icapps / flutter-background-location-tracker

Flutter background location tracker plugin. (Android / iOS)
MIT License
31 stars 30 forks source link

flutter-background-location-tracker service not working when screen is OFF for long run #44

Closed sharath-b-naik closed 1 year ago

sharath-b-naik commented 1 year ago

Hi, I'm using this plugin for track user's location in background. This works perfectly when screen is ON even app killed (removed from recent apps). But this stops working after couple of minutes when screen is OFF. i noticed after 10 minutes this stops working.

can you help me to solve this issue ?

ikbendewilliam commented 1 year ago

Hi, what OS are you experiencing this on? On Android there is a battery saving system that shuts apps down in the background to increase the battery life. You can disable this behavior for your app by asking for the battery saving permission. See this plugin for more info.

Is there a notification shown that the app is running in the background?

sharath-b-naik commented 1 year ago

Thank you. Issue solved by disabling battery optimisation.

harivyas07 commented 11 months ago

Hi for me unfortunately this solution is not working , OS android 12 , phone Samsung S10 , the background tracking works perfectly when the phone screen is not off and when I lock the screen the app works in background for only 2 mins and then I don’t receive any location updates . I tried to make the battery optimisation as unrestricted but still no luck

ikbendewilliam commented 11 months ago

@harivyas07 did you ask for the always permission? On Android you have to first ask for location permission and then the location always permission.

harivyas07 commented 11 months ago

Yes I did asked always permission but still no luck

On Sun, 24 Sep 2023 at 23:36, William Verhaeghe @.***> wrote:

@harivyas07 https://github.com/harivyas07 did you ask for the always permission? On Android you have to first ask for location permission and then the location always permission.

— Reply to this email directly, view it on GitHub https://github.com/icapps/flutter-background-location-tracker/issues/44#issuecomment-1732634292, or unsubscribe https://github.com/notifications/unsubscribe-auth/BBPGIQBWMAXNSXBM7ZAPVOTX4BZATANCNFSM6AAAAAAUMCYOLI . You are receiving this because you were mentioned.Message ID: @.*** com>

harivyas07 commented 11 months ago

@ikbendewilliam Anything you can help me with as the background functionality is not working when the phone screen is off ( stops working after 2 mins )

ikbendewilliam commented 11 months ago

@harivyas07 I don't immediately know. If you have permissions for battery saver and location always it should work fine in the background. Some things you can try: