用户拒绝推送通知提示时的回调方法?

问题描述:

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

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

然而,如果用户点击no,这些方法都不会被调用,这是有道理的.我的问题是,如果他拒绝,是否有不同的委托方法会被解雇?

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?

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

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.