| #
3b6a24fb |
| 13-Dec-2018 |
Tomasz Sapeta <[email protected]> |
[ios][android][sdk][ncl] Background location, geofencing and background fetch (#2338)
# Why
Canny issues:
- https://expo.canny.io/feature-requests/p/background-tasks-support
- https://expo.cann
[ios][android][sdk][ncl] Background location, geofencing and background fetch (#2338)
# Why
Canny issues:
- https://expo.canny.io/feature-requests/p/background-tasks-support
- https://expo.canny.io/feature-requests/p/background-location-tracking
- https://expo.canny.io/feature-requests/p/geofencing-api
Related PR:
- https://github.com/expo/universe/pull/3201 (docs)
# How
The core of this PR is to implement TaskManager that provides an API to manage tasks, especially these that run while the app is in the background. I hope I documented this piece enough so I don't have to write it here again
This PR also adds three ways of how we can use background tasks:
- Background location updates
`Location.startLocationUpdatesAsync`, `Location.stopLocationUpdatesAsync`, `Location.hasStartedLocationUpdatesAsync`
- Geofencing
`Location.startGeofencingAsync`, `Location.stopGeofencingAsync`, `Location.hasStartedGeofencingAsync`
- Background fetch
`expo-background-fetch` module, *iOS only so far*
Also, to improve the quality of `expo-location`, I've deprecated `enableHighAccuracy` option and introduced a new one called `accuracy`. It allows to use all possible accuracies provided by iOS platform. Android has fewer options of accuracy, but I've made simple mapping (see https://github.com/expo/expo/pull/2338/files#diff-66bdbbc66d3410d9198aa17584b5409eR633).
All new modules and `expo-location` are now TypeScripted
# Test Plan
New APIs examples in `native-component-list`:
- `BackgroundFetch` - shows the status and the date of the last background fetch which can be manually triggered in Xcode (Debug -> Simulate background fetch).
- `Location` -> `Background location map` - it tracks your location by drawing a polyline.
- `Location` -> `Geofencing map` - this one will work better once we merge #2316, as it should show local notifications when the device enters/exits a region.
- `TaskManager` - shows all registered tasks for the experience.
There are also some quick tests in `test-suite` for the new methods in `Location` and `TaskManager` modules.
show more ...
|