bordeux
bordeux

Reputation: 622

Phonegap - access to api from external website

I set in config files:

<access origin="*" subdomains="true" />
<access origin=".*" subdomains="true" />
<content src="http://mydomain.pl/aps_mobile/" />

But on http://mydomain.pl/aps_mobile/ don't execute event "deviceready" and navigator.camera is undefined. What i doing wrong?

Upvotes: 2

Views: 2268

Answers (2)

user2365819
user2365819

Reputation: 31

You don't access to hardware resource if you execute the cordova script from a external host because the script is not mapped to libs/cordova.x.x.x.jar of Phonegap application. But you can resolve in this way:

in res/xml/config.xml

<access origin="*" />
<content src="index.html" />

in assets/www/index.html

<body>
    <script type="text/javascript" src="cordova-x.x.x.js"></script>
    <iframe name="framewrap" id="framewrap"
        style="border:0;position: absolute; top: 0; left: 0;width: 100%;"
        src="http://yourwebsite.pl">
    </iframe>
    <script type="text/javascript"> 
        document.getElementById("framewrap").contentWindow.navigator = navigator;
    </script>
 </body>

finaly, in camera configuration, you must set destinationType to 0 if you wanto DATA_URL, 1 if you want FILE_URI or 2 if you want NATIVE_URI.

I hope to help you

Upvotes: 3

Monica
Monica

Reputation: 311

Index file shouldn't be on server. You need yo have an index.html in your assets folder of the app, and make the connection to the server through jquery ajax calls. Also make sure you have imported cordova and phonegap javascript files in index.html

Upvotes: 1

Related Questions