我目前有一个iOS项目,但推送通知操作没有显示。以下是我负责测试的有效负载体:
$body['aps'] = array(
'alert' => $message,
'sound' => 'default',
'link_url' => $url,
'category' => 'NEWS_CATEGORY',
);
以下是App Delegate中的registerForPushNotifications:
func registerForPushNotifications(application: UIApplication) {
//allows notification actions by setting catagories
let viewAction = UIMutableUserNotificationAction()
viewAction.identifier = "VIEW_IDENTIFIER"
viewAction.title = "View"
viewAction.activationMode = .Foreground
let newsCategory = UIMutableUserNotificationCategory()
newsCategory.identifier = "NEWS_CATEGORY"
newsCategory.setActions([viewAction], forContext: .Default)
let notificationSettings = UIUserNotificationSettings(forTypes: [.Badge, .Sound, .Alert], categories: [newsCategory])
}
非常感谢有关通知操作未显示原因的任何帮助!
答案 0 :(得分:1)
似乎忘了向应用程序添加实际的注册设置。添加
application.registerUserNotificationSettings(notificationSettings)
let notificationSettings = UIUserNotificationSettings(forTypes: [.Badge, .Sound, .Alert], categories: [newsCategory])
之后