We have a mobile application which has been developed using Salesforce Mobile SDK 2.1 and Backbone.JS (Smartstore + smartsync) on iOS platform and we recently, move it to Salesforce Mobile SDK 3.0.
We en-counted some issues, specially with addEventListener event where it didn't work which works fine with SDK 2.1.
document.addEventListener("offline", function () {}
document.addEventListener("online", function () {}
But somehow, once we changed to window from document as below it triggers the listeners but both firing at the same time and when the application comes online it fires twice each
window.addEventListener("offline", function () {}
window.addEventListener("online", function () {}
Offline Tracker Code :
app.models.OfflineTracker = Backbone.Model.extend({
initialize: function () {
var that = this;
this.set("isOnline", navigator.onLine);
//start here
document.addEventListener("offline", function () {
debugLog("Received OFFLINE event");
that.set("isOnline", false);
app.router.navigate('#getUserLanguage', true);
}, false);
document.addEventListener("online", function () {
debugLog("Received ONLINE event");
that.set("isOnline", true);
app.router.navigate('#home', true);
}, false);
}
});
Is there any solution for this?