Open ardatumay opened 3 years ago
+1
+1
+1
@androidfanatic
I was able to solve this using the more recently maintained drop in replacement for this package.
'react-native-geolocation-service'
hope this helps :D
@ioitiki I did the exact same thing after struggling for an hour! Cheers.
Link for the lazy: https://github.com/Agontuk/react-native-geolocation-service
If you don't want to change the library, you can check the permission using react-native-permissions
export const requestAuthorization = async (): Promise<boolean> => {
const permission =
Platform.OS === 'android'
? PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION
: PERMISSIONS.IOS.LOCATION_WHEN_IN_USE;
try {
const result = await check(permission);
if (result === RESULTS.GRANTED) {
return true;
} else if (result === RESULTS.DENIED || result === RESULTS.BLOCKED) {
const requestResult = await request(permission);
return requestResult === RESULTS.GRANTED;
} else {
return false;
}
} catch (err) {
console.warn(err);
return false;
}
};
Hello, When app is first installed and location permissions is not given by the user, calling getCurrentPosition first requests permission from user and then, without waiting result of user permission, returns the position. However, if user gives permission little bit late which is later than return of this method, this method returns error as current position. But user already give the permission. So I need to wait for user to finished her/his interaction with permission dialog. How to do this?
Another problem: When requestPermission method is called, it requests a permission but never returns the result of permission dialog when user presses one of the options. How to know whether user give the permission or not?
All questions is for ios.
Thanks for any suggestion.