更新时间:2020-07-14 16:13
在新版本的消息推送 SDK 中,mPaaS 支持内建消息通知,即:
默认情况下,内建消息通知功能是关闭的。打开该功能需要您在其实现的 AliPushRcvService
子类中覆写 useDefaultNotification
方法并返回 true
。
protected abstract boolean useDefaultNotification(String msgKey, String msgValue);
启用内建消息通知后,展示类型消息推送至客户端时,handleActionReceived
方法不再被调用,如果您仍希望获取消息内容,可在 useDefaultNotification
中进行处理。
当用户点击消息时,消息推送 SDK 将根据消息携带的 URL 参数进行跳转。当 URL 为 Web 网页时,浏览器将被启动被打开此 URL。当 URL 为自定义 URI 时,接入应用必须能够接收此 URI 并进行正确处理。步骤如下:
在 AndroidManifest.xml
中声明可接收自定义 URI 的 Activity。下方代码示例中表明 LauncherActivity
可以接收 mpaas://
的 URI。
<activity android:name=".push.LauncherActivity"
android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="mpaas" />
</intent-filter>
</activity>
在 Activity 中处理通知消息的 Intent 对象,可通过 Intent.getData()
方法获取 URI 并进行跳转。通知消息携带的额外参数可通过 Intent.getStringExtra("data")
获取。
SDK 使用的消息通知 ID 从 10000 开始,请避免您使用的其他通知栏消息 ID 与 SDK 使用的消息通知 ID 冲突。
在文档使用中是否遇到以下问题
更多建议
匿名提交