Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export const getUserLocation = (user) => async dispatch => {
- // asking user for permission to fetch thier current location
- let { status } = await Permissions.askAsync(Permissions.LOCATION);
- if(status !== 'granted'){
- dispatch({ type: USER_DENIED_ACCESS })
- }else {
- if(Platform.OS !== 'ios'){
- // if AndroiedLocation is GPS is closed open location form settings page
- const AndroiedLocation = await Location.getProviderStatusAsync();
- if(!testo.locationServicesEnabled){
- await IntentLauncherAndroid.startActivityAsync(
- IntentLauncherAndroid.ACTION_LOCATION_SOURCE_SETTINGS
- )
- }
- }
- let location = await Location.getCurrentPositionAsync({enableHighAccuracy: true})
- let locationArray = [ 37.4015, -122.104641]
- let uid = user.uid
- // saving loaction to database using geoFire
- const geoFireRef = await new GeoFire(firebase.database().ref('geoData'))
- geoFireRef.set(uid, locationArray)
- dispatch({ type: FETCHED_USER_LOCATION_SUCCESSFULLY, payload: location })
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement