您的位置:首页 > 移动开发 > IOS开发

iOS推送开关

2016-03-04 13:09 507 查看
//这里使用了UISwitch来获取推送的状态
[self.isSoundSend addTarget:self action:@selector(isSoundSendAction:) forControlEvents:UIControlEventValueChanged];
[self.isMessageSend addTarget:self action:@selector(isMessageSendAction:) forControlEvents:UIControlEventValueChanged];

BOOL isNotifyAlert = NO, isNotifySound = NO;
float iphoneVersion = [[[UIDevice currentDevice] systemVersion] intValue];//获取iphone的iOS systemVersion
if (iphoneVersion >= 8) {
UIUserNotificationType types = [[UIApplication sharedApplication] currentUserNotificationSettings].types;
isNotifyAlert = (types & UIUserNotificationTypeAlert) == UIUserNotificationTypeAlert;
isNotifySound = (types & UIUserNotificationTypeSound) == UIUserNotificationTypeSound;
} else {
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
isNotifyAlert = (types & UIRemoteNotificationTypeAlert) == UIRemoteNotificationTypeAlert;
isNotifySound = (types & UIRemoteNotificationTypeSound) == UIRemoteNotificationTypeSound;
}
self.isSoundSend.on = isNotifySound;
self.isMessageSend.on = isNotifyAlert;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: