且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

增加推送通知徽章 iPhone

更新时间:2023-02-27 08:44:11

通常在所有应用程序中,未读通知计数都保存在服务器中.当服务器向特定设备令牌发送推送通知时,它们会随负载一起发送徽章计数.一旦设备收到通知并且您的应用程序处于后台(或终止),操作系统会自动将徽章计数更新为您的应用程序图标.如果您的应用程序是否正在运行,您将在

Usually in all apps the unread notification counts are maintained in the server. When the server sends a push notification to a particular device token they send the badge count along with the payload. Once the device is notified and your app is in background(or killed) the OS automatically update the badge count to your app icon. In case whether you have your app running, you will get notified in the

application:didReceiveRemoteNotification:

委托,因此您可以从 (NSDictionary *)userInfo 接收徽章计数.因此,您可以使用该功能更新应用图标徽章计数

delegate and thus you are able to receive the badge count from the (NSDictionary *)userInfo. And thus you are able to update the app icon badge count using the function

[UIApplication sharedApplication].applicationIconBadgeNumber = [[[userInfo objectForKey:@"aps"] objectForKey: @"badgecount"] intValue];

认为这应该对您有所帮助.

Think this should help you.