-
Notifications
You must be signed in to change notification settings - Fork 271
lockScreenCrash
pengbin edited this page Dec 6, 2016
·
12 revisions
正确集成金山SDK到自己的项目中,能成功实现预览和推流功能,在切换到后台(点击home、锁屏等),再切回来的时候,会偶现crash。
1.手动注册通知:
NSNotificationCenter *notiftication = [NSNotificationCenter defaultCenter];
2.添加对APP将要暂停运行事件的响应:
[notiftication addObserver:self
selector:@selector(enterBack:)
name:UIApplicationDidEnterBackgroundNotification
object:nil];
3.添加对APP重新开始运行事件的响应:
[notiftication addObserver:self
selector:@selector(becameActive:)
name:UIApplicationDidBecomeActiveNotification
object:nil];
4.APP将要暂停运行:
- (void) enterBack:(NSNotification *)not{
[_kit appEnterBackground:NO];
}
5.APP重新开始运行
- (void) becameActive:(NSNotification *)not{
[_kit appBecomeActive];
}
6.移除通知
- (void)viewDidDisappear:(BOOL)animated{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}