/** * Fix natywnego crasha "RuntimeException: Adding window failed" / DeadObjectException * (Sentry issue ddec9d6b, fatal, Android). RN `Alert.alert` pokazuje natywny * DialogFragment przez WindowManager.addView. Gdy activity leci w tło albo jest * ubijane (binder do WindowManagera martwy) w momencie `Dialog.show()`, add-window * rzuca DeadObjectException → fatal crash. Typowy trigger: alert z async handlera * (np. "Update available" na boocie, błąd playbacku/resolve) odpalony gdy user zdążył * zbackgroundować apkę. * * Guard: nie pokazuj dialogu gdy apka NIE jest na wierzchu ('active'). Transientowe * alerty w tle i tak nie mają sensu (user nie patrzy), a ważne (update) wrócą przy * następnym foregroundzie/launchu. Patch globalny na Alert.alert, obejmuje WSZYSTKIE * wywołania (obecne i przyszłe, też z bibliotek) bez owijania ~56 call-site'ów. * * Import jako side-effect NA GÓRZE App.tsx, przed pierwszym możliwym Alertem. */ import { Alert, AppState } from 'react-native'; const _origAlert = Alert.alert.bind(Alert); (Alert as { alert: typeof Alert.alert }).alert = (( ...args: Parameters ) => { if (AppState.currentState !== 'active') return; return _origAlert(...args); }) as typeof Alert.alert;