我在 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/