【发布时间】:2014-04-04 11:51:21
【问题描述】:
在我的 iOS 应用中,我使用 setInterval 获取当前位置,我能够获取当前位置。
我的问题是,即使我的应用在后台运行时也需要获取当前位置并保存到数据库中?
谁能指导我如何做到这一点?
我在 app.js 中的代码
Ti.App.addEventListener('pause', function(e) {
// register a background service. this JS will run when the app is backgrounded
//checking that switch is ON/OFF
if (Ti.App.Properties.getString('getLocation') == 'YES') {
//timer = setInterval(Titanium.Geolocation.addEventListener('location', locationCallBack1), 10000);
service = Ti.App.iOS.registerBackgroundService({
url : '/mainWindows/bg.js'
});
}
});
提前致谢。
【问题讨论】: