应用被kill事件监听

2023-10-30  本文已影响0人  冷暖自知灬
[[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(appEnterBackground)name:UIApplicationDidEnterBackgroundNotificationobject:nil];
[[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(applicationWillTerminate)name:UIApplicationWillTerminateNotificationobject:nil];

// - 事件处理
/** 程序进入后台的通知的事件监听 */
-(void)appEnterBackground
{
[[UIApplicationsharedApplication]beginBackgroundTaskWithExpirationHandler:nil];
}

/** 程序被杀死 */
-(void)applicationWillTerminate
{
// - 监听到 app 被杀死时候的回调....
}```
上一篇 下一篇

猜你喜欢

热点阅读