Srini
Srini

Reputation: 348

Accessing device features from external webpage using phonegap

I am having phonegap app for ios which contains one webview to load the external url..

From that external url i try to access the device features like device name, camera etc..

But the problem is, i copied the cordova.js file in webserver which containes the external url. In that url i add this things.

<script type="text/javascript" src="cordova-1.7.0.js"/>
<script type="text/javascript">
document.addEventListener('deviceready',onDeviceReady',false);
function onDeviceReady(){
}

Javascript is not executing the document.addEventListener line itself.. It does not understand the 'deviceready' event.. and i am unable access the device feautures.. Help me.. i am struck with these things for last 10 days..

Upvotes: 1

Views: 890

Answers (2)

Srini
Srini

Reputation: 348

Issue is resolved in below way.

  1. Before accessing the cordova plugin files, executed the javascript file in webview by using stringByEvaluatingJavascriptFromString method.

  2. If you access the native feauture from external server, instantiate the plugin and use the functions inside this

Upvotes: 0

Shyantanu
Shyantanu

Reputation: 681

/* enter code here */ function onBodyLoad()
            {       
                document.addEventListener("deviceready", onDeviceReady, false);
            }

Use This, Call the function on body load.

Upvotes: 2

Related Questions