Capture answer to “App would like to send you push notifications” alert

橙三吉。 提交于 2019-12-05 00:42:43

问题


The first time you call registerForRemoteNotificationTypes: on your UIApplication object, a UIAlertView pops up saying "[app] would like to send you push notifications".

Is there any way to know when "OK" or "Don't allow" is tapped in this AlertView?

Currently application:didRegisterForRemoteNotificationsWithDeviceToken: is called on my AppDelegate, even before a user makes a decision.

The reason I ask is because on first launch, I want to push a ViewController with Notification options, but only if the user indicated that they want to receive notifications.


回答1:


You can use next method of UIApplication:

Returns the types of notifications the application accepts.

- (UIRemoteNotificationType)enabledRemoteNotificationTypes

For example,

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


来源:https://stackoverflow.com/questions/7672090/capture-answer-to-app-would-like-to-send-you-push-notifications-alert

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!