applicationWillTerminate中的cancelAllLocalNotifications? [英] cancelAllLocalNotifications in applicationWillTerminate?

查看:121
本文介绍了applicationWillTerminate中的cancelAllLocalNotifications?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在我的应用程序终止时(通过操作系统或双击主页按钮并终止应用程序)取消AllLocalNotifications和setApplicationIconBadgeNumber为0。我只是将这两个调用添加到我的主应用代理代码中:

I want to cancelAllLocalNotifications and setApplicationIconBadgeNumber to 0 when my application is terminated (either by the OS or by double tapping the home button and killing the app). I simply added these two calls to my primary app delegate code:

-(void)applicationWillTerminate:(UIApplication *)application 
{
        [application cancelAllLocalNotifications];
        [application setApplicationIconBadgeNumber:0];
}

现有通知仍在运行且徽章编号是否仍然设置?

Existing notifications are still running and the badge number remains set?

推荐答案

applicationWillTerminate:在操作系统杀死你的应用时不会被调用。操作系统只会在不通知您的应用程序的情况下终止该过程。目前没有记录的方法来执行代码。

applicationWillTerminate: is not called by the OS when it kills your app. The OS just kills the process without notifying your app about it. There is no documented way to execute code at this moment.

这篇关于applicationWillTerminate中的cancelAllLocalNotifications?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