问题描述:

I'm developing and Android app under Cordova.

I've added successfully the plugin to the project with :

cordova plugin add uk.co.workingedge.phonegap.plugin.launchnavigator

Note : the plugin launchnavigator is present under /plugins.

Then according to this tutorial : https://www.npmjs.com/package/uk.co.workingedge.phonegap.plugin.launchnavigator

I tried a simple navigation to London, UK, like this :

launchnavigator.navigate("London, UK");

But I get the following error :

"ReferenceError: launchnavigator is not defined

at file:///android_asset/www/scripts/6f9ead4e.scripts.js:4363:13

at j (file:///android_asset/www/scripts/ab53ae49.modules.js:12:19786)

at file:///android_asset/www/scripts/ab53ae49.modules.js:12:20463

at k.$eval (file:///android_asset/www/scripts/ab53ae49.modules.js:12:25596)

at k.$digest (file:///android_asset/www/scripts/ab53ae49.modules.js:12:24168)

at k.$apply (file:///android_asset/www/scripts/ab53ae49.modules.js:12:25926)

at HTMLDivElement.<anonymous> (file:///android_asset/www/scripts/ab53ae49.modules.js:19:20693)

at HTMLDivElement.dispatch (file:///android_asset/www/scripts/ab53ae49.modules.js:2:29002)

at HTMLDivElement.r.handle (file:///android_asset/www/scripts/ab53ae49.modules.js:2:25715)", source: file:///android_asset/www/scripts/ab53ae49.modules.js (12)

Am I missing something ?

网友答案:

(1) Make sure you wait until the deviceready event is fired since Cordova plugins are loading dynamically at runtime:

document.addEventListener("deviceready", function(){
    launchnavigator.navigate("London, UK");
}, false);

(2) Download the example project which contains several Cordova projects which can be used as a working reference.

相关阅读:
Top