React native 使用sim网络在没有GPS或internet的情况下检测用户当前位置
我想得到用户的当前位置(只是在安卓)没有互联网和发送短信。我尝试在react native中使用以下代码:React native 使用sim网络在没有GPS或internet的情况下检测用户当前位置,react-native,gps,React Native,Gps,我想得到用户的当前位置(只是在安卓)没有互联网和发送短信。我尝试在react native中使用以下代码: navigator.geolocation.getCurrentPosition( (position) => { let initialPosition = JSON.stringify(position); console.log(initialPosition); }
navigator.geolocation.getCurrentPosition(
(position) => {
let initialPosition = JSON.stringify(position);
console.log(initialPosition);
},
(error) => console.log(JSON.stringify(error)),
{enableHighAccuracy: true, timeout: 15000, maximumAge: 2000 }
);
但是这个代码给了我这个错误:
error : 3 , Location request timed out
我在谷歌搜索,也搜索这个问题,并尝试了很多方法来解决它,比如:
enableHighAccuracy: false
或
删除选项参数
{enableHighAccuracy: true, timeout: 15000, maximumAge: 2000 }
或
删除maximumAge
以及当删除maximumAge
此工作时,但当删除它时
设备为我提供上次检测到的用户位置,该位置可能距离用户当前位置很远
也可以尝试使用这个库
对于最后一个解决方案和实现库示例代码:
但这段代码只适用于WIFI,并且当WIFI处于禁用状态时,请给我超时
错误
我的问题是:
在react native中,如果没有GPS或internet网络,我如何使用sim网络检测用户当前位置?react native支持许多android设备和SDK版本
有什么突破吗?