All Products
Document Center

Advanced functions

Last Updated: Jul 13, 2021

After integrating the push SDK, you can also perform the following client configuration:


  • The MPPushMsgServiceAdapter method mentioned in this guide is only applicable for baseline or later version. If your current baseline version is lower than, refer to mPaaS upgrade guide to upgrade the baseline.
  • You can continue using the AliPushRcvService method in the earlier version. Please submit a ticket or contact the mPaaS support staff to obtain the old version documents.

Clear notification badges

For third-party channels, you can enable that a badge appears on the app icon when users receive messages. Currently, the push SDK only supports automatic badge clearance for Huawei channel.

  • To clear the app badge automatically when users click the notification, perform the following settings:

    1. // Set whether to clear automatically
    2. boolean autoClear = true;
    3. MPPush.setBadgeAutoClearEnabled(context, autoClear);
    4. // Set the Activity name of the app entrance. If not set, badges cannot be cleared
    5. String activityName = "com.mpaas.demo.push.LauncherActivity";
    6. MPPush.setBadgeActivityClassName(context, activityName);
  • In the scenario that the badge cannot be cleared automatically, for example, the user actively clicks the app icon to enter the app, you can call the following method in Application to actively clear the badge:

    1. MPPush.clearBadges(context);

Report third-party channel tokens

With the third-party channels integrated, the push SDK will receive the third-party channel token after initialization, automatically bind it with the self-built channel token, and report the tokens.

If necessary, you can override the onChannelTokenReceive and onChannelTokenReport methods of MPPushMsgServiceAdapter to listen the delivery and report of third-party channel tokens.

  1. public class MyPushMsgService extends MPPushMsgServiceAdapter {
  2. /**
  3. * Callback for the reception of third-party channel token
  4. *
  5. * @param channelToken Third-party channel token
  6. * @param channel Third-party channel type
  7. */
  8. @Override
  9. protected void onChannelTokenReceive(String channelToken, PushOsType channel) {
  10. Log.d("Receive third-party channel token: " + channelToken);
  11. Log.d("Vendor: " + channel.getName());
  12. }
  13. /**
  14. * Callback for the report of third-party channel token
  15. *
  16. * @param result Report result
  17. */
  18. @Override
  19. protected void onChannelTokenReport(ResultBean result) {
  20. Log.d("Report third-party channel token " + (result.success ? "Succeeded" : ("Error:" + result.code)));
  21. }
  22. /**
  23. * Whether to report the third-party channel token automatically
  24. *
  25. * @return If false is returned, you can report the token by yourself
  26. */
  27. @Override
  28. protected boolean shouldReportChannelToken() {
  29. return super.shouldReportChannelToken();
  30. }
  31. }

To bind the tokens and report them by yourself, you can override the shouldReportChannelToken method and return false. You must call the following method after receiving the two tokens.

  1., token , channel.value(), channelToken);

Customize NotificationChannel

To customize the name and description of NotificationChannel for the self-built channel, you can add the following content in the AndroidManifest.xml file:

  1. <meta-data
  2. android:name=""
  3. android:value="Name" />
  4. <meta-data
  5. android:name=""
  6. android:value="Description" />