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

Allow transforming or rejecting coordinates with a special transform #3

Merged
merged 1 commit into from
Aug 17, 2018

Conversation

danielgindi
Copy link
Contributor

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:

BackgroundGeolocationFacade.locationTransform = ^(MAURLocation * location) {
  location.latitude = @(location.latitude.doubleValue + 0.018);
  return location;
};

Note: The equivalent android PR is here: mauron85/background-geolocation-android#8

@mauron85
Copy link
Owner

Merged. Thank you!

mauron85 added a commit to mauron85/react-native-background-geolocation that referenced this pull request Aug 17, 2018
mauron85 pushed a commit to mauron85/react-native-background-geolocation that referenced this pull request Aug 17, 2018
@danielgindi danielgindi deleted the feature/location_transform branch August 20, 2018 08:19
mauron85 added a commit to mauron85/cordova-plugin-background-geolocation that referenced this pull request Aug 20, 2018
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.

2 participants