Giter Site home page Giter Site logo

Comments (9)

deadlyfingers avatar deadlyfingers commented on August 22, 2024

Ok, I have the page loading without an iframe (NB: the camera plugin won't fire as I had to use CDM to communicate from the iframe to Cordova) but I'm getting this error in the logs:

exeption nativeEvalAndFetch : ReferenceError: Can't find variable: cordova

So far I've tried location.href = "http://localhost:5000"; and location.replace("http://localhost:5000"); methods. Might try the window.open in _self method next...

Related posts:
http://stackoverflow.com/questions/22798792/load-external-page-on-to-cordova-phonegap-application
http://stackoverflow.com/questions/14818138/loading-remote-html-in-phonegap-or-cleaver-cordova-on-ios

from postcardapp.

vjrantal avatar vjrantal commented on August 22, 2024

I think I know what is going on here.. The index page has Cordova referenced with a relative link like this:

<script type="text/javascript" charset="utf-8" src="cordova.js"></script>

When you serve your the page from http://localhost:5000 that page should also have Cordova referenced. The issue here is that a simple relative link doesn't work anymore. You could host the right cordova.js file within the express app, but even that wouldn't solve the issue entirely due to the way Cordova downloads the other files it needs.

from postcardapp.

tongkolizer avatar tongkolizer commented on August 22, 2024

I've been trying this as a workaround but it seems like I can't get it to work.

#118

Now I have a problem with building again...

image

from postcardapp.

deadlyfingers avatar deadlyfingers commented on August 22, 2024

The exeption nativeEvalAndFetch : ReferenceError: Can't find variable: cordova error only seems to happen on iOS simulator.
Now the Postcard app works without an iframe, but side effect is losing Cordova.
It's proving difficult to load cordova.js from Express app ... Tried the following:

  1. location.href redirect
    The problem here is that the 'cordova.js' scripts are stored in the application bundle / assets dir and this dir (cordova.file.applicationDirectory) can't seem to be served by Express app.
    eg. Not allowed to load local resource: file:///android_asset/www/cordova.js
  2. window.open into _self (using cordova-plugin-inappbrowser)
    Related articles:
    http://www.telerik.com/blogs/cross-window-communication-with-cordova's-inappbrowser
    ^ No API for communication between windows, but there maybe a workaround...
  3. xhr to load express app into body, I believe this maintains access to cordova.js, but then the app's own scripts don't execute naturally.

from postcardapp.

deadlyfingers avatar deadlyfingers commented on August 22, 2024

This does work however -
4. Manually copy the cordova.js, cordova_plugins.js, plugins and cordova-js-src folder from the 'platforms' build dir into the Express app's public/ dir

The problem with this is getting the build script to hook in nicely - essentially you will need to build the first to get these files generated, the copy them into the public dir and issue a cordova build after that...

from postcardapp.

deadlyfingers avatar deadlyfingers commented on August 22, 2024

Another possible option -
5. Hosted web app plugin... While inappbrowser prevents access to cordova functions, there is a plugin for hosted webapps to allow use of cordova functions! https://github.com/manifoldjs/ManifoldCordova
cordova plugin add cordova-plugin-hostedwebapp --save
The only thing is we need to start url to be dynamic and this sounds like it uses a static manifest.json config with "start_url"...

from postcardapp.

deadlyfingers avatar deadlyfingers commented on August 22, 2024

Option 4 seems to work best for what we need - I have this working in a Cordova/JXCore POC using a gulp script with 'after_prepare' hook.

from postcardapp.

deadlyfingers avatar deadlyfingers commented on August 22, 2024

Final todo here is to rewire Camera to use normal Cordova function instead of using the iframe's Cross-domain Messaging method.

from postcardapp.

deadlyfingers avatar deadlyfingers commented on August 22, 2024

There is also a local websever plugin that might be worth looking at for this purpose but its for iOS only.
https://github.com/apache/cordova-plugins/tree/master/local-webserver

from postcardapp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.