0

我正在嘗試將this plugin添加到PhoneGap應用程序中。如何在PhoneGap Developer App上安裝Cordova/phonegap插件

我用這個命令:

$ cordova plugin add cordova-media-with-compression 

我可以看到該插件的插件列表中正確添加運行以下命令:

$ phonegap plugin list 

但是,當我使用PhoneGap的開發應用(在iPhone上)該插件不可用。

我運行此代碼,以獲得安裝的插件在運行時的名單:

document.addEventListener("deviceready", function() { 

    var pluginList = cordova.require("cordova/plugin_list").metadata; 
    console.log(JSON.stringify(pluginList)); 

}); 

上面的代碼返回兩套不同的插件,如果我運行瀏覽器或從應用程序PhoneGap開發者應用程序。從瀏覽器我得到這個:

{ 
    "cordova-media-with-compression": "2.1.0", 
    "cordova-plugin-battery-status": "1.1.2", 
    "cordova-plugin-camera": "2.1.1", 
    "cordova-plugin-compat": "1.1.0", 
    "cordova-plugin-console": "1.0.4", 
    "cordova-plugin-contacts": "2.0.1", 
    "cordova-plugin-device": "1.1.3", 
    "cordova-plugin-device-motion": "1.2.2", 
    "cordova-plugin-device-orientation": "1.0.4", 
    "cordova-plugin-dialogs": "1.2.1", 
    "cordova-plugin-file": "4.3.0", 
    "cordova-plugin-file-transfer": "1.5.1", 
    "cordova-plugin-geolocation": "2.1.0", 
    "cordova-plugin-globalization": "1.0.4", 
    "cordova-plugin-inappbrowser": "1.3.0", 
    "cordova-plugin-network-information": "1.2.1", 
    "cordova-plugin-splashscreen": "3.2.2", 
    "cordova-plugin-statusbar": "2.1.3", 
    "cordova-plugin-vibration": "2.1.2", 
    "cordova-plugin-whitelist": "1.2.2" 
} 

而且從PhoneGap的開發應用我得到這個:

{ 
    "com.wikitude.phonegap.WikitudePlugin": "5.3.0", 
    "cordova-plugin-battery-status": "1.2.0", 
    "cordova-plugin-ble-central": "1.1.2", 
    "cordova-plugin-camera": "2.3.0", 
    "cordova-plugin-compat": "1.0.0", 
    "cordova-plugin-console": "1.0.4", 
    "cordova-plugin-contacts": "2.2.0", 
    "cordova-plugin-device": "1.1.3", 
    "cordova-plugin-device-motion": "1.2.2", 
    "cordova-plugin-device-orientation": "1.0.4", 
    "cordova-plugin-dialogs": "1.3.0", 
    "cordova-plugin-file": "4.3.0", 
    "cordova-plugin-file-transfer": "1.6.0", 
    "cordova-plugin-geolocation": "2.4.1-dev", 
    "cordova-plugin-globalization": "1.0.4", 
    "cordova-plugin-inappbrowser": "1.5.0", 
    "cordova-plugin-insomnia": "4.2.0", 
    "cordova-plugin-media": "2.4.0", 
    "cordova-plugin-media-capture": "1.4.0", 
    "cordova-plugin-network-information": "1.3.0", 
    "cordova-plugin-splashscreen": "4.0.0", 
    "cordova-plugin-statusbar": "2.2.0", 
    "cordova-plugin-whitelist": "1.3.0", 
    "cordova-plugin-x-socialsharing": "5.1.3", 
    "phonegap-plugin-barcodescanner": "6.0.3", 
    "phonegap-plugin-contentsync": "1.2.5", 
    "phonegap-plugin-mobile-accessibility": "1.0.4", 
    "phonegap-plugin-push": "1.8.3" 
} 

正如你所看到的,在第一個列表有插件cordova-media-with-compression而在第二個列表沒有。

爲什麼這兩個插件列表不等於?我如何在PhoneGap Developer App中獲得新安裝的插件?

回答

1

我發現了PhoneGap的開發應用配備了一組插件開箱即用的,這是不可能添加其他外部插件:http://docs.phonegap.com/references/developer-app/troubleshoot-faq/

如果您使用的插件您的項目沒有顯示在此列表中,它不會與PhoneGap開發人員應用程序一起使用。 但是,您可以在本地創建your own custom build of the PhoneGap Developer app並在其中包含任何其他插件。

官方建議是創建開發人員應用程序的自定義版本。

這些都是在GitHub上有關此問題的一些討論:

https://github.com/phonegap/phonegap-app-developer/issues/247 https://github.com/phonegap/phonegap-app-developer/issues/209