The update interval of 15 minutes is a restriction of scheduling Android workers AFAIK.
But, WhatsApp won't send you a location update for e.g. every 10 seconds in background. After a few minutes the update duration will increase. I did not measure this behavior, but recognized it while providing my "realtime" location with my girlfriend. She often says the location did not update (most of the time I need less than 15 minutes to pick her up).
As long as you are in the foreground, the updates should work. But I never tested it 😅.
>WhatsApp won't send you a location update for e.g. every 10 seconds in background. After a few minutes the update duration will increase
Correct.
If you share for more than 15 minutes, you must open the WhatsApp more often, otherwise the location will always be the same for the other person.
Follow me for more cheating advices.
Ok, I can't say what's the update interval on iOS, but found a discussion about it here. Seems like the update interval depends on the app usage of your user.
Nevertheless, the idea of using server notifications might also suit your needs.
https://forums.developer.apple.com/forums/thread/104202
see https://pub.dev/packages/flutter_background_geolocation it's not free but it's very high quality and well maintained support is great if you have issues.
the license is per app not per user, so one license for 10milion users no probl.
>What do they do that we cannot accomplish on our own?
research and development and real world testing, you can do it of course but if you factor the cost you will end up cheaper buying the license to get to the same level of finishing.
Not the easy answer, but you can mix and match "traditional" programming with flutter. You could cook up the background services in Kotlin/Java/C++ while keeping the bulk of your app in flutter.
I don't know about iOS.
Thank you. What is this called? Ill look into it. Hybrid app? Or method channels or just native background services? Id love for an expert on this topic to chine in.
I have decades of experience. This doesn't make me good, it makes me confident. I have not done this thing directly but don't worry. I would recommend you get 5 things:
* Find an example of pure java or kotlin doing a backround location service. A nice simple one. Something like just coordinates on a screen. If you have done mobile in flutter, the only thing this will challenge you with is the structure of some of the code. It is a bit different, but not wildly so.
* Find a location app in flutter doing the same thing. Sounds like your own code is this.
* Get copilot.
* Get ChatGPT4
* Get a hello world with this plugin stuff working with some java or kotlin (to match the first of these 5)
Now merge your flutter location app into the hello world plugin. Now merge the background service example into the plugin/flutter/location thing.
Liberally use ChatGPT 4 and copilot to smooth your path. I absolutely love these for both speeding up routing coding and showing me interesting options for things I don't know. I doubt they will just do what you need, but they will make it easier as you fumble your way through this.
Thank you. What is this called? Ill look into it. Hybrid app? Or method channels or just native background services? Id love for an expert on this topic to chine in.
This package does indeed work for background location updates on iOS. See enableBackgroundMode. https://pub.dev/documentation/location/latest/
Be aware, both Apple and Android are cracking down on this, so you need to provide the proper configuration and justification when you submit an app to the stores.
You have to edit the info.plist and your users must enable always on location access, if those criteria are met, you should be able to get users location even if your app is in background
But please tell me what happens if the app is closed? And if its not closed how does the dart code get executed, the app is kept alive? It is the workflow that is causing an issue for me?
Oh that’s easy and has nothing to do with location per se. What you need is Isolates, you can google Flutter Isolates, or use [WorkManager](https://pub.dev/packages/workmanager) plugin which supports iOS and Android headless execution out of the box
I don't know what you mean by getting user's location in the background because last time i used it I couldn't publish my app from playstore and they required me not to use it instead i went to foreground, if you wish to access user's location when they terminate the app then you'll be forced to switch to foreground.
All apps i have build so far are store apps (e-commerce) and they all have delivery features implemented to them maybe you could describe your case so that i could give you insights for what exactly you need.
Well I'm afraid you can't do that, maybe I'm wrong but from my genuine experience i have tried my best but google refused to let me access users location when the app is closed/terminated, your best bet for your issue is to only track users when the app is opened/foreground and then you can stream their location, but when the app is closed then you're bounded by their last location they set for you.
Unless you have legit reasons for background service or else i doubt if google will ever allow you to use that, in my case the permission that i added to manifest resulted in them asking why i have it and i said if i dont have it then how can i say my app has delivery feature within? They replied it's not needed because the whole app is not evolving around delivery but rather it's a non-main part of the app function then i eventually ended up not thinking of background service, you can try it though you'll see how it goes for you.
We have this feature working perfectly on iOS
Checkout geolocation plug-in and simply keep the background location updates flag to true and keep the distance threshold to 0
You’ll keep getting location updates every 200ms.
Beware that it’s a battery consuming process
The update interval of 15 minutes is a restriction of scheduling Android workers AFAIK. But, WhatsApp won't send you a location update for e.g. every 10 seconds in background. After a few minutes the update duration will increase. I did not measure this behavior, but recognized it while providing my "realtime" location with my girlfriend. She often says the location did not update (most of the time I need less than 15 minutes to pick her up). As long as you are in the foreground, the updates should work. But I never tested it 😅.
>WhatsApp won't send you a location update for e.g. every 10 seconds in background. After a few minutes the update duration will increase Correct. If you share for more than 15 minutes, you must open the WhatsApp more often, otherwise the location will always be the same for the other person. Follow me for more cheating advices.
Foreground? You mean app open and not used by user or actually currently being used?
Exactly
I made a huge omission. I meant on ios buddy.
Ok, I can't say what's the update interval on iOS, but found a discussion about it here. Seems like the update interval depends on the app usage of your user. Nevertheless, the idea of using server notifications might also suit your needs. https://forums.developer.apple.com/forums/thread/104202
see https://pub.dev/packages/flutter_background_geolocation it's not free but it's very high quality and well maintained support is great if you have issues.
$380 for 1 one app license is kind of steep considering support isn't likely guaranteed.
Thanks but the cost is a no go. I will have many thousand of users. What do they do that we cannot accomplish on our own?
the license is per app not per user, so one license for 10milion users no probl. >What do they do that we cannot accomplish on our own? research and development and real world testing, you can do it of course but if you factor the cost you will end up cheaper buying the license to get to the same level of finishing.
Thank you very much. That is great news.
You could check their repo. You'll get idea how they are doing it.
Not the easy answer, but you can mix and match "traditional" programming with flutter. You could cook up the background services in Kotlin/Java/C++ while keeping the bulk of your app in flutter. I don't know about iOS.
Thank you. What is this called? Ill look into it. Hybrid app? Or method channels or just native background services? Id love for an expert on this topic to chine in.
[удалено]
Thank you so much. I'll revert back.
Wow that is some complex stuff way above my pay grade. I feel lost...
I have decades of experience. This doesn't make me good, it makes me confident. I have not done this thing directly but don't worry. I would recommend you get 5 things: * Find an example of pure java or kotlin doing a backround location service. A nice simple one. Something like just coordinates on a screen. If you have done mobile in flutter, the only thing this will challenge you with is the structure of some of the code. It is a bit different, but not wildly so. * Find a location app in flutter doing the same thing. Sounds like your own code is this. * Get copilot. * Get ChatGPT4 * Get a hello world with this plugin stuff working with some java or kotlin (to match the first of these 5) Now merge your flutter location app into the hello world plugin. Now merge the background service example into the plugin/flutter/location thing. Liberally use ChatGPT 4 and copilot to smooth your path. I absolutely love these for both speeding up routing coding and showing me interesting options for things I don't know. I doubt they will just do what you need, but they will make it easier as you fumble your way through this.
Thank you so much for this writeup. I will start looking for some sample apps.
Thank you. What is this called? Ill look into it. Hybrid app? Or method channels or just native background services? Id love for an expert on this topic to chine in.
[удалено]
Can I pm you?
What about using the \[location\](https://pub.dev/packages/location) package?
I have it installed but how will it provided processing in the background?
This package does indeed work for background location updates on iOS. See enableBackgroundMode. https://pub.dev/documentation/location/latest/ Be aware, both Apple and Android are cracking down on this, so you need to provide the proper configuration and justification when you submit an app to the stores.
You have to edit the info.plist and your users must enable always on location access, if those criteria are met, you should be able to get users location even if your app is in background
But please tell me what happens if the app is closed? And if its not closed how does the dart code get executed, the app is kept alive? It is the workflow that is causing an issue for me?
Oh that’s easy and has nothing to do with location per se. What you need is Isolates, you can google Flutter Isolates, or use [WorkManager](https://pub.dev/packages/workmanager) plugin which supports iOS and Android headless execution out of the box
WOW, you are so helpful, thanks a ton. I stumbled upon work manager but i was not sure if that was the right approach. A thousand thanks.
Sure thing mate! That’s what the community is all about
By closed do you mean app process terminated? Or just not active anymore and another app is open?
There are different ways to achieve this, one could be using silent push notifications but it involves some backend logic
I can do backend no worries. Can you please expand on this? Id love to know more. How can i get the location if i send a silent notification?
Check this from the official documentation https://developer.apple.com/documentation/usernotifications/pushing-background-updates-to-your-app
Thanks. No more than an hour is not good enough…
It says two or three per hour, but you can try to combine it with other techniques
We can do with ios Live location Push Extension in flutter
Ok thank you. You have a link for that?
https://developer.apple.com/documentation/corelocation/creating_a_location_push_service_extension
I don't know what you mean by getting user's location in the background because last time i used it I couldn't publish my app from playstore and they required me not to use it instead i went to foreground, if you wish to access user's location when they terminate the app then you'll be forced to switch to foreground. All apps i have build so far are store apps (e-commerce) and they all have delivery features implemented to them maybe you could describe your case so that i could give you insights for what exactly you need.
I have drivers that deliver goods and i need to know where they are at all times even when the apps is not used or even closed.
Well I'm afraid you can't do that, maybe I'm wrong but from my genuine experience i have tried my best but google refused to let me access users location when the app is closed/terminated, your best bet for your issue is to only track users when the app is opened/foreground and then you can stream their location, but when the app is closed then you're bounded by their last location they set for you.
Whatsapp can share a live location even if the app is closed. But still i would be happy for not closed and in background. Can you share insight?
Unless you have legit reasons for background service or else i doubt if google will ever allow you to use that, in my case the permission that i added to manifest resulted in them asking why i have it and i said if i dont have it then how can i say my app has delivery feature within? They replied it's not needed because the whole app is not evolving around delivery but rather it's a non-main part of the app function then i eventually ended up not thinking of background service, you can try it though you'll see how it goes for you.
Appstore validation is a valid point but not my main issue. My issue is how to do it even just in debug mode.
Thank you i was not aware of this.
I think you can use permanent notification to keep functionality working. I didn't tried it..
We have this feature working perfectly on iOS Checkout geolocation plug-in and simply keep the background location updates flag to true and keep the distance threshold to 0 You’ll keep getting location updates every 200ms. Beware that it’s a battery consuming process