feat: Android APP V1 - Experimental Alpha
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import type { MobileAppLifecycleAdapter } from '../../contracts/mobile.contracts';
|
||||
|
||||
/** Visibility API fallback for browser runtimes. */
|
||||
export class WebMobileAppLifecycleAdapter implements MobileAppLifecycleAdapter {
|
||||
private handler: ((isActive: boolean) => void) | null = null;
|
||||
|
||||
async initialize(): Promise<void> {
|
||||
if (typeof document === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
this.handler?.(!document.hidden);
|
||||
});
|
||||
}
|
||||
|
||||
onAppStateChange(handler: (isActive: boolean) => void): void {
|
||||
this.handler = handler;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user