Skip to content

Commit 13f49ae

Browse files
author
Matthieu Gicquel
committed
fix: make preventRecentScreenshot: false work on iOS
1 parent 970c31a commit 13f49ae

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

ios/RNASAppLifecyleDelegate.swift

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@ import UIKit
33

44
public class RNASAppLifecycleDelegate: ExpoAppDelegateSubscriber {
55
public func applicationDidFinishLaunching(_ application: UIApplication) {
6-
application.ignoreSnapshotOnNextApplicationLaunch()
6+
if(!isPreventRecentScreenshotsEnabled()) {
7+
return
8+
}
9+
application.ignoreSnapshotOnNextApplicationLaunch()
710
}
811

912
public func applicationWillResignActive(_ application: UIApplication) {
13+
if(!isPreventRecentScreenshotsEnabled()) {
14+
return
15+
}
16+
1017
// https://developer.apple.com/documentation/uikit/app_and_environment/scenes/preparing_your_ui_to_run_in_the_background
1118

1219
// TODO: better error handling in case there's an issue with the splashscreen (instead of !)
@@ -17,6 +24,18 @@ public class RNASAppLifecycleDelegate: ExpoAppDelegateSubscriber {
1724
}
1825

1926
public func applicationDidBecomeActive(_ application: UIApplication) {
27+
if(!isPreventRecentScreenshotsEnabled()) {
28+
return
29+
}
30+
2031
UIApplication.shared.windows.first?.rootViewController?.dismiss(animated: false)
2132
}
2233
}
34+
35+
36+
func isPreventRecentScreenshotsEnabled() -> Bool {
37+
if let value = Bundle.main.object(forInfoDictionaryKey: "RNAS_PREVENT_RECENT_SCREENSHOTS") as? Bool {
38+
return value
39+
}
40+
return false
41+
}

0 commit comments

Comments
 (0)