Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Installation

  • Install prerequisites.

Code Block
yarn add @react-native-async-storage/async-storage
  • Install package.

Code Block
yarn add react-native-related-digital
  • Install pods (IOS only).

Code Block
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 the agconnect-services.json file to the same location.

Code Block
maven {url 'http://developer.huawei.com/repo/'}
  • Add below lines to your android/build.gradle file's dependencies section.

Code Block
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.

Code Block
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.

Code Block
multiDexEnabled true
  • Add below code to your AndroidManifest.xml file's application section to receive notifications when the app is foreground.

Code Block
languagexml
<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.

Code Block
languagexml
<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>
Code Block
languagexml
<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.

Code Block
languagejava
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.

Code Block
languagejs
  await visilabsApi.sendTheListOfAppsInstalled()

Also, add one of the below sections to your AndroidManifest.xml

Option 1

Code Block
languagexml
<manifest package="com.example.myApp">
    <queries>
        <package android:name="com.example.app1" />
        <package android:name="com.example.app2" />
    </queries>
</manifest>

Option 2

Code Block
languagexml
<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.

Code Block
languagejs
  addEventListener('carouselItemClicked', async (carouselItemInfo) => {
    console.log('carouselItemInfo is ', carouselItemInfo)
  }, euroMessageApi)