Demo app doesn't record/track location when app is suspended
See original GitHub issueWhich platform(s) does your issue occur on?
- Android
- Android versions 8/9
- Samsung Galaxy S7 device and Google Pixel 3 API 29 Emulator
Please, provide the following version numbers that your issue occurs with:
- CLI: 6.0.2
- Cross-platform modules: 6.1.1
- Runtime(s): (look for the
"tns-android"
and"tns-ios"
properties in thepackage.json
file of your project) - Plugin(s):
“nativescript”: { “id”: “org.nativescript.demo”, “tns-ios”: { “version”: “6.1.0” }, “tns-android”: { “version”: “6.0.2” } }, “dependencies”: { “nativescript-geolocation”: “…/src”, “nativescript-theme-core”: “^1.0.4”, “nativescript-toast”: “~2.0.0”, “nativescript-unit-test-runner”: “0.7.0”, “tns-core-modules”: “^6.0.0” }, “devDependencies”: { “jasmine-core”: “^2.5.2”, “karma”: “4.1.0”, “karma-jasmine”: “2.0.1”, “karma-nativescript-launcher”: “^0.4.0”, “nativescript-css-loader”: “~0.26.0”, “nativescript-dev-webpack”: “^1.0.0”, “tns-platform-declarations”: “^6.0.0”, “tslint”: “~5.11.0”, “karma-webpack”: “3.0.5”, “typescript”: “~3.4.5” },
Please, tell us how to recreate the issue in as much detail as possible.
Run the demo app and start background thread monitoring. Then press home (suspend the app) and change location. Location is only recorded when you re-enter the app.
I assume this is supposed to run location tracking in the background i.e. when the app is suspended. If so I cannot get this to work on both the emulator and device provided above. Location services stops running.
Is the demo app supporting background location tracking? If not how would this be achieved in Nativescript Angular on Android?
Is there any code involved?
Demo app of this repo
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5
@Basler182 and anyone else who checks this out. I have found a solution based around using a foreground service. It is based on this NativeScript/NativeScript#6994
This issue has been solved but also contained a demo project. I have updated that demo project to NS6.
There was also a fix needed for the
webpack.config.js
file I added this below based on this answer: https://stackoverflow.com/a/57757216Before: const appComponents = [ “tns-core-modules/ui/frame”, “tns-core-modules/ui/frame/activity”, ];
After: const appComponents = [ “tns-core-modules/ui/frame”, “tns-core-modules/ui/frame/activity”, resolve(__dirname, “./src/foreground-service.android”) ];
Here is the updated demo project: ns6-updated-foreground-service.zip
@snackmaster95 Hi, unfortunately I don’t personally have any VueJS experience so I won’t be able to help specifically there.
However this solution only adds javascript/typescript to the project, so as far as I know there shouldn’t need to be anything Vue specific? The files that are changed are
webpack.config.js
,androidManifest.xml
,app.component.ts
(or the root of your app),references.d.ts
(if you don’t have this just add it) and then theforeground-service.android.ts
. If I’m correct this can all be translated into VueJS compatible files, but like I said my experience is limited?The “date second” console log is located in the
items.component.ts
file