iOS 天蓝色推送通知应用程序角标(Badge)

标签 ios iphone apple-push-notifications azure-notificationhub

我在 UIUserNotificationSettings 中设置了 UIUserNotificationTypeBadge,但是当通知到达时,badge 仍然没有出现在应用程序上。
可能是什么原因以及在这种情况下的解决方案。

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeSound |
                                            UIUserNotificationTypeAlert | UIUserNotificationTypeBadge categories:nil];

最佳答案

您需要在通知负载中设置角标(Badge)值。

这是将角标(Badge)设置为 5 的示例代码。

{
    "aps" : {
        "alert" : {
            "title" : "Game Request",
            "body" : "Bob wants to play poker"
        },
        "badge" : 5
}

您可以在此处了解有关负载的更多信息。 https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/TheNotificationPayload.html

关于iOS 天蓝色推送通知应用程序角标(Badge),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37585083/

相关文章:

iphone - 通用应用中的文档目录

iphone - 如何将背景音乐同步到屏幕上的视觉效果?

ios - 向 iOS 设备发送推送通知

ios - ARC 语义问题 "multiple methods named ' setRotation'“仅在归档时

ios - Xcode:使用不同的选项运行两次测试

ios - 从 UIPageViewController 点指示器中删除黑条

xcode - 如何在 Mac 上使用 Apple 推送通知?

ios - Flutter iOS 推送未收到

ios - 使用 NSOutputStream,我看到 00 00 0a 00 而不是 0a 00 00 00

ios - NSPredicate SELF CONTAINS[c] 首先返回较长文本中包含的值