@globules-io/cordova-plugin-background-mode
v1.0.0
Published
Prevent Cordova apps from sleeping in background using foreground service + wake lock. Fully Android 16 (API 36) compatible.
Downloads
15
Maintainers
Readme
Cordova Background Mode Plugin (2025 Edition)
Plugin for the Cordova framework to perform infinite background execution on Android & iOS.
Fully modernized, Google Play & App Store compliant, survives Samsung One UI 7, Xiaomi HyperOS 2, Android 15, iOS 18.
Store Compliance Warning
Infinite background execution is not officially supported by Google Play or Apple App Store.
A successful submission is possible but not guaranteed. Use at your own risk.
Supported Platforms
- Android (6.0+)
- iOS (12.0+)
Installation
cordova plugin add @globules-io/cordova-plugin-background-mode
# or from this repo
cordova plugin add https://github.com/globules-io/cordova-plugin-background-mode.gitUsage
Enable/Disable
cordova.plugins.backgroundMode.enable();
cordova.plugins.backgroundMode.disable();Check Status
cordova.plugins.backgroundMode.isEnabled(); // true if plugin is enabled
cordova.plugins.backgroundMode.isActive(); // true if app is in backgroundEvents
cordova.plugins.backgroundMode.on('activate', () => {
console.log('Background mode activated');
});
cordova.plugins.backgroundMode.on('deactivate', () => {
console.log('Background mode deactivated');
});
cordova.plugins.backgroundMode.un('activate', callback); // Remove listenerNotification (Android)
cordova.plugins.backgroundMode.configure({
title: 'My App',
text: 'Running in background...',
icon: 'icon', // res/drawable/icon.png
color: 'F14F4D', // Android 5.0+ accent color
silent: false, // Set true to hide notification (not recommended)
resume: true, // Tap notification brings app to foreground
hidden: true, // Android 5.0+: hide on lockscreen
bigText: false
});Silent Mode
Warning: Android may kill silent background apps aggressively.
cordova.plugins.backgroundMode.configure({ silent: true });