gpt4 book ai didi

ios - 无法从通知中心删除推送通知

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:31:06 26 4
gpt4 key购买 nike

[[UIApplication sharedApplication] cancelAllLocalNotifications];
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];'

我将上面的代码添加到 didfinishLaunchingWithOptions 但是当用户在他的通知中心点击通知并进入我的应用程序时,通知不会被清除。

编辑:

我还尝试将此添加到我的代码中:

You Also need to increment then decrement the badge in your application:didReceiveRemoteNotification: method if you are trying to clear the message from the message centre so that when a user enters you app from pressing a notification the message centre will also clear, ie:

[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 1];
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
[[UIApplication sharedApplication] cancelAllLocalNotifications];

如此处所述:iOS application: how to clear notifications?但是通知中心仍然不会清除通知

最佳答案

我刚刚在我的应用程序中手动添加了一个角标(Badge)编号并粘贴

- (void)applicationDidBecomeActive:(UIApplication *)application
{
application.applicationIconBadgeNumber = 0;
}

给我的 AppDelegate。对我来说,这就像一种魅力。请注意,didfinishLaunchingWithOptionsapplicationDidBecomeActive 与 Mouhammad Lamaa 解释的不同。如果您将其粘贴到您的 AppDelegate 并点击通知中心的通知,它应该会消失。如果不是,您的应用可能会在激活后创建一个新的通知?

关于ios - 无法从通知中心删除推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14580986/

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