Installation
Install prerequisites.
yarn add @react-native-async-storage/async-storage
Install package.
yarn add react-native-related-digital
Install pods (IOS only).
cd ios pod install
Platform Integrations
Android
Create a Firebase project and register your app. Download google-services.json file and place it in
android/app
folder.Add below line to your
android/build.gradle
file's both repositories sections. If you are going to do Huawei integration, add theagconnect-services.json
file to the same location.
maven {url 'http://developer.huawei.com/repo/'}
Add below lines to your
android/build.gradle
file's dependencies section.
classpath 'com.google.gms:google-services:4.3.3' classpath 'com.huawei.agconnect:agcp:1.4.1.300'
Change your
minSdkVersion
to 19.Add below lines to your
android/app/build.gradle
file's bottom.
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.huawei.agconnect'
Add below line to your
android/app/build.gradle
file's defaultConfig section.
multiDexEnabled true
Add below code to your
AndroidManifest.xml
file'sapplication
section to receive notifications when the app is foreground.
<service android:name="euromsg.com.euromobileandroid.service.EuroFirebaseMessagingService" android:exported="false"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service>
If you are going to do Huawei integration, add the following lines to the file.
<service android:name="euromsg.com.euromobileandroid.service.EuroHuaweiMessagingService" android:exported="false"> <intent-filter> <action android:name="com.huawei.push.action.MESSAGING_EVENT" /> </intent-filter> </service>
In order to send push to Huawei devices, you need to follow the steps in the link from the Huawei Developer panel. https://developer.huawei.com/consumer/en/doc/HMS-Plugin-Guides-V1/config-agc-0000001050178043-V1
Add below code to your
AndroidManifest.xml
file'sapplication
section to enable geofence capability.
<service android:name="com.visilabs.gps.geofence.GeofenceTransitionsIntentService" android:enabled="true" android:permission="android.permission.BIND_JOB_SERVICE" /> <service android:name="com.visilabs.gps.geofence.GeofenceMonitor" android:enabled="true" android:exported="true" /> <receiver android:name="com.visilabs.gps.geofence.GeofenceTransitionsReceiver" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="com.visilabs.android.gps.geofence.ACTION_RECEIVE_GEOFENCE" /> </intent-filter> </receiver> <receiver android:name="com.visilabs.gps.geofence.VisilabsAlarm" android:exported="false" /> <receiver android:name="com.visilabs.gps.geofence.GeofenceBroadcastReceiver" android:enabled="true" android:exported="true" />
Modify your
MainApplication.java
as below to init library. Change geofenceEnabled parameter as you want.
import com.visilabs.Visilabs; import euromsg.com.euromobileandroid.EuroMobileManager; @Override public void onCreate() { // ... initEuroMessage(); } private void initEuroMessage() { String appAlias = "demo-alias"; String huaweiAppAlias = "demo-alias-huawei"; String organizationId = "OID"; String siteId = "SID"; String datasource = "datasource"; String channel = "Android"; String segmentUrl = "http://lgr.visilabs.net"; String realtimeUrl = "http://rt.visilabs.net"; String targetUrl = "http://s.visilabs.net/json"; String actionUrl = "http://s.visilabs.net/actjson"; String geofenceUrl = "http://s.visilabs.net/geojson"; Visilabs.CreateAPI(organizationId, siteId, segmentUrl, datasource, realtimeUrl, channel, this, targetUrl, actionUrl, 30000, geofenceUrl, true); EuroMobileManager euroMobileManager = EuroMobileManager.init(appAlias, huaweiAppAlias, this); // optional euroMobileManager.setPushIntent("com.pushsdk.MainActivity", this); euroMobileManager.setNotificationTransparentSmallIcon(R.drawable.ic_launcher, this); euroMobileManager.setNotificationTransparentSmallIconDarkMode(R.drawable.ic_launcher, this); euroMobileManager.useNotificationLargeIcon(true); euroMobileManager.setNotificationLargeIcon(R.drawable.ic_launcher, this); euroMobileManager.setNotificationLargeIconDarkMode(R.drawable.ic_launcher, this); euroMobileManager.setNotificationColor("#d1dbbd"); euroMobileManager.setChannelName("Channel", this); }
If you want to track installed apps, call below method.
await visilabsApi.sendTheListOfAppsInstalled()
Also, add one of the below sections to your AndroidManifest.xml
Option 1
<manifest package="com.example.myApp"> <queries> <package android:name="com.example.app1" /> <package android:name="com.example.app2" /> </queries> </manifest>
Option 2
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" tools:ignore="QueryAllPackagesPermission" />
Add below listener to be able to handle carousel push notification's item click.
addEventListener('carouselItemClicked', async (carouselItemInfo) => { console.log('carouselItemInfo is ', carouselItemInfo) }, euroMessageApi)