All Products
Search
Document Center

Mobile Platform as a Service:Advanced features

Last Updated:Mar 26, 2024

After integrating the push SDK, you can configure the client as follows:

Prerequisites

  • The MPPushMsgServiceAdapter method in this topic applies only to baseline versions 10.1.68.32 and later. If the current baseline version is earlier than 10.1.68.32, upgrade the baseline version by referring to mPaaS Upgrade Guide.

  • The AliPushRcvService method in the old version can still be used. Click here to download the old version of the document.

Clear corner mark

For messages received through the vendor channel, the number of messages can be displayed on the app icon. Currently, the push SDK only supports Huawei channels to automatically clear corner markers.

  • Set the application corner to automatically clear when the user clicks the notification:

    // Specify whether to automatically clear the data.
      boolean autoClear = true;
      MPPush.setBadgeAutoClearEnabled(context, autoClear);
      // Set the application entry Activity class name. If you do not set this parameter, you cannot clear the corner mark.
      String activityName = "com.mpaas.demo.push.LauncherActivity";
      MPPush.setBadgeActivityClassName(context, activityName);
  • In scenarios where corner markers cannot be automatically cleared, for example, when a user actively clicks an application icon to enter an application, you can call the following method in the Application to actively clear corner markers:

      MPPush.clearBadges(context);

Report vendor channel token

If you have connected to the vendor channel, the push SDK will receive the token of the vendor channel after initialization. The push SDK will automatically bind the vendor channel token and user-created channel token for reporting.

If necessary, you can listen for the issuance and reporting of the vendor channel token by rewriting the MPPushMsgServiceAdapter onChannelTokenReceive and onChannelTokenReport methods:

public class MyPushMsgService extends MPPushMsgServiceAdapter {

    /**
     * Callback of the vendor channel token received
     *
     * @param channelToken The token of the vendor channel.
     * @param channel The type of the vendor channel.
     */
    @Override
    protected void onChannelTokenReceive(String channelToken, PushOsType channel) {
        Log.d("Received vendor channel token: " + channelToken);
        Log.d("Vendor: " + channel.getName());
    }

    /**
     * Callback for the result of vendor channel token reporting
     *
     * @param result The report result.
     */
    @Override
    protected void onChannelTokenReport(ResultBean result) {
        Log.d("Report vendor token " + (result.success ? "Success" : ("Error:" + result.code)));
    }

    /**
     * Indicates whether the vendor token is automatically reported.
     *
     * @return The return value is false, which can be reported as required.
     */
    @Override
    protected boolean shouldReportChannelToken() {
        return super.shouldReportChannelToken();
    }

}

If you need to bind the report, you can override the shouldReportChannelToken method and return false, and call it after ensuring that you have received two tokens:

MPPush.report(context, token , channel.value(), channelToken);

Custom NotificationChannel

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

<meta-data
    android:name="mpaas.notification.channel.default.name"
    android:value="Name" />
<meta-data
    android:name="mpaas.notification.channel.default.description"
    android:value="Description" /> 

Adjust push channel priority order

Baseline 10.2.3.43 and later allow you to adjust the priority of vendor channels on specific devices. To use this feature, create a mpaas_push_config.properties file in the assets directory of your project and enable it as needed.

Prioritize the Honor channel on Huawei /Honor devices

To preferentially use the Honor Push Channel on Huawei or Honor devices, add the following to the file mpaas_push_config.properties:

// Prioritize the use of Honor channels on Huawei /Honor devices
isHonorBeforeHms=true

Prioritize the use of device vendor channels on devices with FCM push capabilities

To preferentially use the device vendor's channel on devices with FCM push capabilities, add the following to the file mpaas_push_config.properties:

// Device vendor’ channels will be used first on devices with FCM push capability.
isFcmEnd=true