无法在 Urban Airship 中启用定位 YES
Unable to get Location Enabled YES in Urban Airship
我需要启动位置服务以根据位置向设备发送推送。我正在使用段来设置位置和时间,但我在日志中看到的是:
[UALocationService reportCurrentLocation] [Line 358] Location service not authorized or not enabled.
我的应用程序 info.plist 中确实有 NSLocationAlwaysUsageDescription
和 NSLocationWhenInUseUsageDescription
键。
我找不到导致位置未启用的问题。任何帮助将不胜感激。谢谢。
代码:
self.locationManager = [[CLLocationManager alloc] init];
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
[self.locationManager requestWhenInUseAuthorization];
}
[self.locationManager startUpdatingLocation];
[UALocationService locationServicesEnabled];
[UALocationService locationServiceAuthorized];
[UALocationService airshipLocationServiceEnabled];
UALocationService *locationService = [UAirship shared].locationService;
[locationService reportCurrentLocation];
[locationService startReportingSignificantLocationChanges];
经过查找,发现不需要自己添加CLLocationManager。
Instead make use of function
coreLocationWillPromptUserForPermissionToRun
like this:
[UALocationService coreLocationWillPromptUserForPermissionToRun];
以下是我们需要调用以启用服务的函数:
[UALocationService airshipLocationServiceEnabled];
[UALocationService setAirshipLocationServiceEnabled:YES];
[UALocationService locationServicesEnabled];
[UALocationService locationServiceAuthorized];
[UALocationService coreLocationWillPromptUserForPermissionToRun];
我需要启动位置服务以根据位置向设备发送推送。我正在使用段来设置位置和时间,但我在日志中看到的是:
[UALocationService reportCurrentLocation] [Line 358] Location service not authorized or not enabled.
我的应用程序 info.plist 中确实有 NSLocationAlwaysUsageDescription
和 NSLocationWhenInUseUsageDescription
键。
我找不到导致位置未启用的问题。任何帮助将不胜感激。谢谢。
代码:
self.locationManager = [[CLLocationManager alloc] init];
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
[self.locationManager requestWhenInUseAuthorization];
}
[self.locationManager startUpdatingLocation];
[UALocationService locationServicesEnabled];
[UALocationService locationServiceAuthorized];
[UALocationService airshipLocationServiceEnabled];
UALocationService *locationService = [UAirship shared].locationService;
[locationService reportCurrentLocation];
[locationService startReportingSignificantLocationChanges];
经过查找,发现不需要自己添加CLLocationManager。
Instead make use of function
coreLocationWillPromptUserForPermissionToRun
like this:
[UALocationService coreLocationWillPromptUserForPermissionToRun];
以下是我们需要调用以启用服务的函数:
[UALocationService airshipLocationServiceEnabled];
[UALocationService setAirshipLocationServiceEnabled:YES];
[UALocationService locationServicesEnabled];
[UALocationService locationServiceAuthorized];
[UALocationService coreLocationWillPromptUserForPermissionToRun];