Skip to content

[Feature] Throw LocationSignalLostException when GPS signal is lost #1617

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

orkun1675
Copy link

When the GPS signal is lost while listening for position updates we inform the listener using an exception called LocationSignalLostException. This allows listeners to be aware of position availability changes. The listener can catch and ignore this exception if it is not important to them. The listener knows the GPS signal is restored when they receive a new Position via the stream.

Fixes #1355.

Pre-launch Checklist

  • I made sure the project builds.
  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is does not need version changes.
  • I updated CHANGELOG.md to add a description of the change.
  • I updated/added relevant documentation (doc comments with ///).
  • I rebased onto main.
  • I added new tests to check the change I am making, or this PR does not need tests.
  • I made sure all existing and new tests are passing.
  • I ran dart format . and committed any changes.
  • I ran flutter analyze and fixed any errors.

@orkun1675
Copy link
Author

This feature requires changes in 4 plugins. I'm not sure how I can get the static analyzers to pass due to this inter-dependency. Any guidence would be appreciated.

Note that IIUC, once this PR is merged and updates to the 4 plugins are published to pub.dev the build errors will go away.

@orkun1675 orkun1675 changed the title Throw LocationSignalLostException when GPS signal is lost [Feature] Throw LocationSignalLostException when GPS signal is lost Dec 9, 2024
@TimHoogstrate
Copy link
Contributor

Dear @orkun1675,

Thanks for the contribution. Do you want to update this PR? I'm planning to pick it up and test how it works. I do however have a question regarding your PR. It looks like you throw the exception on Android and iOS when the location signal is lost.

on iOS: https://developer.apple.com/documentation/corelocation/clerror-swift.struct/code/locationunknown?language=objc
on Android: https://developers.google.com/android/reference/com/google/android/gms/location/LocationCallback#onLocationAvailability(com.google.android.gms.location.LocationAvailability)

Both seem to be able to recover from this state (when something changes).

But, it is not always because of the GPS location. The location could also be fetched from other sources right? If so, we should make a clear distinction between GPS and Location. Because a GPS location is always a location but a location is not always a GPS location.

Furthermore, regarding your question:

The approach would be the following: First we can use this PR for "ALL" changes required. Then we can test the changes and we could split the PR into different PR's for the separate packages (android, iOS and so on). Then we start releasing the packages first. After that we release the platform interface. And then the app facing package. If all packages are released we are done.

Kind regards,

@orkun1675
Copy link
Author

Hi @TimHoogstrate I tested this PR in production but the OS (especially iOS) does not behave as expected.

When my iPhone SE goes underground the location updates keep coming in for a few minutes and kCLErrorLocationUnknown is not immediately thrown. Furthermore, I've also observed that kCLErrorLocationUnknown is thrown sporadically when GPS is live & working.

We thus gave up on trying to differentiate between no GPS vs. no movement for iOS.

This change is still useful for the Android side, IIRC.

I unfortunately don't have the bandwidth to pick this back up right now, but it would make sense IMO, to merge it and add a disclaimer about unpredictable iOS behaviour.

@TimHoogstrate
Copy link
Contributor

@orkun1675,

Thanks for your reply, nice finding. Let's keep this PR open for now and maybe we can use it sometime later when we better understand what is happening at iOS devices.

Kind regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: A function that is called when GPS signal is lost.
2 participants