All Products
Search
Document Center

Access third-party push channels

Last Updated: Apr 19, 2021

To improve the arrival rate of pushed messages, mPaaS integrates the push functions of some mainstream mobile phone manufacturers such as Huawei, Xiaomi, OPPO, and vivo. After Mi Push, Huawei Push, OPPO Push, and vivo Push are used to push messages, notifications can still be sent when the process is suspended, and the process can be activated when users tap the notification bar.

Note: Mobile phone manufacturers’ proprietary push channels can help Apps achieve stable push performance. Therefore, we recommend that you access the third-party push channels on your App.

This topic comprises two parts: Access third-party push channels on your App client and Access MpaaSNcActivity, and shows you how to access push functions of third-party channels. The part Access third-party push channels on your App client introduces the client configurations required for accessing the push services of Huawei, Xiaomi, OPPO, and vivo.

Access third-party push channels on your App client

Access Huawei channel

Register with Huawei Push

Visit the Huawei Developer official website, register an account, and enable the push service. For more information, see Enable Huawei push.

Access Huawei Push on your App client

MPS supports access to Huawei HMS2 and HMS5, but in the process of accessing Huawei push components, you can only select one of the versions to access. The following describes the access methods of Huawei HMS2 and HMS5 respectively.

Access Huawei Push - HMS2.x version
  1. Import MPS dependencies. The procedure of accessing a third-party channel is the same as that of accessing an MPS self-built channel. For more information, see Add the SDK.
  2. Add Push - Huawei2 component in the IDE plugin.
  3. Configure AndroidManifest.xml.
    If it is a project based on the mPaaS framework, please configure it in the AndroidManifest.xml configuration file of the Portal project.

    1. <activity
    2. android:name="com.huawei.hms.activity.BridgeActivity"
    3. android:configChanges="orientation|locale|screenSize|layoutDirection|fontScale"
    4. android:excludeFromRecents="true"
    5. android:exported="false"
    6. android:hardwareAccelerated="true"
    7. android:theme="@android:style/Theme.Translucent">
    8. <meta-data
    9. android:name="hwc-theme"
    10. android:value="androidhwext:style/Theme.Emui.Translucent" />
    11. </activity>
    12. <!-- To prevent dex crashing in an earlier version, dynamically enable provider, and set enabled to false.-->
    13. <provider
    14. android:name="com.huawei.hms.update.provider.UpdateProvider"
    15. android:authorities="${applicationId}.hms.update.provider"
    16. android:exported="false"
    17. android:enabled="false"
    18. android:grantUriPermissions="true">
    19. </provider>
    20. <!-- Replace the "appid" of value with the actual App ID in the service details of the App on Huawei Developer. Keep the slash (\) and space in the value. -->
    21. <meta-data
    22. android:name="com.huawei.hms.client.appid"
    23. android:value="\ your huawei appId" />
    24. <receiver
    25. android:name="com.huawei.hms.support.api.push.PushEventReceiver"
    26. >
    27. <intent-filter>
    28. <!-- Receive the notification bar message sent by the channel. It is compatible with earlier versions of PUSH. -->
    29. <action android:name="com.huawei.intent.action.PUSH" />
    30. </intent-filter>
    31. </receiver>
    32. <receiver
    33. android:name="com.alipay.pushsdk.thirdparty.huawei.HuaweiPushReceiver"
    34. android:process=":push">
    35. <intent-filter>
    36. <!-- Required. Used for receiving TOKEN. -->
    37. <action android:name="com.huawei.android.push.intent.REGISTRATION" />
    38. <!-- Required. Used for receiving messages. -->
    39. <action android:name="com.huawei.android.push.intent.RECEIVE" />
    40. <!-- Optional. Used for triggering onEvent callback upon a click on the notification bar or the button on the notification bar. -->
    41. <action android:name="com.huawei.android.push.intent.CLICK" />
    42. <!-- Optional. Used for checking whether the PUSH channel is accessed. You do not need to configure this parameter if access check is not required. -->
    43. <action android:name="com.huawei.intent.action.PUSH_STATE" />
    44. </intent-filter>
    45. </receiver>
  4. Access MpaaSNcActivity.
