目标C - 检测,如果用户更改应用程序的通知设置 [英] objective c - Detect when user change the app's notifications settings

查看:188
本文介绍了目标C - 检测,如果用户更改应用程序的通知设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要的总是知道用户的推送通知设置中选择的选项。结果
(选项为 - 警报,声音和徽章)

I need to always know which options the user choose on the push notification settings.
(The options are - alert, sound and badges)

所以,当我的应用程序启动我打电话:

So when my app launch I call:

UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];

和检测用户选择了什么。

and detect what the user chose.

但我怎么能当用户在应用续航时间以后更改设置检测?结果
有一些更改时发生这种设置,被调用的委托方法?

But how can I detect if the user change the settings later during the app life time?
Is there some delegate method that get called when a change occur with this settings?

推荐答案

有没有代表。您需要 enabledRemoteNotificationTypes 定期查询的UIApplication 属性,例如 applicationDidBecomeActive:

There is no delegate. You need to query the UIApplication property enabledRemoteNotificationTypes periodically, for example in applicationDidBecomeActive:.

有关详细信息,请检查这些问题的答案:

For details check these answers:

<一个href=\"http://stackoverflow.com/questions/1535403/determine-on-iphone-if-user-has-enabled-push-notifications\">Determine在iPhone上,如果用户启用了推送通知

<一个href=\"http://stackoverflow.com/questions/9276154/view-in-lock-screen-and-enabledremotenotificationtypes-ios5\">View在锁定屏幕和enabledRemoteNotificationTypes - iOS5的

编辑:结果
如果您需要重置推送通知设置和权​​限的警觉,看看在苹果技术注意TN2265 。在部分的重置推送通知警报的权限iOS上的的他们解释如何重置在iOS的设置。然而,许多开发商抱怨程序不起作用。不知道此链接将工作,你需要有机会获得苹果的论坛,但它是一个关于这个问题的确切线程。


If you need to reset the push notification setting and the permission alert, have a look at the Apple technical note TN2265. In section "Resetting the Push Notifications Permissions Alert on iOS" they explain how to reset the setting on iOS. However, many developers complain that the procedure doesn't work. Not sure if this link will work, you will need to have access to the Apple forum, but it is one of the threads about this exact issue.

我是我自己想知道,也许苹果已删除的权限对话框中的iOS 5.1。否则,为什么他们会要求应用程序显示警报?据 AppStore的审核准则

I was myself wondering if maybe Apple has removed the permission dialog in iOS 5.1. Otherwise why would they require the application to show the alert? According to AppStore review guidelines:

5.3的应用程序发送推送通知未征得用户同意,将被拒绝。

5.3 Apps that send Push Notifications without first obtaining user consent will be rejected

例如路径(应用程序)要求用户选择是否要在唱过程中间推送通知,而不是应用程序启动时的第一次。

For example Path (application) asks the user to opt-in for push notification in the middle of the sing-up process, not when the application starts for the first time.

不知道应该是什么提示的目的,反正作为应用程序无法查询该通知设置的状态。特别是,应用程序可以检查哪些通知类型(使用 enabledRemoteNotificationTypes )已启用,但不是如果为特定应用程序推送通知启用或禁用(通知中心ON / OFF开关在顶部)。至少这是iOS中5.1的行为。即使用户禁用该应用程序的通知,该应用程序还可以注册推送通知(使用 registerForRemoteNotificationTypes ),并将收到的APNS令牌。

Not sure what should be the purpose of the prompt anyway as the application can't query the state of the notification setting. In particular, the application can check which notification types (using enabledRemoteNotificationTypes) are enabled but NOT if push notifications for a particular application are enabled or disabled (the Notification Center ON/OFF switch at the top). At least that's the behavior in iOS 5.1. Even if user disables notifications for that application, the application can still register for push notifications (using registerForRemoteNotificationTypes) and WILL receive an APNS token.

这篇关于目标C - 检测,如果用户更改应用程序的通知设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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