How to trigger code/service if the app is terminated?


#1

I’m currently having difficulty trying to work out how to do the following…

The app needs to know the user’s location at all times even when the app is terminated. It is doing this to detect if the user is within the radius of a specific location. Running location services when the app is killed is fine; the difficulty is finding out how to check if the user is within the radius of a location and send the user a local notification. So, I’m not sure how to trigger a service that checks this, if the app is terminated?

I am currently using https://github.com/mauron85/cordova-plugin-background-geolocation to always run location services. I’m also using https://github.com/katzer/cordova-plugin-local-notifications to handle local notifications. These work fine if the apps are minimised or open; just not when terminated.

I didn’t think it was possible, but a colleague showed me an app (National Trust) that has this feature in.

Any help or advice would be appreciated.


#2

I have since found something that may be a solution to what I require:

You define locations using geofencing and the device pushes local notifications when the user is in proximity of them regardless of the app being open or not.

Hopefully it will provide what I need.