iOS獲取通知狀態並跳轉設定介面設定
轉自:https://blog.csdn.net/timtian008/article/details/51887412?utm_source=copy
1、獲取使用者通知中心對程式訊息通知的設定,是否開啟訊息通知
if ([[UIDevice currentDevice].systemVersion floatValue]>=8.0f) { UIUserNotificationSettings *setting = [[UIApplication sharedApplication] currentUserNotificationSettings]; if (UIUserNotificationTypeNone == setting.types) { NSLog(@"推送關閉"); }else{ NSLog(@"推送開啟"); } }else{ UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; if(UIRemoteNotificationTypeNone == type){ NSLog(@"推送關閉"); }else{ NSLog(@"推送開啟"); } }
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
2、去設定
- 1
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
- 1
補充資料: 在iOS應用程式中開啟裝置設定介面及其中某指定的選項介面
[[UIApplicationsharedApplication] openURL:[NSURL URLWithString:@”prefs:root=General”]]; [[UIApplicationsharedApplication] openURL:[NSURL URLWithString:@”prefs:root=General&path=Restrictions”]];
一些其他可用的引數:
List of currently known URLs in the Settings app:
prefs:root=General&path=About //關於 prefs:root=General&path=ACCESSIBILITY//重力感應 prefs:root=AIRPLANE_MODE//飛航模式 prefs:root=General&path=AUTOLOCK//自動鎖定 prefs:root=General&path=USAGE/CELLULAR_USAGE//用量 prefs:root=Brightness//亮度調節 prefs:root=General&path=Bluetooth//藍芽 prefs:root=General&path=DATE_AND_TIME//時間和日期 prefs:root=FACETIME// prefs:root=General//通用 prefs:root=General&path=Keyboard//鍵盤 prefs:root=CASTLE// prefs:root=CASTLE&path=STORAGE_AND_BACKUP// prefs:root=General&path=INTERNATIONAL// prefs:root=LOCATION_SERVICES//定位 prefs:root=ACCOUNT_SETTINGS// prefs:root=MUSIC//音樂 prefs:root=MUSIC&path=EQ// prefs:root=MUSIC&path=VolumeLimit// prefs:root=General&path=Network//網路 prefs:root=NIKE_PLUS_IPOD// prefs:root=NOTES// prefs:root=NOTIFICATIONS_ID// prefs:root=Phone// prefs:root=Photos//相簿 prefs:root=General&path=ManagedConfigurationList// prefs:root=General&path=Reset// prefs:root=Sounds&path=Ringtone// prefs:root=Safari// prefs:root=General&path=Assistant// prefs:root=Sounds//聲音 prefs:root=General&path=SOFTWARE_UPDATE_LINK// prefs:root=STORE// prefs:root=TWITTER// prefs:root=General&path=USAGE// prefs:root=VIDEO//視訊 prefs:root=General&path=Network/VPN// prefs:root=Wallpaper//桌布 prefs:root=WIFI// prefs:root=INTERNET_TETHERING//