Commit 76041cc
authored
Fix(preventScreenshot): fix logic on iOS (#39)
**Bug fixed** : Opening Control Center during app launch causes the
screenshot prevention overlay to get stuck visible on iOS. The overlay
remains on screen while the app is fully active, producing a white
screen over the app content. Subsequent background/foreground
transitions are also affected.
**File**: RNASAppLifecyleDelegate.swift
Change: Added `private var becomeActiveObserver: NSObjectProtocol?`
Why: Holds a reference to the NotificationCenter observer for proper
cleanup in deinit
────────────────────────────────────────
Change: Added `_ = launchScreen.view` in the lazy `launchScreenWindow`
initializer
Why: Forces the storyboard view controller to load its view eagerly, so
the overlay renders its content immediately instead of showing a blank
white window on first display
────────────────────────────────────────
Change: In `didFinishLaunchingWithOptions`: subscribe to
`UIApplication.didBecomeActiveNotification` via NotificationCenter
Why: This notification is posted directly by UIKit at the OS level,
independently of Expo's delegate chain. It fires reliably when the app
becomes active even during launch, where the delegate method is dropped
────────────────────────────────────────
Change: Added deinit to remove the NotificationCenter observer
Why: Prevents a memory leak if the delegate is ever deallocated
────────────────────────────────────────
Change: Replaced `launchScreenWindow?.makeKeyAndVisible()` with
`launchScreenWindow?.isHidden = false` in `applicationWillResignActive`
Why: `makeKeyAndVisible()` steals key window status from the main app
window, which triggers cascading `willResignActive` events from internal
app activity, causing the overlay to re-appear unexpectedly. The
window's .alert + 2 level already guarantees it appears on top without
needing key window status
────────────────────────────────────────
Change: Added a comment to `applicationDidBecomeActive`
Why: Kept as belt-and-suspenders fallback in case the NotificationCenter
observer is not set up (e.g. preventRecentScreenshots is toggled at
runtime)1 parent e5040f4 commit 76041cc
1 file changed
Lines changed: 27 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
16 | 29 | | |
17 | 30 | | |
18 | 31 | | |
19 | 32 | | |
20 | 33 | | |
21 | 34 | | |
22 | | - | |
23 | 35 | | |
24 | 36 | | |
25 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
26 | 44 | | |
27 | 45 | | |
28 | 46 | | |
29 | 47 | | |
30 | | - | |
| 48 | + | |
31 | 49 | | |
32 | 50 | | |
33 | 51 | | |
34 | 52 | | |
35 | | - | |
| 53 | + | |
36 | 54 | | |
37 | | - | |
38 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
39 | 58 | | |
40 | | - | |
| 59 | + | |
41 | 60 | | |
| 61 | + | |
| 62 | + | |
42 | 63 | | |
43 | 64 | | |
44 | 65 | | |
| |||
0 commit comments