如果在推送通知弹出窗口中单击“不允许”,回调方法是什么?

有一个推送通知弹出窗口出现在全新安装的应用程序上。 有两个选择,OK和Do not Allow(如果我没记错的话)。

如果点击“不允许”,我想知道回调方法是什么。 问题是,我实现了didFailToRegisterForRemoteNotifications,因为我认为如果单击“不允许”,它将直接进入AppDelegate中的该方法。 但是,该方法未被调用。

我的问题是,当用户点击“不允许”时,我需要知道该事件。 有没有办法做到这一点? 我很感激任何帮助。 谢谢。

但是从这里没有委托回调: 如果用户拒绝推送通知提示,则回调方法?

您可以在AppDelegate中使用BOOL变量进行检查,

AppDelegate.m // declare a BOOL BOOL allow = NO; - (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken { allow = YES; [self doWhatever]; } - (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error { allow = YES; [self doWhatever]; } 
 didFailToRegisterForRemoteNotifications 

当与苹果注册服务的通信失败时,没有办法知道用户只是点击了不允许,但是你可以查看UIApplication,有一种方法可以知道PushNotification注册的状态

 NSUInteger rntypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; if (rntypes == UIRemoteNotificationTypeNote) { // application is not registered for any type of push notification }