-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Labels
Description
Thoughts?
/**
* Plugin messages are not processed on Android until the next message.
* This is a workaround to manually check messages.
* http://stackoverflow.com/q/23352940/230462 and http://stackoverflow.com/a/24319063/230462
* @param enabled
*/
manuallyCheckMessages: function (enabled) {
if (!!this._checkMessageInterval === !!enabled) return;
if (enabled) {
this._checkMessageInterval = setInterval(function () {
cordova.exec(null, null, '', '', [])
}, 200);
} else {
clearInterval(this._checkMessageInterval);
this._checkMessageInterval = null;
}
},
/**
* If the response failed, retry the MeteorRider request when online.
*/
retryWhenOnline: function () {
var self = this;
// If there is a problem loading, retry loading when online.
document.addEventListener('MeteorRiderResponseError', function () {
// Retry init of MeteorRider when the app goes online
self._retryLoading = true;
self.manuallyCheckMessages(true);
});
document.addEventListener('online', function () {
if (!self._retryLoading) return;
self.manuallyCheckMessages(false);
self._retryLoading = false;
MeteorRider.request();
}, false);
}