Access Huawei Push - HMS5.x version
  1. Import MPS dependencies. The procedure of accessing a third-party channel is the same as that of accessing an MPS self-built channel. For more information, see Add the SDK.
  2. Add Push - HMS5 component in the IDE plugin.
  3. Download the configuration file agconnect-services.json in the Huawei App Service Console and place it under the assets directory of the main project.
  4. Configure the Maven warehouse address of HMS Core SDK in the build.gradle file in the project root directory.
    1. allprojects {
    2. repositories {
    3. // Other repos are ignored
    4. maven {url 'https://developer.huawei.com/repo/'}
    5. }
    6. }
  5. Add HMS Core SDK dependencies in the build.gradle file of the main project.
    1. dependencies {
    2. implementation 'com.huawei.hms:push:5.0.2.300'
    3. // Huawei HMS Core SDK version is updated frequently, see the following link for the latest version: https://developer.huawei.com/consumer/cn/doc/HMSCore-Guides-V5/version-change-history-0000001050040072-V5
    4. }
  6. Access MpaaSNcActivity
  7. If you are upgrading from version 2.x to version 5.x, please uninstall the Push - Huawei2 component, and remove the Huawei push configuration in the corresponding AndroidManifest.xml file.

Process application badges

Processing application badges is supported in mPaaS since 10.1.60.13 version. When the server pushes the messages with badge information to the client, the SDK provides an interface to handle the badge information on the application icon.

MPPush class provides the following three interfaces to process application badges:

  • Set whether to automatically clear the application badge information when the messages on the notification bar are clicked. When enable is true, it indicates to automatically clear the badge information while false not.

    1. void setBadgeAutoClearEnabled(Context context, boolean enabled)
  • Set the Activity name of the application icon where the badge is. The Activity name is required, otherwise the badge information cannot be cleared.

    1. void setBadgeActivityClassName(Context context, String name)
  • Clear application badge information. This method can be used to actively clear the badge information when the SDK cannot process the badge information. For example, when the user actively clicks the application icon to enter the application, the badge information is cleared.

    1. void clearBadges(Context context)

Access Xiaomi channel

Register with Mi Push

Refer to the following official Xiaomi documents to complete registration for Mi Push:

Access Mi Push on your App client

  1. Import MPS dependencies. The procedure of accessing a third-party channel is the same as that of accessing an MPS self-built channel. For more information, see Add the SDK.
  2. Add Push - Xiaomi component in the IDE plugin.
  3. Configure AndroidManifest.xml.
    If it is a project based on the mPaaS framework, please configure it in the AndroidManifest.xml configuration file of the Portal project.

    1. <! --As signatures are involved, the permission is put in the portal.-->
    2. <permission
    3. android:name="${applicationId}.permission.MIPUSH_RECEIVE"
    4. android:protectionLevel="signature"/>
    5. <uses-permission android:name="${applicationId}.permission.MIPUSH_RECEIVE"/>
    6. <! --Keep the slash (\) and space in the value.-->
    7. <meta-data
    8. android:name="xiaomi_appid"
    9. android:value="\ 2xxxxxxxxxx" />
    10. <! --Retain the slash (\) and space in the value.-->
    11. <meta-data
    12. android:name="xiaomi_appkey"
    13. android:value="\ 5xxxxxxxxxxxx" />
    14. <service android:name="com.xiaomi.push.service.XMJobService"
    15. android:enabled="true"
    16. android:exported="false"
    17. android:permission="android.permission.BIND_JOB_SERVICE"
    18. android:process=":push" />
    19. <service
    20. android:name="com.xiaomi.push.service.XMPushService"
    21. android:enabled="true"
    22. android:process=":push"/>
    23. <service
    24. android:name="com.xiaomi.mipush.sdk.PushMessageHandler"
    25. android:enabled="true"
    26. android:exported="true"
    27. android:process=":push"/>
    28. <service
    29. android:name="com.xiaomi.mipush.sdk.MessageHandleService"
    30. android:enabled="true"
    31. android:process=":push"/>
    32. <receiver
    33. android:name="com.xiaomi.push.service.receivers.NetworkStatusReceiver"
    34. android:exported="true"
    35. android:process=":push">
    36. <intent-filter>
    37. <action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
    38. <category android:name="android.intent.category.DEFAULT"/>
    39. </intent-filter>
    40. </receiver>
    41. <receiver
    42. android:name="com.xiaomi.push.service.receivers.PingReceiver"
    43. android:exported="false"
    44. android:process=":push">
    45. <intent-filter>
    46. <action android:name="com.xiaomi.push.PING_TIMER"/>
    47. </intent-filter>
    48. </receiver>
    49. <receiver
    50. android:name="com.alipay.pushsdk.thirdparty.xiaomi.XiaoMiMsgReceiver"
    51. android:exported="true"
    52. android:process=":push">
    53. <intent-filter>
    54. <action android:name="com.xiaomi.mipush.RECEIVE_MESSAGE"/>
    55. </intent-filter>
    56. <intent-filter>
    57. <action android:name="com.xiaomi.mipush.ERROR"/>
    58. </intent-filter>
    59. <intent-filter>
    60. <action android:name="com.xiaomi.mipush.MESSAGE_ARRIVED"/>
    61. </intent-filter>
    62. </receiver>
  4. Access MpaaSNcActivity.

