All Products
Document Center

Use mPaaS built-in message notification

Last Updated: Apr 29, 2021

In the latest MPS SDK, mPaaS supports notification built in mPaaS.

  • When a message (non-silent) arrives, the SDK automatically shows a system notification and handles the redirection event.
  • The SDK automatically handles messages upon their arrival, opens the messages, and tracks ignored messages. It saves you the trouble to manually call the corresponding operations.

Enable built-in message notification

mPaaS built-in message notification is turned off by default. To enable this function, you need to overwrite the useDefaultNotification method in the AliPushRcvService subclass and return the value of true.

  1. protected abstract boolean useDefaultNotification(String msgKey, String msgValue);

After the notification function is enabled, when a message (with display type as “show message”) is pushed to a client, the handleActionReceived method is no longer called. To get the message content, call the useDefaultNotification method.

Implement message redirection

When a user taps a message, the MPS SDK redirects to the URL specified in the message. If the URL is a Web page, the SDK launches the browser to open the URL. If the URL is a custom URI, the App must be able to receive the URI and handle it correctly. Perform the following steps:

  1. In AndroidManifest.xml, declare the activity that can receive a custom URI. The following code sample shows that LauncherActivity can receive the URI of mpaas://.

    1. <activity android:name=".push.LauncherActivity"
    2. android:launchMode="singleInstance">
    3. <intent-filter>
    4. <action android:name="android.intent.action.MAIN" />
    5. <category android:name="android.intent.category.LAUNCHER" />
    6. </intent-filter>
    7. <intent-filter>
    8. <action android:name="android.intent.action.VIEW" />
    9. <category android:name="android.intent.category.BROWSABLE" />
    10. <category android:name="android.intent.category.DEFAULT" />
    11. <data android:scheme="mpaas" />
    12. </intent-filter>
    13. </activity>
  2. To set the intent object of a notification message in Activity, you can use Intent.getData() to get the URI and redirect to it. To get additional parameters specified in a notification message, call the Intent.getStringExtra("data") method.


Message notification IDs used by the SDK start from 10000. Do not use the same SDK notification IDs for other messages shown on notification bar.