|
地板
楼主 |
发表于 2017-4-28 17:31:09
|
只看该作者
** 警告⚠️ 该锁屏方法自2017-04月份开始被设定为私有API 调用后影响上线 报错“二进制文件不可用” 请谨慎使用 **
// 判断锁屏
#import <notify.h>
#define NotificationLock CFSTR("com.apple.springboard.lockcomplete")
#define NotificationChange CFSTR("com.apple.springboard.lockstate")
#define NotificationPwdUI CFSTR("com.apple.springboard.hasBlankedScreen")
- (BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)launchOptions {
// 锁屏的通知监听
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(),NULL, screenLockStateChanged,NotificationLock,NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(),NULL, screenLockStateChanged,NotificationChange,NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
return YES;
}
//设备是否锁屏
staticvoid screenLockStateChanged(CFNotificationCenterRef center,void* observer,CFStringRef name,const void* object,CFDictionaryRef userInfo){
NSString* lockstate = (__bridgeNSString*)name;
if ([lockstateisEqualToString__bridge NSString*)NotificationLock]) {
NSLog(@"锁屏");
}else{
NSLog(@"状态改变了");
}
}
anychat组件中是否有类似这些代码,监听手机锁屏? |
|