Skip to content

设置自定义消息接收

方法名

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)
  • 参数说明
    参数名参数类型是否必填默认值参数描述
    paramsObject接口请求参数
    params.notificationShowbooleantrue是否立即显示通知
    true:立即显示通知
    false:不显示通知
    successFunction执行成功的函数
    failFunction执行失败的函数
    completeFunction执行完成的函数,不管成功还是失败都会执行

回调

  • 示例
json
{
    "data": {
      "type": "onNotification",
      "title": "这里是标题",
      "summary": "这里是内容",
      "extraMap": {}
    },
    "message": "",
    "code": 0
}
  • 回调说明:
    参数名参数类型参数描述
    messageString消息提示
    dataObject数据对象
    data.typeString消息类型,具体类型如下:
    onNotification:推送通知到达回调
    onMessage:收到推送消息的回调
    onNotificationOpened:点击通知回调
    onNotificationClickedWithNoAction:点击无跳转逻辑通知的回调,点击无跳转逻辑(open=4)通知时回调该方法
    onNotificationRemoved:删除通知的回调
    onNotificationReceivedInApp:通知在应用内回调,该方法仅在notificationShow返回false时才会被回调,且此时不调用onNotification,此时需要您自己处理通知逻辑
    data.titleString通知标题 onNotification onNotificationOpened onNotificationClickedWithNoAction onNotificationReceivedInApp onMessage 状态下返回
    data.summaryString通知内容 onNotification onNotificationOpened onNotificationClickedWithNoAction onNotificationReceivedInApp 状态下返回
    data.extraMapObject通知额外参数,包括部分系统自带参数 onNotification onNotificationOpened onNotificationClickedWithNoAction onNotificationReceivedInApp 状态下返回
    data.messageIdString消息id onMessage onNotificationRemoved 状态下返回
    data.appIdString应用id onMessage状态下返回
    data.contentString消息内容 onMessage状态下返回
    data.traceInfoString- onMessage状态下返回
    data.openTypeInteger原本通知打开方式,1:打开APP;2:打开activity;3:打开URL;4:无跳转逻辑 onNotificationReceivedInApp状态下返回
    data.openActivityString所要打开的activity的名称,仅当服务端参数openType=2时有效,其余情况为nullonNotificationReceivedInApp状态下返回
    data.openUrlString所要打开的URL,仅当服务端参数openType=3时有效,其余情况为nullonNotificationReceivedInApp状态下返回
    codeInteger返回类型,0.成功,其他:失败