1 decade ago by failbot
Hi guys.
I'm trying to use Cordova/Phonegap together with ImpactJS. Everything seems to work fine if I use it with iOS/xcode/iPhone/iPad and the cordova framework for that; but I run into problems when trying to do the same thing for Android:
Apparenlty impact prevents cordova from being loaded properly - the 'deviceready' event, that gets fired when cordova is fully loaded[1], never gets fired. Additionally, none of the cordova framework functions are available - for example, I can't use notification to get an alert popup[2].
Keep in mind, that I only have this issue when loading both, impact and cordova at the same time, like so:
I've tried different things, changing the loading order, loading the frameworks only the other one was loaded (by injecting <script> into head).
At the moment, I'm using impactjs without the phonegap js functions, but it would be nice if I could use /some/ of the native functions that phones have to offer (vibrating, native notifications, storage, etc.).
Any kind of tips would be apprechiated.
[1] http://docs.phonegap.com/en/1.0.0/phonegap_events_events.md.html#deviceready
[2] http://docs.phonegap.com/en/1.0.0/phonegap_notification_notification.md.html#notification.alert
I'm trying to use Cordova/Phonegap together with ImpactJS. Everything seems to work fine if I use it with iOS/xcode/iPhone/iPad and the cordova framework for that; but I run into problems when trying to do the same thing for Android:
Apparenlty impact prevents cordova from being loaded properly - the 'deviceready' event, that gets fired when cordova is fully loaded[1], never gets fired. Additionally, none of the cordova framework functions are available - for example, I can't use notification to get an alert popup[2].
Keep in mind, that I only have this issue when loading both, impact and cordova at the same time, like so:
<script type="text/javascript" charset="utf-8" src="cordova-1.5.0.js"></script> <script type="text/javascript" charset="utf-8" src="lib/impact/impact.js"></script> ... <body onload="onLoad()"> ...
function onLoad() { document.addEventListener('deviceready', onReady, false); } /**** This never gets executed ****/ function onReady() { console.log("ready"); navigator.notification.alert("Let's go"); // code to start the game }
I've tried different things, changing the loading order, loading the frameworks only the other one was loaded (by injecting <script> into head).
At the moment, I'm using impactjs without the phonegap js functions, but it would be nice if I could use /some/ of the native functions that phones have to offer (vibrating, native notifications, storage, etc.).
Any kind of tips would be apprechiated.
[1] http://docs.phonegap.com/en/1.0.0/phonegap_events_events.md.html#deviceready
[2] http://docs.phonegap.com/en/1.0.0/phonegap_notification_notification.md.html#notification.alert