gpt4 book ai didi

objective-c - 本地通知,当应用程序处于前台时,applicationIconBadgeNumber保留

转载 作者:行者123 更新时间:2023-12-01 17:19:52 25 4
gpt4 key购买 nike

当应用程序处于前台时,即使我将applicationBadgeNumber设置为0,当我退出该应用程序时,我的应用程序上仍然有一个“1”徽章,哪怕我杀死了它,有什么想法吗?当我在后台运行应用程序时打开通知时,完全没有问题!

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification 
{
NSLog(@"%i", notification.applicationIconBadgeNumber); // Return 1
notification.applicationIconBadgeNumber = 0;
NSLog(@"%i", notification.applicationIconBadgeNumber); // Return 0

UIApplicationState state = [application applicationState];

if (state == UIApplicationStateInactive)
{
// Application was in the background when notification
// was delivered.
}
else
{
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"An item is asking your attention" message:nil delegate:nil
cancelButtonTitle:@"Cancel" otherButtonTitles:@"Show me", nil];
[alert show];
}
}

最佳答案

您在哪里设置applicationBadgeNumber?我认为您正在设置通知徽章编号。

试试这个:

 application.applicationIconBadgeNumber = 0;

关于objective-c - 本地通知,当应用程序处于前台时,applicationIconBadgeNumber保留,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9049487/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com