how to activate the ios notification settings programmatically?

后端 未结 3 1373
梦如初夏
梦如初夏 2020-12-21 11:12

My app registers for the notifications like this :

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge | UIR         


        
3条回答
  •  失恋的感觉
    2020-12-21 11:46

    You can't. In iOS 5.0 there was a not documented feature to open the notification setting page (or any setting page) from your application via an url scheme. Then you could ask the user to enable the notifications. But it was removed in 5.1 and anyway probably would not be accepted by Apple.

    registerForRemoteNotificationTypes asks the user whether he wants to accept notifications from your application only the first time you call it. If later the user changes the notification settings then it will not ask it again any more. You can check whether notifications are enabled for your application with enabledRemoteNotificationTypes and warn the user yourself if you want, but user will have to go manually to the settings and re-enable them. You can't do it any more from your application.

    UPDATE as of iOS 8.0

    From iOS 8.0 Apple returned the possibility to open the System Settings page of your app:

    NSURL* settingsURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
    [[UIApplication sharedApplication] openURL:settingsURL];
    

提交回复
热议问题