Agontuk / react-native-geolocation-service

React native geolocation service for iOS and android
https://www.npmjs.com/package/react-native-geolocation-service
MIT License
1.6k stars 291 forks source link

Need to declare foreground service? #295

Closed ahron1 closed 2 years ago

ahron1 commented 3 years ago

As stated in the location permission docs,

The system considers your app to be using foreground location if a feature of your app accesses the device's current location in one of the following situations: An activity that belongs to your app is visible. Your app is running a foreground service. When a foreground service is running, the system raises user awareness by showing a persistent notification. Your app retains access when it's placed in the background, such as when the user presses the Home button on their device or turns their device's display off. Additionally, it's recommended that you declare a foreground service type of location, as shown in the following code snippet. On Android 10 (API level 29) and higher, you must declare this foreground service type.

You declare a need for foreground location when your app requests either the ACCESS_COARSE_LOCATION permission or the ACCESS_FINE_LOCATION permission, as shown in the following snippet:

On Android 10 (API level 29) and higher, you must declare this foreground service type.

So does this need to be done, as suggested in the docs, by adding something like

<service
    android:name="MyNavigationService"
    android:foregroundServiceType="location" ... >
    <!-- Any inner elements would go here. -->
</service>

?

pedrotrogo-fump commented 3 years ago

+1

Agontuk commented 2 years ago

yes, you can add it to your project if you want foreground service. You can follow the example project https://github.com/Agontuk/react-native-geolocation-service/blob/master/example/android/app/src/main/AndroidManifest.xml#L31