0
votes

I want to be able to register my application for push notifications but only when is active so I implement something like:

When application activates (applicationDidBecomeActive event):

[[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

When application gets inactivated (applicationWillResignActive event): [[UIApplication sharedApplication] unregisterForRemoteNotifications ];

My problem is that first time when the application gets installed, the application get's activated and registers for push notification, but when the IOS shows the push notification acceptance dialog, it also send applicationWillResignActive to my application so my unregister call is made.

The result is unexpected behavior: the application registers but without selected options for badge/alert, even if the user accepts.

Has anyone successfully implemented an app that is disabling push while application is in background?

Thanks

1

1 Answers

1
votes

Instead of unregistering inside applicationWillResignActive: try unregistering inside

– applicationDidEnterBackground:

Hope this helps!