我正在开发离子式Cordova应用程序,并且正在使用cordova-hot-code-push-plugin。热门代码推送插件的功能是从服务器获取更新并进行安装。安装后,我注意到其他离子本机插件(例如Camera,File等)无法正常工作,当我注意到cordova_plugin.js文件时,该文件中缺少这些插件。
这是我的app.component.ts
private hotCordovaPushOptions:HotCodePushRequestOptions = {
"config- file":"https://warehousemobile.000webhostapp.com/warehouse/chcp.json",
};
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen,private hotCodePush:HotCodePush) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
this.hotCodePush.fetchUpdate(this.hotCordovaPushOptions).
then(
(value:any)=>{
this.hotCodePush.isUpdateAvailableForInstallation().
then((value:HotCodePushUpdate)=>{
this.hotCodePush.installUpdate().then((res:any)=>{
console.log(res);
}
)
})
},(error:any)=>
{
console.log("e =>"+error)
});
});
}
这是我的cordova-hcp.json
{
"name": "hot-code-push",
"ios_identifier": "",
"android_identifier": "",
"update": "start",
"content_url": "https://warehousemobile.000webhostapp.com/warehouse"
}
在获取更新之前,cordova_plugin.js
module.exports.metadata =
// TOP OF METADATA
{
"cordova-plugin-camera": "4.0.3",
"cordova-plugin-whitelist": "1.3.3",
"cordova-plugin-splashscreen": "5.0.2",
"cordova-plugin-ionic-webview": "2.0.3",
"cordova-plugin-ionic-keyboard": "2.1.2",
"cordova-hot-code-push-plugin": "1.5.3"
};
获取更新后
module.exports.metadata =
// TOP OF METADATA
{
"cordova-plugin-device": "2.0.2",
"cordova-plugin-splashscreen": "5.0.2",
"cordova-plugin-ionic-webview": "2.0.3",
"cordova-plugin-ionic-keyboard": "2.1.2",
"cordova-hot-code-push-plugin": "1.5.3"
};
答案 0 :(得分:0)
问题出在ionic团队最近发布的WKWebView插件上,它与Cordova热门代码推送插件不能很好地配合使用。使用命令删除插件
ionic cordova plugin remove cordova-plugin-ionic-webview --save
并添加以下插件
cordova plugin add cordova-plugin-wkwebview-engine
希望这会有所帮助