iOS azure推送通知应用程序徽章

时间:2016-06-02 07:15:47

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

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

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

1 个答案:

答案 0 :(得分:2)

您需要在通知有效内容中设置徽章值。

以下是将徽章设置为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