react-native-background-geolocation
react-native-background-geolocation copied to clipboard
expo not works when the application is terminated
My Environment
- Plugin version: 4.11.3
- Platform: Android
- OS version:Android
- Device manufacturer / model: google pixel 6
- React Native version (
react-native -v): expo 48 - Plugin config
useEffect(() => {
BackgroundGeolocation.ready({
heartbeatInterval: 60,
debug: true,
stopOnTerminate: false, // <-- Allow the background-service to continue tracking when app terminated.
startOnBoot: true,
logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
notification: {
title: "The Notification Title",
text: "The Notification Text",
},
preventSuspend: true // <-- Required for iOS
});
const subscription = BackgroundGeolocation.onHeartbeat((event) => {
console.log("[onHeartbeat] ", event);
getLocationF()
// You could request a new location if you wish.
BackgroundGeolocation.getCurrentPosition({
samples: 1,
persist: true
}).then((location) => {
console.log("[getCurrentPosition] ", location);
});
})
}, []);
const getLocationF = async () => {
await Notifications.scheduleNotificationAsync({
content: {
title: "You've got mail! 📬",
body: 'Here is the notification body',
data: { data: 'goes here' },
},
trigger: { seconds: 2 },
});
}
Expected Behavior
Need To send me notification every minute when the app is killed.
Actual Behavior
Send me notification every minute but only when the app is on background or forground
Steps to Reproduce
- eas build --profile development
- install the apk on my device (google pixel)
- define battery to be unrestricted
- npx expo start --dev-client
Context
Debug logs
Logs
PASTE_YOUR_LOGS_HERE
Are you observing the plug-in logs in $ adb logcat? See wiki “Debugging”.
also see api docs Config.enableHeadless
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.