Going Native: background execution of javascript just isn't 100%

I’ve been through many solutions to get the background geolocation to work. I eventually settled with BackgroundGeoLocation. In most use-cases, it has been working out. It fails whenever a network connection is disrupted or shifted (between cell and wifi). It works at first because the block of code being executed was placed when the app was still in foreground. As soon as it goes in the background, it will continue on with that previous run. When a connection is disrupted, the background process is forced to abandon and restart again–this time, it is unable to execute any javascript block. I hope I am wrong about this and that someone else out there has made this work.

Anyways, with the advent of Swift, at least I don’t get cross-eyed anymore. Objective-C syntax was unbearable. I will miss the richness, ease and flexibility of HTML/CSS for the UI. I’ll be using Ionic again when a project doesn’t involve any background execution of javascript. Good luck everyone!

2 Likes

I wish there was a way to do this smoothly with ionic!

How about creating a plugin for cordova to make the “background thing”.

In my efforts to try to make it work, I ended up learning native iOS enough to proceed building it in full native. I’m pretty happy with this decision since the performance and ease of debugging is much better. I’m sure ionic will continue to improve and I’ll surely use it again in the near future. Early-adoption has its costs.

Just to chime in here…

This isn’t specifically an issue with Ionic, but cordova apps in general.
Background execution of javascript code is a difficult thing, and there has been other attempts for different purposes.

While these attempts do have their limitations, there is room for improvements.
Remember, its open source, :wink: and patches are always welcomed.

Oh yeah, sorry about that. Thanks for the correction. This is a Cordova limitation–not specific to Ionic.

1 Like

Plugin author of cordova-background-geolocation. The plugin is designed to handle network disruptions. I test this by jumping into the subway – when I jump out on the other end, the plugin continues merrily along.

There is no Cordova limitation here – this is completely native iOS/Android code, the same geolocation code used in any native app.