Loading...
Loading...
Uncaught TypeError: Cannot read properties of undefined (at bridge.js)This error occurs in hybrid mobile apps (Capacitor, Cordova, React Native) when a native event (like an AlarmManager wakeup or Push Notification) tries to trigger a JavaScript callback, but the JS environment has been destroyed because the user swiped the app away (Swipe-to-Kill). The 'bridge' or 'window' object is undefined, causing the native-to-js communication to crash.
On Android, trigger a 'Sticky' Foreground Service to prevent the OS from fully destroying the process context when the app is swiped.
// Ensure service is active before background tasks
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(intent);
}In your plugin logic, always check if the Capacitor/Bridge object is available before executing calls.
if (typeof window !== 'undefined' && window.Capacitor) {
window.Capacitor.triggerEvent('alarm', data);
}Request the user to whitelist your app from battery saving to ensure background receivers can wake the JS engine.
Fix this error faster with our free tool