Skip to content

Fix(preventScreenshot): fix logic on iOS#39

Merged
marineshaw merged 1 commit intomainfrom
fix/prevent-screenshot-logic-on-iOS
Apr 15, 2026
Merged

Fix(preventScreenshot): fix logic on iOS#39
marineshaw merged 1 commit intomainfrom
fix/prevent-screenshot-logic-on-iOS

Conversation

@marineshaw
Copy link
Copy Markdown
Contributor

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)

@marineshaw marineshaw changed the title Fix(preventScreenshot): fix logic on iOs Fix(preventScreenshot): fix logic on iOS Apr 14, 2026
@marineshaw marineshaw force-pushed the fix/prevent-screenshot-logic-on-iOS branch from 4d74dd2 to bae9969 Compare April 14, 2026 08:25
@marineshaw marineshaw merged commit 76041cc into main Apr 15, 2026
@marineshaw marineshaw deleted the fix/prevent-screenshot-logic-on-iOS branch April 15, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant