iOS用戶是否打開APP通知開關跳轉到系統的設置界面


1.檢測用戶是否打開推送通知

/**
 系統通知是否打開
 @return 是否打開
 */
//檢測通知是否打開iOS8以后有所變化 所以需要適配iOS7 
+ (BOOL)openThePushNotification{
    if (IOS8) {//IOS8寫的宏
        if ([[UIApplication sharedApplication] currentUserNotificationSettings].types  == UIUserNotificationTypeNone) {
//         未打開通知//這個是個自定義的alertView 當用戶沒有打開推送時  會彈出 可以替換成自己項目里面的彈框 
            openNotifiAlertView *alertView = [[openNotifiAlertView alloc] init];
            alertView.confirmClick = ^{
                if (IOS8) {//iOS8以后跳轉到設置界面的代碼也出現了變化 下面這段代碼是直接跳轉到APP的設置界面
                    //跳入當前App設置界面
                    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
                }else{
                    //適配iOS7 ,跳入系統設置界面
                    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:General&path=Reset"]];
                }            };
            [alertView show];
            
            return NO;
        }else{
            
            return YES;
        }
    }else{ // ios7
        if ([[UIApplication sharedApplication] enabledRemoteNotificationTypes]  == UIUserNotificationTypeNone) {
         
            openNotifiAlertView *alertView = [[openNotifiAlertView alloc] init];
            alertView.confirmClick = ^{
                if (IOS8) {
                    //跳入當前App設置界面
                    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
                }else{
                    //適配iOS7 ,跳入系統設置界面
                    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:General&path=Reset"]];
                }            };
            [alertView show];
            return NO;
        }else{
            
            return YES;
        }
    }

}

2.跳轉的其他的設置界面的字段

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=NOTIFICATIONS_ID"]];*

About — prefs:root=General&path=About
Accessibility — prefs:root=General&path=ACCESSIBILITY
AirplaneModeOn— prefs:root=AIRPLANE_MODE
Auto-Lock — prefs:root=General&path=AUTOLOCK
Brightness — prefs:root=Brightness
Bluetooth — prefs:root=General&path=Bluetooth
Date& Time — prefs:root=General&path=DATE_AND_TIME
FaceTime — prefs:root=FACETIME
General— prefs:root=General
Keyboard — prefs:root=General&path=Keyboard
iCloud — prefs:root=CASTLE iCloud
Storage & Backup — prefs:root=CASTLE&path=STORAGE_AND_BACKUP
International — prefs:root=General&path=INTERNATIONAL
Location Services — prefs:root=LOCATION_SERVICES
Music — prefs:root=MUSIC
Music Equalizer — prefs:root=MUSIC&path=EQ
Music VolumeLimit— prefs:root=MUSIC&path=VolumeLimit
Network — prefs:root=General&path=Network
Nike + iPod — prefs:root=NIKE_PLUS_IPOD
Notes — prefs:root=NOTES
Notification — prefs:root=NOTIFICATIONS_ID
Phone — prefs:root=Phone
Photos — prefs:root=Photos
Profile — prefs:root=General&path=ManagedConfigurationList
Reset — prefs:root=General&path=Reset
Safari — prefs:root=Safari Siri — prefs:root=General&path=Assistant
Sounds — prefs:root=Sounds
SoftwareUpdate— prefs:root=General&path=SOFTWARE_UPDATE_LINK
Store — prefs:root=STORE
Twitter — prefs:root=TWITTER
Usage — prefs:root=General&path=USAGE
VPN — prefs:root=General&path=Network/VPN
Wallpaper — prefs:root=Wallpaper
Wi-Fi — prefs:root=WIFI
Setting—prefs:root=INTERNET_TETHERING


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM