Ripple geolocation settings being ignored by Cordova application

旧巷老猫 提交于 2019-12-25 03:41:03

问题


I'm using Visual Studio 2013 Update 4 and I've installed the Visual Studio for Cordova add-on (version 0.3.22015.1).

I have created an Angular based app based on the Ionic SideMenu Starter Template for Cordova example. I have included the Cordova geolocation plugin in the config.xml file.

Within this example I am obtaining the device's location using the following code:

$scope.showPosition = function (position) {
 // ...
}

$scope.getLocation = function () {
 if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition($scope.showPosition, $scope.showError);
 }
 else {
  $scope.error = "Geolocation is not supported by this browser.";
 }
}

When this code is executed I'm expecting the position object passed to the showPosition callback to have the mock geolocation values specified in the Ripple emulator. However I don't get these mock values, I get my actual position.

How can I get my code to use the mock values?


回答1:


Unfortunately this was a bug with Ripple itself. The good news is a fix was just released on Wednesday. https://github.com/apache/incubator-ripple/blob/master/doc/CHANGELOG.md

You can patch Ripple in VS 2013 by opening the command command prompt and typing:

cd %appdata%\npm\node_modules\vs-mda
npm install ripple-emulator@0.9.29 --save

For VS 2015:

cd %appdata%\npm\node_modules\vs-tac
npm install ripple-emulator@0.9.29 --save

You will need to do this again if you clear the Cordova Cache.



来源:https://stackoverflow.com/questions/29859372/ripple-geolocation-settings-being-ignored-by-cordova-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!