捕获答案"应用程序希望向您发送推送通知"警报

vti*_*tim 5 push-notification apple-push-notifications ios

第一次打电话registerForRemoteNotificationTypes:给你的UIApplication对象,a UIAlertView弹出说"[app]想要发送推送通知".

有没有办法知道何时点击"确定"或"不允许" AlertView

即使在用户做出决定之前application:didRegisterForRemoteNotificationsWithDeviceToken:,我的目前也会被调用AppDelegate.

我想问的原因是因为第一次启动,我要推一个ViewControllerNotification选择,但前提是用户表示,他们希望收到通知.

Nek*_*kto 3

您可以使用下一个方法UIApplication

返回应用程序接受的通知类型。

- (UIRemoteNotificationType)enabledRemoteNotificationTypes
Run Code Online (Sandbox Code Playgroud)

例如,

UIRemoteNotificationType status = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (status == UIRemoteNotificationTypeNone)
{
     NSLog(@"user is not subscribed to receive push notifications");
}
Run Code Online (Sandbox Code Playgroud)

  • 谢谢,但实际上我遇到的问题是,即使在您点击 AlertView 中的“不允许”或“确定”之前,也会调用“application:didRegisterForRemoteNotificationsWithDeviceToken:”。因此,此时“enabledRemoteNotificationTypes”始终为“UIRemoteNotificationNone”。我想当做出选择时我必须再次调用 `registerForRemoteNotificationTypes:` 。 (3认同)