Closed vink1987 closed 6 years ago
I've tried your case and that worked for me as you can see on the gif bellow:
The code I used :
export default class App extends Component<{}> {
componentDidMount = () => {
this.onLocationEnable();
}
onLocationEnable = () => {
RNAndroidLocationEnabler.promptForEnableLocationIfNeeded({interval: 10000, fastInterval: 5000})
.then(data => {
alert(data);
}).catch(err => {
alert("Error " + err.message + ", Code : " + err.code);
});
}
}
Actually it's not working for the catch promise. If the user clicks OK, it enters in .then and shows the alert, but if I click on Cancel, nothing happens. Just try to write a console.log inside .catch(err=> {}) and you'll see that nothing shows up. Any idea about this?
Eu tive o mesmo problema =( , as vezes, mesmo quando o usuário pressionando no OK, o promisse cai no catch. =(
When the gps is turned off and we open the app, I call promptForEnableLocationIfNeeded method which asks the user to enable location with Ok and Cancel buttons. When user selects Ok or Cancel, the promise doesn't work in react-native code. Please update the code.