Skip to content
This repository has been archived by the owner on May 13, 2021. It is now read-only.

How do I access Platform APIs from each platform

Dan Dascalescu edited this page Apr 26, 2017 · 3 revisions

This is a quick pointer, a more detailed entry is on the way

There is actually a different answer for each platform, and we're working on a more detailed walk through. We also have something in the works to try to automate this for the Cordova polyfills, since that is where the real challenge is:

  1. move the content from the www folder (after adding plugin) to your webserver

  2. reference the cordova.js file and the cordova_plugins.js file from your page

  3. Load appropriate cordova.js content for each platform. This is where it gets tricky if you are supporting both iOS and Android (BTW, we build a windows 10 cordova platform as well, if you want to handle them all together). The cordova.js file, which is required for the plugins to know where to load from (they use the path of this file). I'm playing with three different ways to solve this:

    • do some client detection on the server to serve the right version, pretty easy in Node.js
    • make the cordova.js file empty and then add the code back in a third js file called cordova_android.js and cordova_ios.js, for each platform appropriately
    • remove the code from cordova.js and replace with a client detection that then loads the appropriate version.

As you can see, it takes a little bit of work, but once this is done, you can do all your updates from the web server, and never need to deploy again (until you change domain usage :) )