Appearance
设置自定义消息接收
方法名
setPushIntentReceiver
用法
- 用法如下:
js
module.setPushIntentReceiver({
params: {
notificationShow: true
},
//成功执行的函数
success: (res) => {
console.log(data)
},
//失败执行的函数
fail: (res) => {
console.log(res)
},
//接口调用完成返回函数,不管成功还是失败都会返回
complete: (res) => {
// console.log(res)
}
})js
module.setPushIntentReceiver({
params: {
notificationShow: true
},
//成功执行的函数
success: (res) => {
console.log(res)
},
//失败执行的函数
fail: (res) => {
console.log(res)
},
//接口调用完成返回函数,不管成功还是失败都会返回
// complete: (res) => {
// console.log(res)
// }
} as LevenOptions)- 参数说明
参数名 参数类型 是否必填 默认值 参数描述 params Object 是 无 接口请求参数 params.notificationShow boolean 是 true 是否立即显示通知
true:立即显示通知
false:不显示通知success Function 否 无 执行成功的函数 fail Function 否 无 执行失败的函数 complete Function 否 无 执行完成的函数,不管成功还是失败都会执行
回调
- 示例
json
{
"data": {
"type": "onNotification",
"title": "这里是标题",
"summary": "这里是内容",
"extraMap": {}
},
"message": "",
"code": 0
}- 回调说明:
参数名 参数类型 参数描述 message String 消息提示 data Object 数据对象 data.type String 消息类型,具体类型如下: onNotification:推送通知到达回调onMessage:收到推送消息的回调onNotificationOpened:点击通知回调onNotificationClickedWithNoAction:点击无跳转逻辑通知的回调,点击无跳转逻辑(open=4)通知时回调该方法onNotificationRemoved:删除通知的回调onNotificationReceivedInApp:通知在应用内回调,该方法仅在notificationShow返回false时才会被回调,且此时不调用onNotification,此时需要您自己处理通知逻辑data.title String 通知标题 onNotificationonNotificationOpenedonNotificationClickedWithNoActiononNotificationReceivedInApponMessage状态下返回data.summary String 通知内容 onNotificationonNotificationOpenedonNotificationClickedWithNoActiononNotificationReceivedInApp状态下返回data.extraMap Object 通知额外参数,包括部分系统自带参数 onNotificationonNotificationOpenedonNotificationClickedWithNoActiononNotificationReceivedInApp状态下返回data.messageId String 消息id onMessageonNotificationRemoved状态下返回data.appId String 应用id onMessage状态下返回data.content String 消息内容 onMessage状态下返回data.traceInfo String - onMessage状态下返回data.openType Integer 原本通知打开方式,1:打开APP;2:打开activity;3:打开URL;4:无跳转逻辑 onNotificationReceivedInApp状态下返回data.openActivity String 所要打开的activity的名称,仅当服务端参数openType=2时有效,其余情况为null onNotificationReceivedInApp状态下返回data.openUrl String 所要打开的URL,仅当服务端参数openType=3时有效,其余情况为null onNotificationReceivedInApp状态下返回code Integer 返回类型,0.成功,其他:失败

