phonegap / phonegap-template-react-hot-loader

PhoneGap Template using React, ES2015, Webpack, and hot module reloading
MIT License
79 stars 21 forks source link

Running in emulator doesn't include cordova.js #3

Closed jonbot closed 8 years ago

jonbot commented 8 years ago

First off — I'm really excited about this project. Exactly suits the needs of what I'm doing.

I ran into an issue that tripped me up for a couple of days. Running the command npm run ios opens up the iOS emulator, but the resulting app apparently does not have cordova.js functionality included.

So, if I did this in my index.js file, no alerts or logs showed up, since no onDeviceReady event fired:

var cordovaApp = {
    initialize: function() {
        this.bindEvents();
    },
    bindEvents: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
    },
   onDeviceReady: function() {
        alert('Device is ready.');
        console.log('Device is ready');
    }
};
cordovaApp.initialize();

Eventually, I built the app for production, following the instructions in the README. This seems to have packed cordova.js up the right way, since my alert and log now show.

devgeeks commented 8 years ago

Yeah, this is a known issue that I am trying to find a solution for.

See #1

jonbot commented 8 years ago

Wow. Apologies for totally spacing there. For some reason I read #1 as only applying to the browser platform. At this point, I get around all this by running node config; webpack; cordova run ios; No big deal there.