如何使用Bluemix推送通知服务在警报通知中设置标题?

时间:2016-08-31 23:08:42

标签: apple-push-notifications ibm-cloud ibm-mobile-services

当解锁样式处于警报模式时,我正在尝试使用Bluemix推送通知设置标题,并且似乎苹果文档中有一个选项可根据有效负载键设置标题 https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/TheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH107-SW1,但我在Bluemix推送其他API文档https://mobile.ng.bluemix.net/imfpushrestapidocs/#!/messages/post_apps_applicationId_messages

中看不到该选项

我不能使用静默推送通知,因为当应用被用户杀死并且它没有运行时它无法正常工作--references BlueMix Push Notification - support for Apple localized alert messages以及更多参考https://forums.developer.apple.com/thread/31403

所以我只能看到标题与我的应用程序名称相关联,是否有任何方法可以更改它而不使用静默推送通知? enter image description here

感谢您的回答

1 个答案:

答案 0 :(得分:0)

正如您在Apple文档中看到的那样,您可以通过在UIAlertController中设置参数标题来设置警报的标题。

e.g。

@IBAction func buttonTapped(sender: AnyObject) {
  let alertController = UIAlertController(title: "iOScreator", message:
    "Hello, world!", preferredStyle: UIAlertControllerStyle.Alert)
  alertController.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.Default,handler: nil))

  self.presentViewController(alertController, animated: true, completion: nil)
}

alert

See this article for more information on that.

现在看起来您的另一个问题是询问您是否可以从警报的实际推送通知中设置标题参数。

这不支持开箱即用,但您可以将其作为附加付费参数发送,并在收到设备的推送通知时解析此参数。

payload

所以你会:

  1. 使用附加有效负载
  2. 中的标题发送通知
  3. 从设备接收通知并从中获取标题
  4. UIAlertController
  5. 中设置标题
相关问题