在使用地理定位之前,我可以检查设备位置是打开还是关闭?
我想显示提醒消息,例如App需要运行您的位置,请在设备位置关闭时打开您的设备位置.
我想显示提醒消息,例如App需要运行您的位置,请在设备位置关闭时打开您的设备位置.
像示例 –
- componentDidMount() {
- // Check condition device location is open or close.
- if( DevicesLocation === 'close' ) {
- alert('App need to run your location,please open your devices location');
- // other process
- } else {
- navigator.geolocation.getCurrentPosition(
- (position) => {
- var initialPosition = JSON.stringify(position);
- this.setState({ initialPosition});
- },(error) => console.log(error.message)
- );
- }
- }
我想你可以用
- navigator.geolocation.getCurrentPosition(
- (position) => {
- //do stuff with location
- },(error) => {
- this.setState({locationEnabled: false}),},{enableHighAccuracy: true,timeout: 20000,maximumAge: 1000}
- );
要从您的应用程序打开设置,我认为您必须亲自使用本机代码:D