如果用户拒绝推送通知提示,则回调方法?

问题描述:

我的问题是我想显示初始推送通知提示的加载屏幕该应用想要向您发送推送通知。

My problem is I want to show a loading screen for the initial Push Notification Prompt "The app wants to send you push notifications."

因此,如果用户点击 yes 我可以继续使用随后调用的委托方法启动应用程序:

So if the user hits yes I can proceed and start the app in the then invoked delegate methods:

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
  [self hideLoadingScreen];
}

- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
  [self hideLoadingScreen];
}

但是如果用户点击没有,这些方法都没有被调用,这是有道理的。我的问题是,是否有一个不同的委托方法,如果他拒绝会被解雇?

However if the user hits no, none of these methods get called, which makes sense. My question is, is there a different delegate method that gets fired if he declines?

我的问题是如果没有被选中,加载屏幕永远不会消失。所以我需要知道用户何时完成选择。

My problem is if no is selected, the loading screens never disappear. So I somehow need to know when the user is done with the selection.

在iOS 7中,当系统的推送通知提示出现时,应用程序变为非活动状态,并且UIApplicationWillResignActiveNotification将触发。类似地,当用户响应提示时(按是或否),应用程序再次变为活动状态,并且UIApplicationDidBecomeActiveNotification将触发。

In iOS 7, when the system's push notification prompt appears, the app becomes inactive and UIApplicationWillResignActiveNotification fires. Similarly when the user responds to the prompt (pressing either Yes or No), the app becomes active again and UIApplicationDidBecomeActiveNotification fires.

因此,您可以收听此通知,然后隐藏你的加载屏幕。

So you can listen for this notification, and then hide your loading screen.

注意:显示提示时,主页按钮,通知中心和控制中心将被禁用,因此无法触发误报UIApplicationDidBecomeActiveNotification。但是,如果用户按下锁定按钮,则会触发UIApplicationDidBecomeActiveNotification。

Note: While the prompt is displayed, the Home button, Notification Center, and Control Center are disabled so they cannot trigger a false-positive UIApplicationDidBecomeActiveNotification. However if the user presses Lock button it will trigger UIApplicationDidBecomeActiveNotification.