如何实现app的全局通知提醒设置?很简单,因为iOS系统就已经有一个快速的设置入口,系统的通知设置.
实现的主要步骤如下:
1> 获取app系统通知设置状态:
if (IOS8) {
int type = [[UIApplication sharedApplication] currentUserNotificationSettings].types;
NSLog(@"enabledRemoteNotificationTypes %d", type);
if (type == 0) {
self.isNoti = false;
} else {
self.isNoti = true;
}
} else {
int type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
NSLog(@"enabledRemoteNotificationTypes %d", type);
if (type == 0) {
self.isNoti = false;
} else {
self.isNoti = true;
}
}
2> 如何从自己的app跳转到对应系统的通知设置界面:
NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if([[UIApplication sharedApplication] canOpenURL:url]) {
NSURL*url =[NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
}
一个小的总结,希望能帮到大家!!!!
网友评论