Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capture answer to "App would like to send you push notifications" alert

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.

like image 820
vtim Avatar asked Oct 23 '22 22:10

vtim


1 Answers

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");
}
like image 130
Nekto Avatar answered Oct 30 '22 02:10

Nekto