【问题标题】:IOS: Notification only showing cross button not showing Category using GCMIOS:通知仅显示交叉按钮不显示使用 GCM 的类别
【发布时间】: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


【解决方案1】:

嗨,我终于找到了答案,这就是 GCM 的做法

{"to": <reg_token>, "notification": {"body": "Hello from GCM", "click_action": "RELEASEROOM_CATEGORY"}}

click_action 代表类别 :D 感谢每一个人 :D

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-17
    • 2021-02-27
    • 1970-01-01
    相关资源
    最近更新 更多