美文网首页
iOS中监听 app被杀死

iOS中监听 app被杀死

作者: SunshineBrother | 来源:发表于2021-03-15 13:57 被阅读0次
//  - 添加通知的监听
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appBecomeActive) name:kApplicationDidBecomeActive object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate) name:UIApplicationWillTerminateNotification object:nil];

// - 事件处理
/** 程序进入后台的通知的事件监听 */
-(void)appEnterBackground{
    [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:nil];
}
/** 程序被杀死 */
-(void)applicationWillTerminate{
    //  - 监听到 app 被杀死时候的回调....
}



相关文章

网友评论

      本文标题:iOS中监听 app被杀死

      本文链接:https://www.haomeiwen.com/subject/njjkcltx.html