【发布时间】:2015-12-09 07:48:04
【问题描述】:
我正在尝试在 IOS 中使用 UIMutableUserNotificationCategory 显示通知,但它只显示默认十字按钮而不显示其他按钮,然后我添加到类别中。它应该像下面这样显示。 GCM 是否可能。这就是我在应用程序 didfinishlaunching 中添加类别的方式
// Category
let releaseRoomCategory = UIMutableUserNotificationCategory()
releaseRoomCategory.identifier = categoryID
releaseRoomCategory.setActions([yesAction, noAction],
forContext: UIUserNotificationActionContext.Minimal)
releaseRoomCategory.setActions([yesAction, noAction], forContext: .Default)
let settings: UIUserNotificationSettings =
UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: NSSet(object: releaseRoomCategory) as? Set<UIUserNotificationCategory>)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()
【问题讨论】:
-
gcm 应该用于 android 消息传递,你应该使用 apns 苹果推送通知服务为 iOS
-
服务器正在为 IOS 和 android 使用 gcm 我不确定我能否在 IOS 的 gcm 有效负载中设置类别
-
你还需要 ApplePushNotification 服务,你需要一个证书developers.google.com/cloud-messaging/ios/client
-
是的,我做了这一切,也收到了通知,但现在我找不到如何在 gcm 通知中传递类别的方法,例如 { "aps": { "badge": 1, "alert": “世界你好!”、“类别”:“SHARE_CATEGORY” } }
-
根据GCM这里发送下游消息的官方文档:developers.google.com/cloud-messaging/downstream您可以尝试在
data中发送类别并稍后在您的应用程序中处理。
标签: ios swift push-notification google-cloud-messaging