2017-12-20 33 views
1

이 문제와 관련된 모든 링크를 방문했지만 아무 도움도받지 못했습니다.Cordova Plugin Geolocation Timeout on IOS 11

IOS의 "cordova-plugin-geolocation"에서 "getCurrentLocation"메서드를 실행할 때 항상 오류 코드 3 (시간 초과)이 발생합니다.

내 코드를 따르

getCurrentPosition() { 
return new Promise(function (resolve, reject) { 
    document.addEventListener("deviceready", function(){ 
    navigator.geolocation.getCurrentPosition((position) => { 
     resolve(position); 
    }, (error) => { 
     reject(error); 
    }, { 
     timeout: 10000 
    }); 
    }, false); 
}); 
} 

나는 모든 플러그인 및 엔진을 업그레이드 오류가 지속되었다. 현재 사용중인 버전을 따르십시오 :

  • cordova 8.0.0;
  • cordova-ios 4.5.4;
  • cordova-android 7.0.0;
  • cordova-plugin-geolocation 4.0.0.
+0

maximumAge> 0을 이미 설정하려 했습니까? 앱을 시작한 직후에 기기가 새로운 위치를 얻을 수없는 환경에있을 수 있기 때문입니다. 내가 너라면 적어도 10 초의 구슬이 허용된다는 것을이 플러그인에 알려주기 위해 적어도 10000 (10 초)으로 설정할 것이다. – Blauharley

+0

예, 이미이 테스트를 수행했습니다. 그러나 여전히 같은 오류. IOS에서 권한 창이 나타나지 않고 위치 권한 설정에서 앱에 대한 정보가 표시되지 않습니다. –

답변

1

힘든 일을 마친 후 수정되었습니다. "/platform/ios/{project_name}/{project_name}-Info.plist"에 다음 키를 추가했습니다.

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key> 
<string>My app requires constant access to your location, even when the screen is off.</string> 
<key>NSLocationWhenInUseUsageDescription</key> 
<string>My app requires constant access to your location, even when the screen is off.</string>