'How to listen for location for realtime in react native

I am working on a location tracking application, I am prompting an error message when users are off their location. Implemented functionality working but I face one problem when the user turns off location from the top menu of the mobile app it not working but when I close an app it worked ( it the bacause I am using react native app state to check app is foreground or in the background ). What I want to achieve when users are off their location I want to listen realtime when location off I want to prompt message direct.

Here is implemented functionality

const _handleAppStateChange = async (nextAppState) => {
    console.log("22 app", appState);
    if (
      appState.current.match(/inactive|background/) &&
      nextAppState === "active"
    ) {
      getCurrentUserLocation();
    }
    appState.current = nextAppState;
    setAppStateVisible(appState.current);
  };


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source