我正在UIUserNotificationSettings
中设置UIUserNotificationTypeBadge
,但当通知到达时,徽章仍然没有出现在应用程序上。
可能是什么原因,在这种情况下是解决方案。
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeSound |
UIUserNotificationTypeAlert | UIUserNotificationTypeBadge categories:nil];
您需要在通知有效负载中设置徽章值。
下面是将锁屏提醒设置为 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