0

I am developing an app that requires push notifications. I would like to detect when it is enabled by the user and when it is not.

It is a simple thing on iOS8 :

UIApplication *application = [UIApplication sharedApplication];
BOOL enabled = application.isRegisteredForRemoteNotifications;

But how to do that on iOS7?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Cherif
  • 5,223
  • 8
  • 33
  • 54

1 Answers1

1

Simple, for pre iOS 8:

UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types == UIRemoteNotificationTypeNone) {
  // disabled
}
David Xu
  • 5,555
  • 3
  • 28
  • 50
  • I tried this in Swift with types None, Alert and Sound and the equalities are never verified in spite of the app being authorized for sound, alert and badge... Do you have an idea why ? – Cherif Apr 24 '15 at 20:42