Android

Adding the SDK dependencies

Config the build.gradle of your project as the following example:

buildscript {
    ...
    repositories {
        ...
        maven { url "https://developer.huawei.com/repo/" }
    }
    dependencies {
        ...
        classpath("com.google.gms:google-services:4.3.+")
        classpath("com.huawei.agconnect:agcp:1.4.1.300")
    }
}

allprojects {
    repositories {
        ...
        mavenCentral()
        maven { url "https://developer.huawei.com/repo/" }

    }
}
  • SDK compatibility with Android is as of Android 5.0

If you are with a version of Kotlin less than 1.5.21, you will have to add the following implementation of coroutines in the gradle dependencies:

dependencies {
    implementation 'androidx.appcompat:appcompat:1.1.0'
    ...

    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1'
}

Adding the indigitall services

These services are necessary so that our SDK can synchronize device data with indigitall's servers.

<manifest ...>
    <!-- ... -->

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

    <!-- To obtain the location of the device -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
    <application ...>
        <!-- ... -->

        <!-- MANDATORY -->

        <!-- So that when the user presses a push, the metric is saved -->
        <service android:name="com.indigitall.android.push.services.StatisticService"/>

        <!-- Daily sync of device data -->
        <service android:name="com.indigitall.android.push.services.NightService"/>

        <!-- To start services when you restart the device -->
        <receiver android:name="com.indigitall.android.push.receivers.BootReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

        <!-- OPTIONAL -->

        <!-- So that when the user clicks an InApp message, the metric is saved.
        It is only necessary if you use the InApp message functionality -->
        <service android:name="com.indigitall.android.inapp.services.StatisticInAppService" />

        <!-- To obtain the location of the device.
        It is only necessary if you are going to ask for location permission
        to segment pushes by device location -->
        <receiver android:name="com.indigitall.android.push.receivers.LocationReceiver">
            <intent-filter>
                <action android:name="LocationReceiver.Action.LOCATION_UPDATE" />
            </intent-filter>
        </receiver>

    </application>
</manifest>

Push permission after Android 13 (Api level 33 - Tiramisu)

Android 13 requires you to add the android.permission.POST_NOTIFICATIONS flag to the manifest:

<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

and also override onRequestPermissionsResult in the Main Activity:

  @Override
  public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    IndigitallReactNativePluginModule.Companion.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
  }

Adding Firebase services

To activate Firebase notifications you must add your google-services.json file in your android project inside your app folder and modify your build.gradle file as follows:

...
apply from: "../../node_modules/..."
apply plugin: 'com.google.gms.google-services'

Once the android project is created, it must be added in the manifest of the application, which can be found in the following path:

Add the following lines:

<service android:name="com.indigitall.android.push.services.FirebaseMessagingService"
         android:exported="false">
  <intent-filter>
    <action android:name="com.google.firebase.MESSAGING_EVENT" />
  </intent-filter>
</service>

Adding HMS Services

Our SDK needs to integrate with your HMS (Huawei Mobile Services) project in order to impact the latest Huawei terminals.

HMS makes the connection with the device to be able to send you push notifications. This connection is established with the Push Token, an ephemeral token, unique and generated by HMS for each device.

In order to impact Huawei devices with Harmony, you will need to perform the following steps:

  1. Add the HMSMessagingService service in the project manifest.
<manifest ...>
    <!-- ... -->
    <application ...>
        <!-- ... -->

        <service
            android:name="com.indigitall.android.hms.services.HMSMessagingService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.huawei.push.action.MESSAGING_EVENT" />
            </intent-filter>
        </service>
    </application>

</manifest>
  1. Add the huawei plugin in the gradle of the application, remember that minSdkVersion that Huawei allows is 19:
//build.gradle (app)
plugins {
    id 'com.huawei.agconnect'
}
// if you use apply plugin
// apply plugin: 'com.huawei.agconnect'

android {
    ...

     defaultConfig {
        minSdkVersion 19
     }

     ...
    dependencies {
        ...
        //Updated to at least version 6.3.0.304
        implementation 'com.huawei.hms:push:6.3.0.304'
    }
}
  1. Add dependencies on gradle.project:
// build.gradle (project)

buildscript {
    repositories {
        ...
        mavenCentral()
       maven {
           url 'https://developer.huawei.com/repo/'
			}
    }
    dependencies {
        ...
        classpath 'com.google.gms:google-services:4.3.10'
        classpath 'com.huawei.agconnect:agcp:1.6.5.300'
    }
}
allprojects {
    ...
    mavenCentral()
    maven{
        url 'https://developer.huawei.com/repo/'
    }

}

Exclude HMS Services

If you want to perform the integration without impacting Huawei devices, you have to remove the dependencies from the previous section and add the following code in the application's gradle, where indigitall implementation is:

implementation("com.indigitall:android:4.20.+") {
        exclude(group = "com.indigitall", module = "android-hms")
    }

ProGuard Configuration

Applications that use ProGuard should include the following line in their ProGuard file to ensure proper library functionality:

-keepnames class com.indigitall.android.** { *; }

Setting the notifications icon

This icon will be displayed in the top bar of the Android system and in the header of the pushes sent through your app.
It must be a monochrome icon, that is, the image must contain only one color and alpha.
We give you an example with our logo in monochrome:

Here we show you how your code should be in the AndroidManifest.xml (The icon has to be a png)

<manifest ...>
    <!-- ... -->
    <application ...>
        <!-- ... -->

        <!-- Resource for monochrome icon -->
        <meta-data android:name="indigitall.icon" android:resource="@drawable/YOUR_MONOCHROME_ICON"/>

        <!-- Resource for icon color -->
        <meta-data android:name="indigitall.color" android:resource="@color/colorPrimary"/>
    </application>
</manifest>
  • For further clarification on creating icons, we leave you this link to the Android documentation that may help you: Product Icons