1,在項目中添加你的插件
cordova plugin add puginId|puginName|puginUrl|puginPath
2,查看插件clobbers標記
打開項目目錄plugins\pluginName\plugin.xml
這里要注意不是所有的,clobbers target 格式都是 "cordova.pluging.xxxx" 也有可能是:"window.xxxxx"或直接"xxxxx"這里要特別注意
3,聲明 clobbers 標記 變量
在需要調用插件的.ts文件中定義clobbers 標記 變量,如下:
declare let cordova: any;
declare let windowSoftManager: any;
變量名稱要與clobbers target中第一個點前面的一致,這里如果是"window",不需要定義,ionic已經為我們定義了,可以使用(<any>window).xxxx.xxx(),直接調用相應方法
4,調用插件中的方法
路徑要與clobbers target中保持一致