I want to implement a custom screen that informs my users why I'm about to ask for push notification permissions. After they press a button in that custom screen I present the iOS push notification permission dialog with [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
I only want to show this custom screen once if the user hasn't already seen the push notification permission dialog. I cannot use [[UIApplication sharedApplication] enabledRemoteNotificationTypes] == UIRemoteNotificationTypeNone
as this will also return 'none' if the user decided to not allow push notifications.
Any ideas anyone?
Push notification alerts can be displayed in three locations on your phone—lock screen, banner, and notification center, when the app user opts-in for messages.
Go to Settings and tap Notifications. Select an app under Notification Style. Under Alerts, choose the alert style that you want. If you turn on Allow Notifications, choose when you want the notifications delivered — immediately or in the scheduled notification summary.
Push notifications are messages that pop up on a user's mobile phone or desktop device via their chosen web browser. These little banners slide into view — whether or not your app or website is open.
You could use NSUserDefaults :
#define kPushNotificationRequestAlreadySeen @"PushNotificationRequestAlreadySeen" if(![[NSUserDefaults standardUserDefaults] boolForKey:kPushNotificationRequestAlreadySeen]) { // Notify the user why you want to have push notifications UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:... delegate:self ...]; [alertView show]; [[NSUserDefaults standardUserDefaults] setBool:YES forKey:kPushNotificationRequestAlreadySeen]; } else { // Already allowed -> register without notifying the user [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound]; }
And
- (void)alertView:(UIAlertView*)alertView didDismissWithButtonIndex:(NSInteger)index { // Actually registering to push notifications [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound]; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With