[英]NotificationCenter Widget Failed To Use CoreLocation
我正在編寫一個通知中心窗口小部件,它必須使用位置信息。 在普通的應用程序中,我使用CoreLocation,並且工作正常。 但是在我的窗口小部件中,我嘗試了locationServicesEnabled
但未使用回調函數, authorizationStatus
始終為kCLAuthorizationStatusNotDetermined
,並且授權設置未顯示在kCLAuthorizationStatusNotDetermined
> location service中 。 我已經將委托設置為該類。
該系統的雅虎天氣小工具可以自動定位和它使用CoreLocation太多,所以小部件都必須使用位置服務的能力。
為什么CoreLocation在我的小部件上不起作用?
更新時間:2012.10.24 15:52
我使用私人API
[CLLocationManager setAuthorizationStatus:YES
forBundle:[NSBundle bundleForClass:self.class]]
現在,授權設置將顯示在“設置”->“位置”服務中。 每次我打開通知中心時,它就會打開。 但authorizationStatus
仍然kCLAuthorizationStatusNotDetermined
並不會去的回調函數。
更新時間:2012.10.25 10:38
我將定位代碼更改為:
[CLLocationManager setDefaultEffectiveBundle:[NSBundle bundleForClass:self.class]];
[_locationManager startUpdatingLocation];
如果我關閉位置服務,它將跳至
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
如果我打開該服務,則無論我是否授權,都不會回電(兩者都
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
和
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
將不會被調用)。
順便說一句,當我打開/關閉服務時,
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
將被調用,但是當我更改authorizationStatus時不會被調用。
可能是因為WeeAppPlugin捆綁包不是有效的捆綁包,導致小部件無法使用位置服務。 在[[CLLocationManager alloc] initWithEffectiveBundle:[NSBundle bundleForClass:self.class]]
私有API中使用[[CLLocationManager alloc] initWithEffectiveBundle:[NSBundle bundleForClass:self.class]]
后,小部件可以正常獲取位置信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.