我在UIUserNotificationTypeBadge
设置了UIUserNotificationSettings
但是当通知到达时,徽章仍然没有出现在应用上。
可能是什么原因,在这种情况下解决方案。
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeSound |
UIUserNotificationTypeAlert | UIUserNotificationTypeBadge categories:nil];
答案 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