if (OSVersion>=8.0) { CLLocationManager *clloc = [[CLLocationManager alloc] init]; [clloc requestAlwaysAuthorization]; }
除了以上的代碼,還需要在app的plist文件里面添加兩個屬性NSLocationAlwaysUsageDescription,NSLocationWhenInUseDescription。這兩個屬性的value你可以自定義也可以不填。
if(OSVersion>=8.0){//8.0以后使用這種方法來注冊推送通知 UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert categories:nil]; [[UIapplication sharedApplication] registerUserNotificationSettings:settings]; UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound; [[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes]; }else{ [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeBadge)];}
新聞熱點
疑難解答