Access OPPO channel

Note: OPPO Push is supported only in 10.1.60 and later baseline versions. If you use the AliPushInterface class provided by the earlier version of the baseline for initialization, please use the MPPush class instead.

Register with OPPO Push

Refer to OPPO Push enabling guide to register an account on the OPPO Developers platform and request to access the push service.

Access OPPO Push on your App client

  1. mPaaS does not provide the OPPO Push SDK. Download the SDK by referring to OPPO SDK document and integrate the SDK to the main project.
    Note: The currently supported OPPO Push SDK version is 2.0.2.
  2. Add Push - OPPO component in the IDE plugin.
  3. Configure AndroidManifest.xml.
    If it is a project based on the mPaaS framework, please configure it in the AndroidManifest.xml configuration file of the Portal project.

    1. <uses-permission android:name="com.coloros.mcs.permission.RECIEVE_MCS_MESSAGE" />
    2. <uses-permission android:name="com.heytap.mcs.permission.RECIEVE_MCS_MESSAGE"/>
    3. <application>
    4. <service
    5. android:name="com.heytap.mcssdk.PushService"
    6. android:permission="com.coloros.mcs.permission.SEND_MCS_MESSAGE"
    7. android:process=":push">
    8. <intent-filter>
    9. <action android:name="com.coloros.mcs.action.RECEIVE_MCS_MESSAGE"/>
    10. </intent-filter>
    11. </service>
    12. <service
    13. android:name="com.heytap.mcssdk.AppPushService"
    14. android:permission="com.heytap.mcs.permission.SEND_MCS_MESSAGE"
    15. android:process=":push">
    16. <intent-filter>
    17. <action android:name="com.heytap.mcs.action.RECEIVE_MCS_MESSAGE"/>
    18. </intent-filter>
    19. </service>
    20. <meta-data
    21. android:name="com.oppo.push.app_key"
    22. android:value="Obtain from the OPPO Developers platform"
    23. />
    24. <meta-data
    25. android:name="com.oppo.push.app_secret"
    26. android:value="Obtain from the OPPO Developers platform"
    27. />
    28. <meta-data
    29. android:name="mpaas.notification.channel.default.name"
    30. android:value="default"
    31. />
    32. <meta-data
    33. android:name="mpaas.notification.channel.default.description"
    34. android:value="default message notification"
    35. />
    36. </application>
  4. Access MpaaSNcActivity.

Access vivo channel

Note: vivo Push is supported only in 10.1.60 and later baseline versions.

Register with vivo Push

Refer to vivo Push platform operation guide to register an account on the vivo open platform and request to access the push service.

Access vivo Push on your App client

  1. mPaaS does not provide the vivo Push SDK. Download the SDK by referring to vivo SDK document and integrate the SDK to the main project.
  2. Add Push - vivo component in the IDE plugin.
  3. Configure AndroidManifest.xml.
    If it is a project based on the mPaaS framework, please configure it in the AndroidManifest.xml configuration file of the Portal project.

    1. <application>
    2. <service
    3. android:name="com.vivo.push.sdk.service.CommandClientService"
    4. android:process=":push"
    5. android:exported="true" />
    6. <activity
    7. android:name="com.vivo.push.sdk.LinkProxyClientActivity"
    8. android:exported="false"
    9. android:process=":push"
    10. android:screenOrientation="portrait"
    11. android:theme="@android:style/Theme.Translucent.NoTitleBar" />
    12. <meta-data
    13. android:name="com.vivo.push.api_key"
    14. android:value="Provided by vivo open platform" />
    15. <meta-data
    16. android:name="com.vivo.push.app_id"
    17. android:value="Provided by vivo open platform" />
    18. <receiver
    19. android:name="com.alipay.pushsdk.thirdparty.vivo.PushMessageReceiver"
    20. android:process=":push" >
    21. <intent-filter>
    22. <! --Receive push messages.-->
    23. <action android:name="com.vivo.pushclient.action.RECEIVE" />
    24. </intent-filter>
    25. </receiver>
    26. </application>
  4. Access MpaaSNcActivity.

Access MpaaSNcActivity

Without access to MpaaSNcActivity, third-party channel messages cannot be redirected.

  1. <activity
  2. android:name="com.alipay.pushsdk.thirdparty.MPaaSNcActivity"
  3. android:exported="true"
  4. android:theme="@android:style/Theme.Translucent">
  5. <intent-filter>
  6. <action android:name="android.intent.action.VIEW" />
  7. <category android:name="android.intent.category.DEFAULT" />
  8. </intent-filter>
  9. </activity>