Allow transforming or rejecting coordinates with a special transform #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
A concern was raised by users, where they do not want coordinates to be transmitted from their home address.
It's a common privacy issue.
Our idea was to let them set a "reverse fence" around their home. Where all coordinates transmitted within a certain radius - will be offset by around 1km.
Implementation
In order to achieve the desired result, we have to intervene even when the app is in the background, or as a service. At this stage some user mode code like React Native's JS will not have been executed yet.
I came up with a "transform", where all coordinates pass through. You can modify them or return a new one. Or you can reject them by returning null.
Due to the fact that the Facade is in most cases not owned by the developer - for example in RN situation where it is owned by the RCT module, and that module is also owned by RN, we have to access the modules statically.
So static setters have been written for the Facade.
As I believe in separation of concerns, I left the issue of "how to filter", or in RN's situation "how to share settings with the transformer" to the user, to handle with a separate technique/library.
Usage
In
didFinishLaunch
delegate method, write some code like this:Note: The equivalent android PR is here: mauron85/background-geolocation-android#8