参考了这位博主的文章:
http://www.jianshu.com/p/19602f48309b
//在应用活跃的时候判断系统设置中的通知是否打开
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
if (SYSTEM_VERSION < 8.0) {
if ([[UIApplication sharedApplication] enabledRemoteNotificationTypes] == UIRemoteNotificationTypeNone && !titleView) {
titleView = [[SFGlobalAlertView alloc] initWithMessage:@"检测到系统禁止了消息推送,这样会导致您无法及时收到消息" delegate:self type:GlobalAlertViewTypeDefault];
[titleView setLeftButtonTitle:@"立即设置" imageWithNormalImageName:nil
highlightImageName:nil];
[titleView setRightButtonTitle:@"不再提醒" imageWithNormalImageName:nil highlightImageName:nil];
titleView.tag = SFGlobalViewTagForNotiSetting;
[titleView show];
}
}else
{
UIUserNotificationType types = [[UIApplication sharedApplication] currentUserNotificationSettings].types;
if (types == UIUserNotificationTypeNone && !titleView) {
titleView = [[SFGlobalAlertView alloc] initWithMessage:@"检测到系统禁止了消息推送,这样会导致您无法及时收到消息" delegate:self type:GlobalAlertViewTypeDefault];
[titleView setLeftButtonTitle:@"立即设置" imageWithNormalImageName:nil
highlightImageName:nil];
[titleView setRightButtonTitle:@"不再提醒" imageWithNormalImageName:nil highlightImageName:nil];
[titleView show];
titleView.tag = SFGlobalViewTagForNotiSetting;
}
}
}
//如果没有打开,则进入设置
if(SYSTEM_VERSION < 8.0)
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=INTERNET_TETHERING"]];
}else
{
NSURL *url =[NSURL URLWithString:UIApplicationOpenSettingsURLString];
if([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}
}