如何 运行 ionic 中的后台线程?

How to run background thread in ionic?

我正在使用后台地理定位插件,但在使用时收到以下警告:

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

如何运行 ionic中的后台线程?

我在控制器中使用以下代码:

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);
    });
}

忽略每次加载插件时出现的错误。如果你想使用 BackgroundGeolocation。在 ngCordova 上有一个可用的插件。

在地理定位后台模式中启用 ios 运行 的正确方法是在 XCode 中将其打开。单击功能选项卡,然后单击背景模式。请务必选中“位置更新”框。