TaskManager doesn't work on iOS standalone app
See original GitHub issue🐛 Bug Report
Summary of Issue
I made an app which uses the background location for geotracking of the user. I use the TaskManager to implement that approach. On Android, it works fine; on iOS, only works when I test the app in Expo Client (Custom), but in the standalone it doesn’t work very well. I even followed the steps that you give me in the following link to put the TaskManager running in iOS standalone apps: https://docs.expo.io/versions/latest/sdk/task-manager/.
Environment - output of expo diagnostics
& the platform(s) you’re targeting
Output of expo diagnostics
Expo CLI 3.22.0 environment info: System: OS: Windows 10 10.0.19041 Binaries: Node: 12.18.2 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 4.6.1 - C:\Program Files\nodejs\npm.CMD npmPackages: expo: ~36.0.0 => 36.0.2 react: ~16.9.0 => 16.9.0 react-dom: ~16.9.0 => 16.9.0 react-native: https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz => 0.61.4 react-native-web: ~0.11.7 => 0.11.7 react-navigation: ^4.3.1 => 4.4.0
Platforms that I’m targetting: Android and iOS
Reproducible Demo
bottom.jsx
// Executa-se as notiicações de geolocalização que correm em background TaskManager.defineTask(LOCATION_TASK_NAME, ({ data, error }) => { if (error) { // Error occurred - check
error.messagefor more details. Alert.alert('A geolocalização só funciona em smartphones.'); return; } if (data) { const { locations } = data; // do something with the locations captured in the background add(); console.log(counter); // if (counter % 2 != 0) { console.log('Aqui têm as vossas coordenadas!'); console.log(data.locations[0].coords.latitude); console.log(data.locations[0].coords.longitude); // Aqui, ao recolher as coordenadas, invoca cada função para fazer qualquer operação com elas notificacoesPerdidas(data.locations[0].coords.latitude, data.locations[0].coords.longitude); // mask(data.locations[0].coords.latitude, data.locations[0].coords.longitude); // } } });
await Location.startLocationUpdatesAsync(LOCATION_TASK_NAME, { accuracy: Location.Accuracy.High, distanceInterval: 10 });
app.json
{ "expo":{ ..., "ios": { "supportsTablet": true, "bundleIdentifier": "com.on.dica", "buildNumber": "4.1.2", "config": { "googleSignIn": { "reservedClientId": "com.googleusercontent.apps.712914569696-qe8gq455d7gi5b3hj79eit5eu02tu1g2" } }, "infoPlist": { "UIBackgroundModes": [ "location", "fetch" ] } }, ... } }
Steps to Reproduce
-
Include the following code in app.json:
{ "expo": { ... "ios": { ... "infoPlist": { ... "UIBackgroundModes": [ "location", "fetch" ] } } } }
-
Test the app in custom Expo Client for ios (it worked fine)
-
Run
expo build:ios
to build the iOS standalone app -
Test the standalone app in TestFlight
Expected Behavior vs Actual Behavior
Expected Behavior The app should give the local geolocation notifications, runned by TaskManager
Actual Behavior The app is not giving the notifications.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (4 by maintainers)
@thimo1 - make sure that you rebuild after setting that in app.json, it can’t be updated OTA
This issue has been automatically closed since there has not been any recent activity after it was marked as stale. Please open a new issue for any related bugs.