@exodus/react-native-screenshot-detector 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
id screenshotObserver;
|
|
14
14
|
id screenRecordingObserver;
|
|
15
15
|
BOOL isProtectionEnabled;
|
|
16
|
+
UIWindow *originalKeyWindow;
|
|
17
|
+
CALayer *originalSuperlayer;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
RCT_EXPORT_MODULE();
|
|
@@ -91,7 +93,6 @@ RCT_EXPORT_METHOD(isScreenRecording:(RCTPromiseResolveBlock)resolve
|
|
|
91
93
|
resolve(@(isRecording));
|
|
92
94
|
}
|
|
93
95
|
|
|
94
|
-
// Clear and explicit method names
|
|
95
96
|
RCT_EXPORT_METHOD(subscribeToScreenshotAndScreenRecording) {
|
|
96
97
|
[self startObserving];
|
|
97
98
|
}
|
|
@@ -102,32 +103,58 @@ RCT_EXPORT_METHOD(unsubscribeFromScreenshotAndScreenRecording) {
|
|
|
102
103
|
|
|
103
104
|
// Screenshot Prevention using Secure Text Field
|
|
104
105
|
- (void)enableTrueScreenshotPrevention {
|
|
105
|
-
|
|
106
|
-
self.secureTextField
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
@try {
|
|
107
|
+
if (self.secureTextField == nil) {
|
|
108
|
+
self.secureTextField = [[UITextField alloc] init];
|
|
109
|
+
self.secureTextField.userInteractionEnabled = NO;
|
|
110
|
+
self.secureTextField.secureTextEntry = YES;
|
|
111
|
+
}
|
|
109
112
|
|
|
110
113
|
UIWindow *keyWindow = [self getKeyWindow];
|
|
111
114
|
if (keyWindow != nil) {
|
|
112
|
-
|
|
115
|
+
originalKeyWindow = keyWindow;
|
|
116
|
+
originalSuperlayer = keyWindow.layer.superlayer;
|
|
113
117
|
|
|
114
|
-
|
|
115
|
-
[keyWindow.layer.superlayer addSublayer:self.secureTextField.layer];
|
|
118
|
+
[keyWindow makeKeyAndVisible];
|
|
116
119
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
[
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
120
|
+
if (originalSuperlayer != nil) {
|
|
121
|
+
[originalSuperlayer addSublayer:self.secureTextField.layer];
|
|
122
|
+
|
|
123
|
+
[keyWindow.layer removeFromSuperlayer];
|
|
124
|
+
|
|
125
|
+
NSArray *sublayers = self.secureTextField.layer.sublayers;
|
|
126
|
+
if (sublayers.count > 0) {
|
|
127
|
+
[sublayers.firstObject addSublayer:keyWindow.layer];
|
|
128
|
+
} else {
|
|
129
|
+
[self.secureTextField.layer addSublayer:keyWindow.layer];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
} @catch (NSException *exception) {
|
|
134
|
+
NSLog(@"[RNScreenshotDetector] Error in enableTrueScreenshotPrevention: %@", exception);
|
|
125
135
|
}
|
|
126
136
|
}
|
|
127
137
|
|
|
128
138
|
- (void)disableTrueScreenshotPrevention {
|
|
129
|
-
|
|
130
|
-
self.secureTextField
|
|
139
|
+
@try {
|
|
140
|
+
if (self.secureTextField != nil) {
|
|
141
|
+
self.secureTextField.secureTextEntry = NO;
|
|
142
|
+
|
|
143
|
+
if (originalKeyWindow != nil && originalSuperlayer != nil) {
|
|
144
|
+
[originalKeyWindow.layer removeFromSuperlayer];
|
|
145
|
+
[originalSuperlayer addSublayer:originalKeyWindow.layer];
|
|
146
|
+
|
|
147
|
+
[self.secureTextField.layer removeFromSuperlayer];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
originalKeyWindow = nil;
|
|
151
|
+
originalSuperlayer = nil;
|
|
152
|
+
|
|
153
|
+
[self.secureTextField removeFromSuperview];
|
|
154
|
+
self.secureTextField = nil;
|
|
155
|
+
}
|
|
156
|
+
} @catch (NSException *exception) {
|
|
157
|
+
NSLog(@"[RNScreenshotDetector] Error in disableTrueScreenshotPrevention: %@", exception);
|
|
131
158
|
}
|
|
132
159
|
}
|
|
133
160
|
|