首先安裝這個插件 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'您必須配置第一背景使心情,然後在後臺調用你的功能 –
是的,它是一種提醒應用程序。那麼如何配置背景啓用模式? –