Cannot get cordova-plugin-device to work


hello everyone!

 

i pretty new phonegap , since couldn't find solution via google nor in forum, decided start new topic.

 

i use phonegap build create mobile app. besides css have 2 files in root directory: index.html , config.xml.

 

index.html

<!doctype html> <html lang="en">   <head>   <title>test</title>   <meta charset="utf-8" />   <meta http-equiv="x-ua-compatible" content="ie=edge,chrome=1">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <link rel="stylesheet" type="text/css" href="css/style.css" />   <link rel="stylesheet" type="text/css" href="css/font-awesome.css" />   <link rel='stylesheet' type='text/css' href='http://fonts.googleapis.com/css?family=open+sans+condensed:700,300' />   <script src="cordova.js"></script>   <script type="text/javascript">     document.addeventlistener("deviceready", ondeviceready, false);          function ondeviceready() {       var vinfo =  'device name: ' + device.name + '\n' +         'device cordova: ' + device.cordova + '\n' +         'device platform: ' + device.platform + '\n' +         'device uuid: ' + device.uuid + '\n' +         'device version: '+ device.version;        alert(vinfo);     }   </script>   </head>   <body>     <div class="container">       <section class="main">         <button onclick="window.plugins.toast.showshortbottom('hello world!', function(a){console.log('toast success: ' + a)}, function(b){alert('toast error: ' + b)})">show toast</button>         <button onclick="alert('device name: ' + device.name)">show device cordova</button>       </section>      </div>   </body> </html> 

 

config.xml

<widget xmlns   = "http://www.w3.org/ns/widgets"   xmlns:gap   = "http://phonegap.com/ns/1.0"   id="de.sample.app" version="0.0.1">      <plugin name="cordova-plugin-device" spec="1.1.2" source="npm" />   <plugin name="cordova-plugin-dialogs" spec="1.2.1" source="npm" />   <plugin name="cordova-plugin-x-toast" source="npm" />   <preference name='phonegap-version' value='cli-6.3.0' />   <name>sample app</name>   <description>     sample app.   </description>   <content src="index.html" />   <access origin="*" /> </widget> 

the problem seems cannot plugin cordova-plugin-device work. when install apk on android phone, neither "deviceready"-alert nor "button"-alert executes. when try use navigator.notification.alert(device.name, alertcallback) (dialogs plugin) instead (and of course provide callback function) doesn't work either. tried add span element , change html device.cordova on button-click via jquery - no effect.

 

i tried pull plugin github via <plugin spec="https://github.com/apache/cordova-plugin-device.git" /> instead npm. however, didn't work. strange say, 3rd party toast plugin works fine.

 

i've run out of ideas , hope can me out.

 

best regards,

maik

try moving inline script body or add "defer" attribute waits until else has finished loading. might try moving script separate .js file (like index.js).

 

also, have tried debugging app using either chrome (android)? there might error messages appearing in console might of use. check "adb logcat" see if device logging messages might of use.



More discussions in PhoneGap Build


adobe

Comments

Popular posts from this blog

Illustrator CS6 Ocurrío un error E/S en el archivo.

Why is os_ViewContainer running?

Animate - problem with duplicating scripts after loop