Phonegap 3 - 在托管应用程序中调用Cordova方法 [英] Phonegap 3 - Call Cordova methods in hosted application
问题描述
我正在将Phonegap 2.7应用程序移植到Phonegap 3.该应用程序是托管的,所以phonegap加载外部网址而不是本地html。这个托管的webapp加载 cordoba.js
,但是我无法使用插件如splashscreen和来自托管webapp的通知:
I'm porting a Phonegap 2.7 application to Phonegap 3. The application is hosted, so phonegap loads an external url instead of a local html. This hosted webapp loads cordoba.js
, however I'm unable to use plugins such as splashscreen and notifications from the hosted webapp:
navigator.splashscreen.hide();
// Uncaught TypeError: Cannot call method 'hide' of undefined
navigator.notification.vibrate(500);
// Uncaught TypeError: Cannot call method 'vibrate' of undefined
我创建Phonegap 3项目时包括的相同Cordova文件。为什么我无法使用此API?这在Phonegap 2.7上效果很好。
The hosted application required the same Cordova file that was included when I created the Phonegap 3 project. Why am I unable to use this API's? This worked fine on Phonegap 2.7.
更新:正确触发事件:
document.addEventListener('deviceready', callback, false);
回调
一些cordova的互动已经。问题似乎是插件。
callback
is correctly called, so there is some kind of cordova interaction already. Problem seems plugins.
推荐答案
使用cordova.exec直接调用插件。它如下:
Call the plugin directly with cordova.exec. it goes like this:
cordova.exec(function(response){}, function(errorText){}, "PluginName", "method", []) ;
这篇关于Phonegap 3 - 在托管应用程序中调用Cordova方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!