1
我正在使用Xamarin.Forms並創建一個具有後臺服務的iOS應用程序,以每10分鐘獲取一個位置。xamarin形成使用位置的權限iOS
代碼正在工作,我的問題是當我訪問iPad上的應用程序配置。 它顯示訪問攝像頭但不訪問當前位置的權限。
我認爲這將是一個問題,當我提交應用程序審查。
對於初始化位置:
this.locMgr = new CLLocationManager();
if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
{
locMgr.RequestAlwaysAuthorization(); // works in background
//locMgr.RequestWhenInUseAuthorization(); // only in foreground
}
爲了得到位置:
if (CLLocationManager.LocationServicesEnabled)
{
if (CLLocationManager.Status==CLAuthorizationStatus.Authorized
|| CLLocationManager.Status==CLAuthorizationStatus.AuthorizedAlways)
{
//set the desired accuracy, in meters
LocMgr.DesiredAccuracy = 1;
LocMgr.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) =>
{
_currentLocation = (e.Locations[e.Locations.Length - 1]);
};
LocMgr.AuthorizationChanged += (object sender, CLAuthorizationChangedEventArgs e) =>
{
if (e.Status == CLAuthorizationStatus.Denied
|| e.Status == CLAuthorizationStatus.Restricted)
{
LocMgr.StopUpdatingLocation();
_currentLocation = null;
}
};
LocMgr.StartUpdatingLocation();
}
}
有東西,我忘了嗎?
是否有您提出的特定問題或只是您認爲可能存在問題? –
這是一個特殊的問題。我看到在其他Xamarin項目中工作。 但我在我的項目中找不到任何不同的東西。 現在,我的工作很好。 –