【发布时间】:2020-04-29 20:25:51
【问题描述】:
我有一个使用地理定位的 ionic 3 应用程序。该应用程序在 Android 上运行良好,但我在 IOS 上有一个奇怪的行为。当我在 IOS 上运行应用程序时,它会正常启动,但在我暂停或关闭应用程序之前不会请求位置许可,从而导致应用程序无法正常运行。我的地理位置 id 包含在组件构造函数中的 platform.ready 函数中:
platform.ready().then(() => {
geolocation.getCurrentPosition().then(position => {
this.current_postion_lat = position.coords.latitude;
this.current_postion_long = position.coords.longitude;
console.log('Latitude: ' + position.coords.latitude + '\n' +
'Longitude: ' + position.coords.longitude + '\n' +
'Altitude: ' + position.coords.altitude + '\n' +
'Accuracy: ' + position.coords.accuracy + '\n' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' +
'Heading: ' + position.coords.heading + '\n' +
'Speed: ' + position.coords.speed + '\n' +
'Timestamp: ' + position.timestamp + '\n');
console.log("Got to Location Provider Constructor");
const watch = geolocation.watchPosition().subscribe(pos => {
this.current_postion_lat = pos.coords.latitude;
this.current_postion_long = pos.coords.longitude;
console.log('lat: ' + pos.coords.latitude + ', lon: ' + pos.coords.longitude);
});
});
});
我的离子信息:
@ionic/cli-utils:1.19.3 离子(离子 CLI):3.20.1
全局包:
cordova (Cordova CLI) : 8.0.0
本地包:
@ionic/app-scripts : 3.2.4
Cordova Platforms : android 8.0.0 browser 5.0.4 ios 5.1.1
Ionic Framework : ionic-angular 3.6.1
系统:
Android SDK Tools : 26.1.1
ios-sim : 8.0.2
Node : v10.16.3
npm : 4.1.2
OS : macOS
Xcode : Xcode 10.1 Build version 10B61
请帮忙。这使我无法释放。
【问题讨论】:
标签: ios ionic-framework ionic3 hybrid-mobile-app ionic-native