good day;
I want to know how to put a hybrid application in the background on the IOS platform;
Since android is possible; My code is as follows;
function APP_IOS_BACKGROUND (){
document.addEventListener("deviceready", onDeviceReady, false);
var receivedElement;
function trackLocation(location) {
document.getElementById("status").innerText += 'BackgroundGeoLocation: ' + location.latitudue + "," + location.longitude + " ";
bgGeo.finish();
}
function failureFn(error) {
alert('BackgroundGeoLocation error');
alert('BackgroundGeoLocation error: ' + error);
}
function resumeApp() {
bgGeo.start();
}
var bgGeo;
function onDeviceReady() {
var id = "deviceready";
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
if (window.plugins.backgroundGeoLocation != undefined) {
bgGeo = window.plugins.backgroundGeoLocation;
configureBackgroundGeoLocation();
} else
alert("plugin undefined");
}
function configureBackgroundGeoLocation() {
window.navigator.geolocation.getCurrentPosition(function(location) {
alert('Location from Phonegap');
}, function(error) {
alert(error);
});
bgGeo.configure(trackLocation, failureFn, {
desiredAccuracy: 10,
stationaryRadius: 20,
distanceFilter: 30,
debug: true // <-- enable this hear sounds for background-geolocation life-cycle.
});
bgGeo.start();
document.addEventListener("resume", resumeApp, false);
}
}