下面的代码近乎没什么逻辑,但运行10几分钟后,就被杀掉了是怎么回事儿?
手机:一加5
app.json里设置了:
“requiredBackgroundModes”:[“location”],
“permission”:{
“scope.userLocation”:{
“desc”“你的位置信息将用于 GPS信息获取”
}
}
wx.startLocationUpdateBackground({
success:function(res){
var dateline = Date.now();
dateline = util.formatTime(newDate(dateline));
var msg = dateline + ’ 开启持续定位,成功’
textContent.unshift(msg);
thisPage.setData({
textContent: textContent
});
wx.onLocationChange(function (res) {
var dateline = Date.now();
dateline = util.formatTime(newDate(dateline));
var msg = dateline+" 纬度:" + res.latitude + “\n经度:” + res.longitude + ‘,速度:’ + res.speed + ‘,高度:’ + res.altitude;
console.log(msg);
if (textContent.length >= 50) textContent.pop();
textContent.unshift(msg);
thisPage.setData({
textContent: textContent
});
})
},
fail: function (res){
var dateline = Date.now();
dateline = util.formatTime(newDate(dateline));
var msg = dateline + ’ 开启持续定位,失败’
textContent.unshift(msg);
thisPage.setData({
textContent: textContent
});
}
})
},