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

Background location tracking #516

Open
OSPFNeighbour opened this issue Jun 14, 2018 · 13 comments
Open

Background location tracking #516

OSPFNeighbour opened this issue Jun 14, 2018 · 13 comments

Comments

@OSPFNeighbour
Copy link
Contributor

So we currently cant location track if the app is in the background.

Before I waste hours of my time working on this only to have my hopes and dreams squashed by @sdunster does anyone have a plan on how they want this to work.

Options:

  1. custom native code
    Pros: Would work very well
    Cons: have to write and maintain custom native code for both ios and android

  2. jamesisaac-react-native-background-task
    Pros: react-native code library
    Cons: fastest you can run code is every 15 minutes

  3. transistorsoft/react-native-background-geolocation
    Pros: react-native code library, external support
    Cons: "android use requires a licence", $300 perpetual for 1 app. weirdly its MIT so not sure how they are working that licence fee when you could just fork it and remove the licence requirement.

  4. ...

@sdunster
Copy link
Member

This might be an option or useful for inspiration for the 1st option: https://github.com/mauron85/react-native-background-geolocation

@sdunster
Copy link
Member

I don't think 1 will be very hard on iOS - I'm sure I've seen react native APIs specifically for this but I'm not sure. I know this is a major buzzkill but I think we can start testing and warn people to leave the app open if they want tracking.

@sdunster
Copy link
Member

I'm pretty sure it just works™ on iOS, we don't need to do anything except ensure our app is enabled for background updates (pretty sure it already is). https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.html#//apple_ref/doc/uid/TP40009497-CH2-SW1

I'm sure there's more to it than that though so I will do some more reading.

@sdunster
Copy link
Member

Ok we probably need to make sure this has been set to true as well. These docs suck, Apple. https://developer.apple.com/documentation/corelocation/cllocationmanager/1620568-allowsbackgroundlocationupdates

@sdunster
Copy link
Member

we should probably set this too so people are aware that it is using your location/updating and it also provides an easy way for them to get back to it. During testing it will allow us to make sure we turn it off at the appropriate time (when reaching the geofence around HQ for example as well as a fallback timeout). https://developer.apple.com/documentation/corelocation/cllocationmanager/1620568-allowsbackgroundlocationupdates

@sdunster
Copy link
Member

Looks like all but the status bar in my last comment is implemented on iOS: https://github.com/facebook/react-native/blob/master/Libraries/Geolocation/RCTLocationObserver.m#L215

@OSPFNeighbour
Copy link
Contributor Author

its not only "leave it open" its leave it in the foreground and dont let the phone go to sleep.

@sdunster
Copy link
Member

@sdunster
Copy link
Member

Hunch: iOS might already work if the app is left in the foreground but the phone is locked anyway.

@OSPFNeighbour
Copy link
Contributor Author

we could use that mauron85/react-native-background-geolocation package and just let it post locations directly to the server and the server do some magic to find which event responses to update

@OSPFNeighbour
Copy link
Contributor Author

Hunch: I dont use ios

@sdunster
Copy link
Member

yeah longer term this is what I planned to do - we'll have a singleton location responder that activates whenever we're actively responding to an event so we're only ever submitting one location no matter how many things are running/happening etc.

@OSPFNeighbour
Copy link
Contributor Author

how far down the road might this happen. dont want to invest much time into something short time if you are realistically going to be coding this any time soon

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

No branches or pull requests

2 participants