Skip to content

自定义通知样式

注意

  • 当前插件仅支持BasicCustomPushNotification的自定义样式,暂不支持AdvancedCustomPushNotification自定义布局文件式自定义样式

方法名

basicCustomPushNotification

用法

  • 用法如下:
js
module.basicCustomPushNotification({
  params: {
    statusBarDrawable: "abc",
    remindType:"REMIND_TYPE_VIBRATE_AND_SOUND",
    notificationFlags:"FLAG_AUTO_CANCEL",
    serverOptionFirst:false,
    buildWhenAppInForeground:true
  },
  //成功执行的函数
  success: (res) => {
    console.log(data)
  },
  //失败执行的函数
  fail: (res) => {
    console.log(res)
  },
  //接口调用完成返回函数,不管成功还是失败都会返回
  complete: (res) => {
    // console.log(res)
  }
})
js
module.basicCustomPushNotification({
  params: {
    statusBarDrawable: "abc",
    remindType:"REMIND_TYPE_VIBRATE_AND_SOUND",
    notificationFlags:"FLAG_AUTO_CANCEL",
    serverOptionFirst:false,
    buildWhenAppInForeground:true
  },
  //成功执行的函数
  success: (res) => {
    console.log(res)
  },
  //失败执行的函数
  fail: (res) => {
    console.log(res)
  },
  //接口调用完成返回函数,不管成功还是失败都会返回
  // complete: (res) => {
  //   console.log(res)
  // }
} as LevenOptions)
  • 参数说明
    参数名参数类型是否必填默认值参数描述
    paramsObject接口请求参数
    params.statusBarDrawableString设置自定义通知的状态栏图标,文件须放置到app-android > res > drawable目录下,如果插件中没有该目录需创建一个,statusBarDrawable参数无需带扩展名
    params.remindTypeString自定义通知的提醒方式,可选值如下:
    REMIND_TYPE_SILENT:静默
    REMIND_TYPE_VIBRATE:震动
    REMIND_TYPE_SOUND:声音
    REMIND_TYPE_VIBRATE_AND_SOUND:声音+震动
    params.notificationFlagsString支持系统自带的Notification Flag参数,可选值如下:
    FLAG_AUTO_CANCEL FLAG_BUBBLE FLAG_INSISTENT FLAG_NO_CLEAR FLAG_LOCAL_ONLY FLAG_FOREGROUND_SERVICE FLAG_GROUP_SUMMARY FLAG_ONGOING_EVENT FLAG_ONLY_ALERT_ONCE FLAG_SHOW_LIGHTS
    params.serverOptionFirstBooleanfalse是否服务器配置优先
    true:采用后端设定的提醒方式
    false:采用自定义样式指定的提醒方式
    params.buildWhenAppInForegroundBooleantrue设置当推送到达时应用处在前台的情况下是否创建自定义通知
    successFunction执行成功的函数
    failFunction执行失败的函数
    completeFunction执行完成的函数,不管成功还是失败都会执行

回调

  • 示例
json
{
    "data": {
      "result": true
    },
    "message": "",
    "code": 0
}
  • 回调说明:
    参数名参数类型参数描述
    messageString消息提示
    dataObject数据对象
    data.resultBoolean操作结果
    codeInteger返回类型,0.成功,其他:失败