我在使用ionic 3应用程序在ios设备中播放音频时遇到问题。我尝试启用xcode中的背景模式和设置。没有任何作用
platform.ready().then(() => {
if (platform.is('cordova')){
//Subscribe on pause i.e. background
this.platform.pause.subscribe(() => {
console.log("background");
this.bg.enable();
});
//Subscribe on resume i.e. foreground
this.platform.resume.subscribe(() => {
console.log("foreground");
this.bg.disable();
});
}
});
这是我在player.ts文件中进行后台启用的方式。这是Xcode Capabilites设置。 这个问题不会在andorid中产生
您的解决方案在这里:Background Mode
此插件就是为此创建的。如果您不知道如何在ionic中安装和使用插件,请查看以下内容:How to use this cordova plugin