For mobile autoupdate wait for both events to happen:

(deviceready, DOMContentLoaded)
Use the fixed cordova-update
This commit is contained in:
Slava Kim
2014-10-02 13:52:00 -07:00
parent f24904b66c
commit aa8eed5b44
2 changed files with 13 additions and 3 deletions

View File

@@ -68,5 +68,5 @@ Package.on_use(function(api) {
Cordova.depends({
'org.apache.cordova.device': '0.2.11',
'com.meteor.cordova-update': 'https://github.com/meteor/com.meteor.cordova-update/tarball/587af6eb67f8f3994309e17a90e8694b93ad47fe'
'com.meteor.cordova-update': 'https://github.com/meteor/com.meteor.cordova-update/tarball/31640d593ac99012cd7670295ebbec40ffa7f3f0'
});

View File

@@ -2,15 +2,25 @@ var queue = [];
var loaded = !Meteor.isCordova &&
(document.readyState === "loaded" || document.readyState == "complete");
var awaitingEventsCount = 1;
var ready = function() {
awaitingEventsCount--;
if (awaitingEventsCount > 0)
return;
loaded = true;
while (queue.length)
(queue.shift())();
};
if (document.addEventListener) {
var event = Meteor.isCordova ? 'deviceready' : 'DOMContentLoaded';
document.addEventListener(event, ready, false);
document.addEventListener('DOMContentLoaded', ready, false);
if (Meteor.isCordova) {
awaitingEventsCount++;
document.addEventListener('deviceready', ready, false);
}
window.addEventListener('load', ready, false);
} else {
document.attachEvent('onreadystatechange', function () {