Test user
Test user

Reputation: 459

How to run background thread in ionic?

I am using background geolocation plugin, while using that I am getting the below warning:

['Geolocation'] took '13.754150' ms. Plugin should use a background thread

How to run background thread in ionic?

I am using the below code inside my controller:

var myVar = setInterval(alertFunc, 60000);

function alertFunc() {
    console.log('int')
    var latitude,longitude;
    navigator.geolocation.getCurrentPosition(function(position) {
        latitude = position.coords.latitude;
        longitude = position.coords.longitude;
        console.log(latitude);
        console.log(longitude);
    }, function(error) {
        alert('Unable to get location: ' + error.message);
    });
}

Upvotes: 1

Views: 6110

Answers (2)

tjacks3
tjacks3

Reputation: 607

The correct way to enable the ios run in background modes for geolocation is to turn it on in XCode. Click on the capabilities tab then click on the background modes. Make sure you check the Location updates box.

Upvotes: 1

Karan Kumar
Karan Kumar

Reputation: 2665

Ignore that error, that comes up every time you load a plugin. And if you want to use BackgroundGeolocation. there is a plugin for it available at ngCordova.

Upvotes: 6

Related Questions