我使用谷歌地图在我app.I已经在info.plist中应用程序不请求位置服务权限何时在安装时使用?
隐私设置此 - 位置在使用的时候使用情况说明
,并在我的代码(主屏幕),我检查这样太:
if (CLLocationManager.locationServicesEnabled())
{
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestAlwaysAuthorization()
locationManager.startUpdatingLocation()
} else{
let alertController = UIAlertController(title: "Oops !!" , message: "Location service seems to be disabled. Please enable from Settings -> Privacy ->LocationService.", preferredStyle: .Alert)
let defaultAction = UIAlertAction(title: "OK", style: .Default, handler: nil)
alertController.addAction(defaultAction)
self.presentViewController(alertController, animated: true, completion: nil)
}
但它在第一次安装应用程序时没有询问权限。任何帮助将appriciate。
你添加 <!DOCTYPE的plist PUBLIC “ - //苹果// DTD PLIST 1.0 // EN”“HTTP://! www.apple.com/DTDs/PropertyList-1.0.dtd“> 为了能够检测到您是否正在驾驶,我们需要访问您的位置。 在您的.plist文件中? –
只需在您的appdelegates.swift文件中设置此代码 –
@HimanshuMoradiya在AppDelagate中添加哪些代码? –