Euromessage Android SDK Setup

In this page:


Step 1 - Requirements

Android mobile app  & Android Studio

Firebase Cloud Messaging ve Huawei Push Kit - google_services.json & agconnect_services.json

RMC Account - AppAlias

Minimum 21 API Level Test Device

Step 2 - Adding Dependencies

2.1  Add Euromessage to the dependencies in app/build.gradle.

dependencies { implementation 'com.github.relateddigital:euromessage-android:$euromessage_version' } apply plugin: 'com.huawei.agconnect' apply plugin: 'com.google.gms.google-services'

 Click to know the latest version: Euromessage Android GitHub

2.2 Please add code block to project / build.gradle

buildscript { repositories { google() jcenter() maven {url 'http://developer.huawei.com/repo/'} } dependencies { classpath "com.android.tools.build:gradle:$gradle_version" classpath 'com.google.gms:google-services:$google_version' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.huawei.agconnect:agcp:$huawei_version' } } allprojects { repositories { google() jcenter() maven {url 'http://developer.huawei.com/repo/'} maven { url 'https://jitpack.io' } } }

Step 3  - Adding codes to Android Manifest

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


Push notifications are from FCM and HMS will be covered by Euromessage. You may need to define your application's Application Class - if it does not exist. All you have to do here is create a new class, extend it from Application Class and define it in the AndroidManifest file

If you are using WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE permissions in your application, you need to add the following line to your AndroidManifest.xml file in the <application tag

Step 4  - Add other codes

You will see example implementation below. For this you need to define FIREBASE_APP_ALIAS and HUAWEI_APP_ALIAS through the RMC panel.


4.1 Getting Token from Firebase Messaging Services

EuroFirebaseMessagingService takes and subscribes token for an application opened for the first time in the onNewToken () method.

To set the tokens you already have, you need to add the following codes


4.2 Getting Token Huawei Messaging Service

In Huawei, the method of generating tokens are different according to the EMUI version.

EMUI less than 10, subscribe tokens on onNewToken () in EuroHuaweiMessagingService,

On EMUI 10, phones generate tokens as follows. You have to subscribe this generated token to euroMobileManager.

OR


4.3 In devices where two services are active, to avoid sending the token twice

Final code:

 

4.4 Getting Push Notification Permission(Android 13 or higher)

Validate your SDK versions. Compile and target SDK version should be at least 33.

Use the below Euromessage method to trigger the native prompt to request push notification permission.

Step 5  - Token User Member Match

If various parameters belonging to the user are known, they can be added in the activity as below or during the registration phase. Thanks to the code block below, if the user with the same information is available in the Euromessage RMC panel, the received token will be matched to the user.

With this method, values ​​are added to the extra parameter in the json object sent to the server for subscribe operation and it is specified with which token the user will match. The sync () method should be called after the mandatory parameters and optional parameters are sent.

As soon as an application is installed on the mobile device, the token information of this device is written to the RMC database with the push subscription service. A token; “anonymous”, that is, it is recorded without being paired with any user until the user logs in to the application. In order for this token to be paired with a user, it must be logged in the device and an information identifying the owner of this token (KEY_ID or EMAIL) must be sent to the RMC. This information is located in the "extra": {} block in the push message payload.

In order for your data from the mobile channel to be uploaded to RMC, please pay attention that whatever reference value you have used in your active RMC account (KEY_ID * or E-Mail) comes from the mobile channel with this reference.

*KEY_ID: These are the id values ​​used by the application owner to deduplicate the customer. These can be expressed with different names such as CRMid, userid, customerid, accountid.

Extra parameter in payload sent for user-token matching will take parameters in this way;

Step 6 - IYS Email Register

If your user is a corporate account, you must send it as a TACIR. To do this, change the value from false to true in registerEmail method.

Step 7  - Read Report & Navigating

To capture the content of the incoming push notification, you should use the onNewIntent() method as follows. If you have previously entered a class through the EuroMobileManager.setPushIntent() method, the onNewIntent() method must be added to that class. If you did not use the setPushIntent() method, the onNewIntent() method must be added to the launcher activity.

If you did not use the setPushIntent() method, the onNewIntent() method must be added to the launcher activity.

About read reports:

  • If you are using SDK version 5.1.3 or higher, you have to send the read report yourself. It cannot be shipped by the SDK due to restrictions with Android 12.

  • If you are using SDK version 5.0 - 5.1.2, SDK will automatically send read reports. That's why you shouldn't call the reportRead() method. (This method is not already available in SDK versions 5.0+.)

  • If you are using an SDK version below 5.0, you should call the reportRead() method as below for the read reports to be reflected on the panel.

Proposal :

If the push notification reaches your device in debug mode when sending campaigns from RMC, but not in release mode, take a look at your problems with pro-guard in your application.

You can add the following codes to proguard-rules.pro;


Sample Apps :

Euromessage Demo

Shopping Demo- VL&EM

Copyright 2020 Related Digital