floatinghotpot / cordova-httpd

Embed tiny web server into Cordova with a plugin
285 stars 148 forks source link

Cordova not available #57

Open ghost opened 7 years ago

ghost commented 7 years ago

the example code from the site leaves my browser saying "Run time Error" and in the browser console its telling me cordova is not available. How can i fix?

floatinghotpot commented 7 years ago

You cannot load the page in browser directly.

Instead, you need build it into a cordova hybrid app.

See what a cordova hybrid app is: https://en.wikipedia.org/wiki/Apache_Cordova

You can learn more on cordova homepage: http://cordova.apache.org/

ghost commented 7 years ago

should i be able to access the server from same phone when run on ionic view

floatinghotpot commented 7 years ago

No, I guess.

This plugin contains native code and javascript code. To use the full features, you will need to build the native code into your app, so the javascript code can call the native code via js-bridge.

But ionic view may not build cordova-http into it.

ghost commented 7 years ago

i tried these commands:

$ ionic cordova plugin add cordova-plugin-httpd
$ npm install --save @ionic-native/httpd

and all the other plugins seemed to work from the site, this must be a different story

floatinghotpot commented 7 years ago

Ok, this is right step to make the plugin working. You have to build it into an app (either android apk, or ios ipa package), then install into simulator or device.

floatinghotpot commented 7 years ago

The ionic view is only used to verify your HTML5 page layout and platform independent features. If some feature depends on native code, it cannot be verified in ionic view.

ghost commented 7 years ago

ok, i will try to build to android