【发布时间】:2013-01-23 17:38:13
【问题描述】:
有没有办法让应用程序以编程方式知道它是否可以接收推送通知?
【问题讨论】:
标签: iphone ios notifications push-notification apple-push-notifications
有没有办法让应用程序以编程方式知道它是否可以接收推送通知?
【问题讨论】:
标签: iphone ios notifications push-notification apple-push-notifications
最初您需要尝试注册接收推送通知。
[[UIApplication sharedApplication]registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert)];
如果有可能你会收到成功的委托方法
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devTokenLocal
如果你不可能收到失败委托方法。请注意,您可以分析错误消息以获取更具体的信息
-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{}
【讨论】:
你可以使用
[[UIApplication sharedApplication] isRegisteredForRemoteNotifications]
【讨论】: