Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release build is not receiving location updates in dart. #38

Closed
shahmirzali49 opened this issue May 31, 2022 · 35 comments
Closed

Release build is not receiving location updates in dart. #38

shahmirzali49 opened this issue May 31, 2022 · 35 comments

Comments

@shahmirzali49
Copy link

shahmirzali49 commented May 31, 2022

It's working when the app is in the foreground, but when I close the app, not updating.

by the way, I got the always permission. there is no problem with permissions

@vanlooverenkoen
Copy link
Contributor

can you provide us with the smalles example possible where it is not working?
Did you try the example project?

@shahmirzali49
Copy link
Author

background_example.zip

Yes, this is the example project. first I get LocationWhenInUse permission after Always, and then in the foreground is working. but when the app is killed not work.

thank you for replying and helping.

@shahmirzali49
Copy link
Author

shahmirzali49 commented May 31, 2022

@vanlooverenkoen I tried real device (iphone 8 ios 15.5) and used your example project codes. unfortunately I don't have logs. but say me If you need something and how , I can provide you.

@vanlooverenkoen
Copy link
Contributor

We created local notification to debug the background location tracking. That way you are 100% sure if it is working or not. Could you try that.

@vanlooverenkoen
Copy link
Contributor

vanlooverenkoen commented Sep 7, 2022

@Shahmirzali-Huseynov I have updated the example project in #40 . maybe you did not change the distance filter. (I forgot to change that as well, but after setting that to null I got updates every x seconds. while connected to my PC)

@shahmirzali49
Copy link
Author

@vanlooverenkoen you mean If I define distanceFilterMeters to null it will work?

@vanlooverenkoen
Copy link
Contributor

I am not sure how you are testing. But the distanceFilterMeters are set to 5. so If you don't move more than 5m you will not get any updates.

@shahmirzali49
Copy link
Author

I tried your #40 example project. this function didn't affect. is it working for you?

final result = await Permission.locationAlways.request();

@vanlooverenkoen
Copy link
Contributor

What do you mean by killed? Completely removed from the resent apps? Or just send to the background. Because if you force quit the app from recents apple will kill all services and background services linked to your app

@shahmirzali49
Copy link
Author

@vanlooverenkoen no generally, I run release #40 , on iPhone 8 real device, and just click the request location permission button, and nothing happens.

@vanlooverenkoen
Copy link
Contributor

Let me double check that today.

@vanlooverenkoen
Copy link
Contributor

I forgot to add:

        ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
        'PERMISSION_LOCATION=1',

The pr is updated

@shahmirzali49
Copy link
Author

shahmirzali49 commented Sep 8, 2022

@vanlooverenkoen Did you test example #40 in release run on real device IOS ? because when I run the app in debug mode location tracking is working (when the app is alive, not background or when is killed), but when I release run, location tracking not working even app isn't killed or on background/foreground. request permission working but tracking not working completely(run release).

@vanlooverenkoen
Copy link
Contributor

Hmm you could also run on simulator and select bikeride for example.
But in my case everything is working fine.
Did you set your permissions to always allow

@shahmirzali49
Copy link
Author

@vanlooverenkoen I mean in Release mode completely not working location tracking, even app is alive.

@shahmirzali49
Copy link
Author

Can you test release mode on Real device IOS? when it's possible

@shahmirzali49
Copy link
Author

@vanlooverenkoen I test also in the simulator. city run/biker too. but same when the app is killed it's not working

Screen.Recording.2022-09-08.at.15.10.05.mp4

@vanlooverenkoen
Copy link
Contributor

That is normal.

What do you mean by killed? Completely removed from the resent apps? Or just send to the background. Because if you force quit the app from recents apple will kill all services and background services linked to your app

Can you test by just closing the app but not killing the app. That should work normally.

@vanlooverenkoen
Copy link
Contributor

I will also test on a real device. Thanks already for your feedback!! Much appreciated!

@shahmirzali49
Copy link
Author

On the foreground/background, it's working. When the app is killed not work. but it's all in debug mode. In release mode completely nothing working unfortunately :/.

thank you for the package, your effort, and your support of the community.

@vanlooverenkoen
Copy link
Contributor

Alright yes. killed state that is to be expected. That is an OS limitation.

I will check the release mode later today or tomorrow.

@vanlooverenkoen
Copy link
Contributor

vanlooverenkoen commented Sep 8, 2022

Indeed I am not receiving anything in release. That is strange. Let me investigate.
Thing is we are using this (before #40) in production in 2 apps where it is work just fine. So that is strange.

@vanlooverenkoen
Copy link
Contributor

vanlooverenkoen commented Sep 8, 2022

When I go to the background I do see the blue pill in the status bar which indicates that the app is using location in the background.
I saw the blue pill for a second right after you killed the app. And then it disappeared. (as expected)

@shahmirzali49
Copy link
Author

Yes, location permission is working, but Tracking is not. I think Blue pill means the app has always location permission and be attention the app can track or track your location.

@vanlooverenkoen
Copy link
Contributor

vanlooverenkoen commented Sep 8, 2022

No blue pill actually means that is tracking in the background. Which it is doing. We are just doing something wrong when trying to contact the dart implementation

If you open your console. on mac you can see the extra logs to debug the native part.
image

@vanlooverenkoen
Copy link
Contributor

CustomLogger.log(message: "NOT YET INITIALIZED. Cache the location data")

You can see here what is happening. I will investigate this. And fix this major issue with #40 🙈

@shahmirzali49
Copy link
Author

Okay, thank you for your effort. I will wait :)

@vanlooverenkoen
Copy link
Contributor

vanlooverenkoen commented Sep 8, 2022

Runner	14:46:07.056512+0200	[VERBOSE-2:dart_isolate.cc(668)] Could not resolve main entrypoint function.
Runner	14:46:07.056672+0200	[VERBOSE-2:dart_isolate.cc(167)] Could not run the run main Dart entrypoint.
Runner	14:46:07.057252+0200	[VERBOSE-2:runtime_controller.cc(385)] Could not create root isolate.
Runner	14:46:07.057945+0200	[VERBOSE-2:shell.cc(604)] Could not launch engine with configuration.

Maybe it is the same issue as we had on Android: long instead of int. but we are already using a Int64 in swift

@vanlooverenkoen
Copy link
Contributor

Very weird that it does work ik debug on a real device. But not in release on a real device. 🤯

@shahmirzali49
Copy link
Author

yes exactly, 🥲😔

@vanlooverenkoen
Copy link
Contributor

I am getting the same error in release on Android. 🤯
It seems to be a flutter issue. because it is working perfectly in debug

@vanlooverenkoen
Copy link
Contributor

I think I found it!! There was a bug related to this. (flutter/flutter#91841 (comment))

I found that I had to add the @pramga('vm:entry-point') to make it work in release

@pragma('vm:entry-point')
void backgroundCallback() {
  BackgroundLocationTrackerManager.handleBackgroundUpdated(
    (data) async => Repo().update(data),
  );
}

@vanlooverenkoen
Copy link
Contributor

@Shahmirzali-Huseynov is it possible to test again?

@shahmirzali49
Copy link
Author

Yeah, after adding @pragma('vm:entry-point') it works. sorry for the delay. If you want, you can close the issue.

@vanlooverenkoen
Copy link
Contributor

I will be fixing the comments on my pull request. and after that, I will close it.

@vanlooverenkoen vanlooverenkoen pinned this issue Sep 12, 2022
@vanlooverenkoen vanlooverenkoen changed the title in IOS not working when app is killed Release build is not receiving location updates in dart. Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants