【发布时间】:2019-07-01 09:43:18
【问题描述】:
为了获取 Android 设备中的当前位置,我使用了 Ionic 4 Geolocation 插件并按照文档中给出的步骤进行操作。在运行 Ionic CLI 命令 ionic cordova run android --l --c 时,它会启动应用程序并提示位置权限对话框。但它会引发类似getCurrentPosition() and watchPosition() are deprecated on insecure origins. To use this feature, you should consider switching your application to a secure origin.
{
PositionErrorcode: 1message: "Only secure origins are allowed ."__proto__: PositionError
home.page.ts:37Error getting location PositionError
}
另外,在阅读了论坛中的博客和帖子后,我只是使用了 cli 命令ionic cordova run android(无需重新加载)。在那种情况下,应用程序没有加载,因为源没有正确加载。
Failed to load resource: net::ERR_FILE_NOT_FOUND
file:///polyfills.js Failed to load resource: net::ERR_FILE_NOT_FOUND
file:///styles.js Failed to load resource: net::ERR_FILE_NOT_FOUND
file:///cordova.js Failed to load resource: net::ERR_FILE_NOT_FOUND
file:///vendor.js Failed to load resource: net::ERR_FILE_NOT_FOUND
file:///main.js Failed to load resource: net::ERR_FILE_NOT_FOUND
file:///assets/icon/favicon.png Failed to load resource: net::ERR_FILE_NOT_FOUND
我还尝试使用模拟器扩展控制在模拟器中设置 gps 位置。在真机上试过,也有这样的问题。
【问题讨论】:
标签: ionic-framework geolocation android-emulator ionic-native ionic4