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)];}
新闻热点
疑难解答