2

I'm currently working on a location based Cordova + Meteor (iOS) mobile-app, where I need to keep an eye on the user's location, even when the app is terminated.

For this I have tried to implement the cordova-background-geolocation-lt plugin, but I'm having issues: https://github.com/transistorsoft/cordova-background-geolocation-lt/issues/221

Because of this I am thinking of writing my own native (obj-c/swift) plugin (partly using code from this answer) that will get user's location and send it to the server.

My question is:

From this answer:

When iOS wants to return the location update to the app, it will help you to relaunch the app and return a key UIApplicationLaunchOptionsLocationKey to the app delegate method didFinishLaunchingWithOptions.

When app is killed/terminated/suspended - Is it possible to relaunch only part of the Cordova app - only native code that is responsible for background geolocation tracking and posting it to the server without fully relaunch the whole app - JS part & Meteor part?

Community
  • 1
  • 1
Edgar
  • 898
  • 2
  • 12
  • 36
  • There is no option to do this. Cordova apps are all or nothing. Don't worry about the memory footprint, that's what the operating system looks after – Mikkel Jan 04 '17 at 09:49
  • @Mikkel, that's bad.. You see, the Meteor-Cordova app is not relaunching after it was killed and `locationManager` receives `SignificantLocationChanges`. `SignificantLocationChanges` should auto relaunch the app, but with Cordova & Meteor stack the app isn't relaunching - something prevents it.. so I thought that it is somehow possible to abstract geolocation (native module) from the rest of the Cordova app... – Edgar Jan 04 '17 at 11:36

2 Answers2

1

There is an Apple article here about background tasks: https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html

Meteor generates the IOS code, but you can use XCode to modify the project and code somewhat, or I think you are correct in your approach to creating a plugin, because then you are in the native environment and can do these things.

Mikkel
  • 7,693
  • 3
  • 17
  • 31
1

I was able to succesfully use this plugin in my Meteor + Cordova project after resolving this issue: https://github.com/transistorsoft/cordova-background-geolocation-lt/issues/221 . It turned out that this issue was due to the Meteor's local server suspension after the app enters background state. It is specific to the Meteor-Cordova projects

Edgar
  • 898
  • 2
  • 12
  • 36