简体   繁体   English

地理定位在iOS 8模拟器中不起作用

[英]Geolocation is not working in iOS 8 simulator

I have upgraded the geolocation plugin in cordova 3.5 to fix the issue in iOS 8 by following this post. 我已经升级了cordova 3.5中的geolocation插件,通过以下帖子解决了iOS 8中的问题。

http://shazronatadobe.wordpress.com/2014/09/18/cordova-ios-and-ios-8/ http://shazronatadobe.wordpress.com/2014/09/18/cordova-ios-and-ios-8/

After running the app in iOS8 simulator, I am getting the notification 'Allow "MyApp" to access your location while you use the app?' 在iOS8模拟器中运行应用程序后,我收到通知“允许”MyApp“在您使用应用程序时访问您的位置?” But it still shows the error locationManager::didFailWithError (null) after allowing the location service to use the app. 但在允许位置服务使用该应用程序后,它仍然显示错误locationManager::didFailWithError (null)。 I have tried to close the simulator and run it again and again. 我试图关闭模拟器并一次又一次地运行它。 Also it seems that location service is active ( Settings > Privacy > Location services > MyApp > While Using ) by checking the settings in the simulator. 此外,通过检查模拟器中的设置,似乎位置服务处于活动状态( 设置>隐私>位置服务> MyApp>使用时 )。 By running the same app in iOS 7 simulator is working fine and able to detect the lat/lng. 通过在iOS 7中运行相同的应用程序,模拟器工作正常并且能够检测到lat / lng。

FYI: I am using Xcode 6 to build the application. 仅供参考:我使用Xcode 6来构建应用程序。

Any help/suggestion will be helpful. 任何帮助/建议都会有所帮助。

it sounds strange but it really works at least on my Xcode 6 Project. 这听起来很奇怪,但它至少在我的Xcode 6项目中起作用。 Make also sure to add the required Keys to your Projectname-info.plist file (eg NSLocationWhenInUseUsageDescription -> as a Key) 还要确保将所需的密钥添加到Projectname-info.plist文件中(例如,NSLocationWhenInUseUsageDescription - >作为密钥)

Next check your scheme (Product -> Scheme -> Edit Scheme -> Allow Location Simulation) If you are using a gpx file you can also mark it as a default location. 接下来检查您的方案(产品 - >方案 - >编辑方案 - >允许位置模拟)如果您使用的是gpx文件,您也可以将其标记为默认位置。

Now you can start your simulator by pressing the run button (play symbol). 现在,您可以通过按下运行按钮(播放符号)来启动模拟器。 As soon as your application started you will get notified for the permission. 一旦您的应用程序启动,您将收到许可通知。

The final fix now is to go to iOS Simulator -> Debug -> Location and change the location by choosing one out of the list except the custom location. 现在最后的修复是转到iOS模拟器 - >调试 - >位置,并通过从列表中选择一个除自定义位置之外的位置来更改位置。 Wait a little and change it back to custom location if it didnt change back by itself. 等一下,如果它没有自行更改,请将其更改回自定义位置。

It worked for me, hope for you too regards Schreda 它对我有用,希望你也对Schreda表示敬意

在iOS模拟器 - >调试 - >位置,选择一个没问题,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM