UILocalNotification, PushNotifications, Location updates are not working in IOS 8

With IOS 8 rolled out for iPhone and iPad devices, few months back and all of a sudden most app developers noticed that push notification was not working for their app, neither location updates are running. Most of the apps want user location so that they can offer content based upon user location, with IOS 8 all their features goes down. This post will explain you solution for the three problems

  • UILocalNotification
  • PushNotification
  • CLLocationManager

UILocalNotification

In IOS 8, developer will see warning in their Xcode console while using UILocalNotifications, and did not see their app listed in Settings too. To overcome or solve this problem implement below code

  if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){
        [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
    }

PushNotification

In IOS 8, when you install app on your device and if app uses push notification then a dialogue will be shown to user and also app called its delegate method didRegisterForRemoteNotificationsWithDeviceTocken, But in IOS 8 it never gets called, to let your app register for remote notifications or push notifications you must required device token. To solve this problem use below code

  if ([UIApplication instancesRespondToSelector:@selector(registerForRemoteNotifications)]){

     [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];

        [application registerForRemoteNotifications];
    }

CLLocationManager

In IOS 8, CLLocationManager required two extra steps to be followed by developers in order to get location updates
First add below key to your Info.plist, simply copy based below  key and value
Key: NSLocationAlwaysUsageDescription
Value:- You can put it empty (it’s of string type)
NSLocationAlwaysUsageDescription key in Info.plist
NSLocationAlwaysUsageDescription key in Info.plist
Secondly, you have to call two additional methods
#define IS_OS_8_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
 if(IS_OS_8_OR_LATER) {
        [locationManager requestAlwaysAuthorization];
        [locationManager requestWhenInUseAuthorization];
    }
Hope these little codes, help you. Thanks for reading this post 🙂