Versions Compared

Key

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

In this page:

...

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

...

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());
    }
}

...

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.

...

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.

Code Block
languagejava
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    if(intent != null) {
        Bundle bundle = intent.getExtras();
        if (bundle != null) {
            Message message = (Message) intent.getExtras().getSerializable("message");
            if(message != null) {
                // Send open report
                if(EuroMobileManager.getInstance() == null) {
                    EuroMobileManager.init(googleAppAlias, huaweiAppAlias, getApplicationContext()).sendOpenRequest(message);
                } else {
                    EuroMobileManager.getInstance().sendOpenRequest(message);
                }
            } else {
                // Carousel push notification : an item was clicked
                String itemClickedUrl = bundle.getString("CarouselItemClickedUrl");
                if(itemClickedUrl != null && !itemClickedUrl.equals("")) {
                    try {
                        Intent viewIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(itemClickedUrl));
                        viewIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        startActivity(viewIntent);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
}
  • 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+.)

Code Block
languagejava
@Override
protected void onNewIntent(Intent intent) {
  super.onNewIntent(intent);
  if (intent.getExtras() != null) {
    Message message = (Message) intent.getExtras().getSerializable("message");
    String url = message.getUrl();
    // Navigate to the corresponding page by using url above.
  }
}
  • 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.

Code Block
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    if (intent.getExtras() != null) {
        Message message = (Message) intent.getExtras().getSerializable("message");
        EuroMobileManager.getInstance().reportRead(intent.getExtras());
        String url = message.getUrl();
        // Navigate to the corresponding page by using url above.
    }
}

...