如何以编程方式激活的ios通知设置? [英] how to activate the ios notification settings programmatically?

查看:231
本文介绍了如何以编程方式激活的ios通知设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

像这样的通知,我的应用程序寄存器:

My app registers for the notifications like this :

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert];

但如果我手动去通知设置,禁用一切(通知中心,警报,声音,徽章),然后卸载并重新安装该应用程序(或刚刚重装不卸载第一),我的iPhone保持原来的设置。我怎么可以强制重新激活这些设置回重新安装?

but if I manually go to the notifications settings, disable everything (notification center, alert, sound, badge) then uninstall and reinstall the app (or just reinstall without uninstalling first), my iPhone keeps the old settings. How can I force to reactivate these settings back on reinstallation?

推荐答案

您不能。在iOS中5.0有一个没有记录功能,通过一个URL方案,打开你的应用程序的通知设置页面(或任何设置页)。然后,你可以要求用户启用的通知。但它在5.1中删除,反正很可能不会被苹果所接受。

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 问他是否愿意接受你的申请的通知只的首次的调用它的用户。如果以后用户更改通知设置那么就不会再问下去了。您可以检查是否通知与 enabledRemoteNotificationTypes 您的应用程序启用和你自己向用户发出警告,如果你想要的,但用户必须手动去设置,并重新启用它们。您不能从您的应用程序做任何更多。

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.

更新内容的iOS 8.0

从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];

这篇关于如何以编程方式激活的ios通知设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