首先安装这个插件 https://github.com/katzer/cordova-plugin-background-mode#examples
然后
document.addEventListener('deviceready', function() {
// Android customization
cordova.plugins.backgroundMode.setDefaults({ text:'Doing heavy tasks.'});
// Enable background mode
cordova.plugins.backgroundMode.enable();
// Called when background mode has been activated
cordova.plugins.backgroundMode.onactivate = function() {
setTimeout(function() {
// Modify the currently displayed notification
cordova.plugins.backgroundMode.configure({
text:'Running in background for more than 5s now.'
});
}, 5000);
}
}, false);
我假设你正在某种提醒应用程序的其中显示一些弹出窗口或'在应用notification'您必须配置第一背景使心情,然后在后台调用你的功能 –
是的,它是一种提醒应用程序。那么如何配置背景启用模式? –