Versions Compared

Key

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

In this page:

Table of Contents

...

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

...

Code Block
languagegroovy
dependencies {
  		implementation 'com.github.relateddigital:euromessage-android:5.1.3$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

Code Block
languagegroovy
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' }
    }
}

...

Code Block
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
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>

        <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>


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

...

Code Block
languagexml
android:requestLegacyExternalStorage="true"

...

 Step 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.

Code Block
languagejava
public class MainApplication extends Application {

    private final String FIREBASE_APP_ALIAS = "euromessage-android";
    private final String HUAWEI_APP_ALIAS = "euromsg-huawei";

    private static EuroMobileManager euroMobileManager;

    @Override
  	 public void onCreate() {
        super.onCreate();

        euroMobileManager = EuroMobileManager.init(FIREBASE_APP_ALIAS, HUAWEI_APP_ALIAS, this);
        euroMobileManager.registerToFCM(getBaseContext());
    }
}

...


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

Code Block
languagejava
	  if (!EuroMobileManager.checkPlayService(getApplicationContext())) {
            setHuaweiTokenToEuromessage();
        }
        

Final code:

Code Block
languagejava
public class MainApplication extends Application {

    private final String FIREBASE_APP_ALIAS = "euromessage-android";
    private final String HUAWEI_APP_ALIAS = "euromsg-huawei";

    private static EuroMobileManager euroMobileManager;

    @Override
  	 public void onCreate() {
        super.onCreate();

        euroMobileManager = EuroMobileManager.init(FIREBASE_APP_ALIAS, HUAWEI_APP_ALIAS, this);
        euroMobileManager.registerToFCM(getBaseContext());

        setExistingFirebaseTokenToEuroMessage();

		if (!EuroMobileManager.checkPlayService(getApplicationContext())) {
            setHuaweiTokenToEuromessage();
        }

    }
}	      

4.4 Getting Push Notification Permission(Android 13 or higher)

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

Code Block
languagegroovy
android {
    compileSdkVersion "33"

    defaultConfig {
        targetSdkVersion "33"
    }
}

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

Code Block
languagejava
EuroMobileManager.getInstance().requestNotificationPermission(activity);

Step 5  - Token User Member Match

...

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.

...