跳转到系统 App 设置
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
//开始
if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined) {
[self.locationManager requestWhenInUseAuthorization];
}
//结束
[self.locationManager startUpdatingLocation];
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
接受推送通知添加如下
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
<span style="white-space:pre"> </span>[[UIApplication sharedApplication] registerForRemoteNotifications]; //<span style="color:#ff0000;">或者使用"在 APPDelegate 中对应位置添加" 2选1</span>
} else {
//原来注册通知的代码
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}
在 APPDelegate 中对应位置添加
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
if (notificationSettings.types != UIUserNotificationTypeNone) {
[application registerForRemoteNotifications];
}
}