简体   繁体   English

当应用程序在后台运行时,远程推送通知标志计数不会增加

[英]Remote Push Notification badge count not increasing when app is in background

I am working on remote push notification and getting badge count in payload. 我正在进行远程推送通知,并在有效载荷中获取徽章计数。 it's working fine when my app is active(foreground) but when app run in background and i got push then badge count not increases. 当我的应用程序处于活动状态(前景)时,它工作正常,但是当应用程序在后台运行并且被推送时,徽章计数不会增加。 Please help. 请帮忙。

when app is active it calls didReceiveNotification method. 当应用程序处于活动状态时,它将调用didReceiveNotification方法。

I am receiving this type of info in payload. 我在有效负载中收到此类信息。

{aps = {alert = "Hi all.";badge = 6;sound = default;};}

I am not sure where is issue. 我不确定问题出在哪里。

Try this 尝试这个

-(void)applicationDidBecomeActive:(UIApplication *)application
{
    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:1];
    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
    [[UIApplication sharedApplication] cancelAllNotifications];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM