cancelAllLocalNotifications in applicationWillTerminate?

前端 未结 2 1432
温柔的废话
温柔的废话 2021-01-14 20:36

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 kil

相关标签:
2条回答
  • 2021-01-14 20:57

    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.

    0 讨论(0)
  • 2021-01-14 21:14

    You should use applicationWillResignActive: instead.

    Starting with iOS 4.0 applicationWillTerminate is not called for applications when they are killed in the background. Apps are put in the background when you hit the home button now or otherwise switch apps.

    0 讨论(0)
提交回复
热议问题