Android

Adding the SDK dependencies

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'
}
  • SDK compatibility with Android is as of Android 5.0

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 fun onRequestPermissionsResult(
        requestCode: Int,
        permissions: Array<String>,
        grantResults: IntArray
    ) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
        IndigitallFlutterPlugin.onRequestPermissionsResult(context, 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 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.indigitall_flutter_plugin.services.IndigitallFirebaseMessagingService"
         android:exported="false">
  <intent-filter>
    <action android:name="com.google.firebase.MESSAGING_EVENT" />
  </intent-filter>

</service>

Adding HMS Services

🚧

WARNING

Currently, in version 1.1.0 of our SDK, HMS services have been excluded because Google prevents any apps with HMS dependencies from being deployed to the PlayStore. As soon as HMS finds a fix, we'll re-publish, and independently, so it doesn't affect this again in the future.
New version 1.2.0 has been released with HMS included and solved this problem with push HMS library version: implementation("com.huawei.hms:push:6.3.0.304")

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 Service

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:

//x.y.z are version you have to use, see changelog to see what is the last
implementation("com.indigitall:android:x.y.z") {
        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