且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何自定义推送通知?

更新时间:2022-11-18 18:31:08

根据解析"推送通知

According to Parse push notification docs, you can send the following options in your push notification payload:

  • 警告:通知的消息.
  • 徽章:(仅限iOS)应用图标右上角指示的值.可以将其设置为一个值或增量",以使当前值增加1.
  • 声音:(仅适用于iOS)应用程序捆绑包中声音文件的名称.
  • 可用内容:(仅适用于iOS)如果您正在使用iOS7中引入的远程通知后台模式"(也称为"Background Push")编写应用程序,请将此值设置为1以触发后台下载.您还必须从iOS 13和watchOS 6开始设置push_type.
  • push_type :(仅适用于iOS)通知的类型.该值为警报或背景.当您的通知传递显示警报,播放声音或标记应用程序图标时,请指定警报.为不与用户交互的静默通知指定背景.如果未设置任何值,则默认为发出警报.向运行iOS 13和更高版本或watchOS 6和更高版本的设备发送通知时需要.
  • 优先级:(仅适用于iOS)通知的优先级.指定10立即发送通知.指定5以根据用户设备上的电源注意事项发送通知. (更多详细文档)
  • 类别:(仅限iOS)此推送通知的UNNotification分类的标识符.
  • uri :(仅限Android)包含URI的可选字段.打开通知后,将启动与打开URI相关的活动.
  • 标题:(仅适用于Android)Android系统任务栏通知中显示的值.
  • alert: the notification’s message.
  • badge: (iOS only) the value indicated in the top right corner of the app icon. This can be set to a value or to Increment in order to increment the current value by 1.
  • sound: (iOS only) the name of a sound file in the application bundle.
  • content-available: (iOS only) If you are a writing an app using the Remote Notification Background Mode introduced in iOS7 (a.k.a. "Background Push"), set this value to 1 to trigger a background download. You also have to set push_type starting iOS 13 and watchOS 6.
  • push_type: (iOS only) The type of the notification. The value is alert or background. Specify alert when the delivery of your notification displays an alert, plays a sound, or badges your app’s icon. Specify background for silent notifications that do not interact with the user. Defaults to alert if no value is set. Required when delivering notifications to devices running iOS 13 and later, or watchOS 6 and later.
  • priority: (iOS only) The priority of the notification. Specify 10 to send the notification immediately. Specify 5 to send the notification based on power considerations on the user’s device. (More detailed documentation)
  • category: (iOS only) the identifier of the UNNotification​Category for this push notification.
  • uri: (Android only) an optional field that contains a URI. When the notification is opened, an Activity associated with opening the URI is launched.
  • title: (Android only) the value displayed in the Android system tray notification.

除此之外,您还可以按照以下指南在iOS应用中编写自定义推送通知处理程序: http://docs.parseplatform.org/ios/guide/#responding-to-the-payload

Besides these, you can also write a custom push notification handler in your iOS app by following this guide: http://docs.parseplatform.org/ios/guide/#responding-to-the-payload