reactjs
reactjs

Reputation: 124

Expo react native doesn't request location permission

I'm building an app that needs to track user's locations for app functionality. I'm requesting user's location using expo Location

useEffect(() => 
{
  (async ()=>{

   var {granted}=await Location. 
   requestForegroundPermissionsAsync() 
   // if granted do something

   })()
}, [])

The app asks for user's permission the first time, but if user selects "allow only this time" option,closes the app and reopens it, app doesn't ask the location permission again. How can I request permission again on app start if user previously user selected "only this time".

Upvotes: 0

Views: 566

Answers (1)

Akshay PandherPatte
Akshay PandherPatte

Reputation: 171

check the location permission first using this code in useEffect

 PermissionsAndroid.check(
      PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION
    );

Upvotes: 1

Related Questions