My app is able to successfully register for push notifications but I would like to move the pop-up alert to a different area of the app
If I implement the same code from AppDelegate.m
to a different screen, Other.m
, of my app, it never registers:
-(void)buttonTapped {
// Register for Push Notifications
UIRemoteNotificationType notifyTypes = (UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeBadge);
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:notifyTypes];
}
#pragma mark - APNS Functions
-(void)application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken {
NSLog(@"didRegisterForRemoteNotifications - 1");
}
-(void)application:application didFailToRegisterForRemoteNotificationsWithError:error {
NSLog(@"didFailToRegisterForRemoteNotifications");
}
If I enable didRegisterForRemoteNotificationsWithDeviceToken
in my AppDelegate.m
, the AppDelegate.m
instance of the method gets called from my Other.m
, but that is not how I want this to work.
Any ideas or suggestions would be appreciated.
Yes, of course.
You can register wherever you want with using
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
but didRegisterForRemoteNotificationsWithDeviceToken:deviceToken is only available in AppDelegate
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