4

enter image description here I have implemented push notification generation using the following methods.

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
    [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
    [[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}

the device token generated correctly normally. But when switch off the Sounds and Badge App Icon and set the alert style as none, (Settings -> App Name -> Notifications) the device token not generating. This issue only occur in iOS 8 devices. In iOS 7 devices it correctly working. Could any one give solution for this.

  • if u disable the notification how to get the device token bro – Anbu.Karthik Jan 28 '15 at 05:20
  • No the device token is enabled. Please see the image. –  Jan 28 '15 at 05:25
  • Well, does the error also occur when you use the methods to register in a distinct way? I might occur that the deprecated method obfuscates the registration process for the app. Please make sure (also if you want to support iOS7 and earlier) that the registers correctly:if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) – Lepidopteron Jan 28 '15 at 07:50
  • @Lepidopteron It correctly working when Sounds and Badge App Icon switches are on –  Jan 28 '15 at 10:08

1 Answers1

1

This is more a bug of iOS7. Notification has 3 way to be prompted to the user : Sounds / Badge / Alert. If you disable sounds and badge and if you set Alert style to None ( i.e. you disable alert ) there is no way to present the notification.

I think this is battery optimisation : if there is no way to notify the user, why registering him to remote notification ?

CZ54
  • 5,488
  • 1
  • 24
  • 39