Skip to content

Instantly share code, notes, and snippets.

@villander
Forked from htulipe/cordova-device-ready.js
Created November 19, 2015 00:30
Show Gist options
  • Save villander/a3cf6e6396a7aedece95 to your computer and use it in GitHub Desktop.
Save villander/a3cf6e6396a7aedece95 to your computer and use it in GitHub Desktop.
Wait for Phonegap's deviceready event before initializing an Ember application
import isOnCordova from '../utils/is-on-cordova';
export function initialize(container, application) {
application.deferReadiness();
document.addEventListener('deviceready', function() {
application.advanceReadiness();
}, false);
if(!isOnCordova()){
document.dispatchEvent(new Event('deviceready'));
}
}
export default {
name: 'cordova-device-ready',
initialize: initialize
};
export default function isOnCordova() {
return !!window.cordova;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment