@sodyo/react-native-sodyo-sdk 5.0.2 → 5.1.1
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.
- package/android/CODE_ANALYSIS.md +464 -0
- package/android/build.gradle +4 -17
- package/android/src/main/java/com/sodyo/RNSodyoSdk/ConversionUtil.java +26 -5
- package/android/src/main/java/com/sodyo/RNSodyoSdk/RNSodyoSdkModule.java +119 -37
- package/android/src/main/java/com/sodyo/RNSodyoSdk/RNSodyoSdkView.java +9 -6
- package/ios/CODE_ANALYSIS.md +360 -0
- package/ios/RNSodyoScanner.h +3 -4
- package/ios/RNSodyoScanner.m +6 -5
- package/ios/RNSodyoSdk.h +1 -3
- package/ios/RNSodyoSdk.m +107 -56
- package/ios/RNSodyoSdkManager.m +40 -17
- package/ios/RNSodyoSdkView.h +4 -2
- package/ios/RNSodyoSdkView.m +36 -12
- package/package.json +1 -1
package/ios/RNSodyoSdk.m
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
#import "RNSodyoSdk.h"
|
|
3
2
|
#import "RNSodyoScanner.h"
|
|
4
3
|
|
|
@@ -16,7 +15,7 @@ RCT_EXPORT_METHOD(
|
|
|
16
15
|
errorCallback:(RCTResponseSenderBlock)errorCallback
|
|
17
16
|
)
|
|
18
17
|
{
|
|
19
|
-
RCTLogInfo(@"SodyoSDK: init()");
|
|
18
|
+
RCTLogInfo(@"SodyoSDK: init() - apiKey: %@, successCallback: %@, errorCallback: %@", apiKey, successCallback ? @"provided" : @"nil", errorCallback ? @"provided" : @"nil");
|
|
20
19
|
|
|
21
20
|
self.successStartCallback = successCallback;
|
|
22
21
|
self.errorStartCallback = errorCallback;
|
|
@@ -25,9 +24,10 @@ RCT_EXPORT_METHOD(
|
|
|
25
24
|
|
|
26
25
|
RCT_EXPORT_METHOD(createCloseContentListener)
|
|
27
26
|
{
|
|
28
|
-
RCTLogInfo(@"SodyoSDK: createCloseContentListener()");
|
|
27
|
+
RCTLogInfo(@"SodyoSDK: createCloseContentListener() - isCloseContentObserverExist: %@", self.isCloseContentObserverExist ? @"YES" : @"NO");
|
|
29
28
|
|
|
30
29
|
if (self.isCloseContentObserverExist) {
|
|
30
|
+
NSLog(@"SodyoSDK: createCloseContentListener - observer already exists, skipping");
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -35,95 +35,103 @@ RCT_EXPORT_METHOD(createCloseContentListener)
|
|
|
35
35
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendCloseContentEvent) name:@"SodyoNotificationCloseIAD" object:nil];
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
// Issue #4 fix: remove notification observer on dealloc
|
|
39
|
+
- (void)dealloc {
|
|
40
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
41
|
+
}
|
|
42
|
+
|
|
38
43
|
RCT_EXPORT_METHOD(start)
|
|
39
44
|
{
|
|
40
|
-
NSLog(@"start");
|
|
45
|
+
NSLog(@"SodyoSDK: start - launching scanner");
|
|
41
46
|
[self launchSodyoScanner];
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
RCT_EXPORT_METHOD(close)
|
|
45
50
|
{
|
|
46
|
-
NSLog(@"close");
|
|
51
|
+
NSLog(@"SodyoSDK: close - closing scanner");
|
|
47
52
|
[self closeScanner];
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
RCT_EXPORT_METHOD(setCustomAdLabel:(NSString *)labels)
|
|
51
56
|
{
|
|
52
|
-
NSLog(@"setCustomAdLabel");
|
|
57
|
+
NSLog(@"SodyoSDK: setCustomAdLabel - labels: %@", labels);
|
|
53
58
|
[SodyoSDK setCustomAdLabel:labels];
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
RCT_EXPORT_METHOD(setAppUserId:(NSString *)userId)
|
|
57
62
|
{
|
|
58
|
-
NSLog(@"setAppUserId");
|
|
63
|
+
NSLog(@"SodyoSDK: setAppUserId - userId: %@", userId);
|
|
59
64
|
[SodyoSDK setUserId:userId];
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
RCT_EXPORT_METHOD(setUserInfo:(NSDictionary *) userInfo)
|
|
63
68
|
{
|
|
64
|
-
NSLog(@"setUserInfo");
|
|
69
|
+
NSLog(@"SodyoSDK: setUserInfo - userInfo: %@", userInfo);
|
|
65
70
|
[SodyoSDK setUserInfo:userInfo];
|
|
66
71
|
}
|
|
67
72
|
|
|
68
73
|
RCT_EXPORT_METHOD(setScannerParams:(NSDictionary *) params)
|
|
69
74
|
{
|
|
70
|
-
NSLog(@"setScannerParams");
|
|
75
|
+
NSLog(@"SodyoSDK: setScannerParams - params: %@", params);
|
|
71
76
|
[SodyoSDK setScannerParams:params];
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
RCT_EXPORT_METHOD(addScannerParam:(NSString *) key value:(NSString *) value)
|
|
75
80
|
{
|
|
76
|
-
NSLog(@"addScannerParam");
|
|
81
|
+
NSLog(@"SodyoSDK: addScannerParam - key: %@, value: %@", key, value);
|
|
77
82
|
[SodyoSDK addScannerParams:key value:value];
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
RCT_EXPORT_METHOD(setDynamicProfile:(NSDictionary *) profile)
|
|
81
86
|
{
|
|
82
|
-
NSLog(@"setDynamicProfile");
|
|
87
|
+
NSLog(@"SodyoSDK: setDynamicProfile - profile: %@", profile);
|
|
83
88
|
[SodyoSDK setDynamicProfile:profile];
|
|
84
89
|
}
|
|
85
90
|
|
|
86
91
|
RCT_EXPORT_METHOD(setDynamicProfileValue:(NSString *) key value:(NSString *) value)
|
|
87
92
|
{
|
|
88
|
-
NSLog(@"setDynamicProfileValue");
|
|
93
|
+
NSLog(@"SodyoSDK: setDynamicProfileValue - key: %@, value: %@", key, value);
|
|
89
94
|
[SodyoSDK setDynamicProfileValue:key value:value];
|
|
90
95
|
}
|
|
91
96
|
|
|
92
97
|
RCT_EXPORT_METHOD(performMarker:(NSString *) markerId customProperties:(NSDictionary *) customProperties)
|
|
93
98
|
{
|
|
94
|
-
NSLog(@"performMarker");
|
|
95
|
-
UIViewController *rootViewController = [
|
|
99
|
+
NSLog(@"SodyoSDK: performMarker - markerId: %@, customProperties: %@", markerId, customProperties);
|
|
100
|
+
UIViewController *rootViewController = [self getRootViewController];
|
|
101
|
+
NSLog(@"SodyoSDK: performMarker - rootViewController: %@", rootViewController);
|
|
96
102
|
[SodyoSDK setPresentingViewController:rootViewController];
|
|
97
103
|
[SodyoSDK performMarker:markerId customProperties:customProperties];
|
|
98
104
|
}
|
|
99
105
|
|
|
100
106
|
RCT_EXPORT_METHOD(startTroubleshoot)
|
|
101
107
|
{
|
|
102
|
-
NSLog(@"startTroubleshoot");
|
|
103
|
-
|
|
104
|
-
|
|
108
|
+
NSLog(@"SodyoSDK: startTroubleshoot");
|
|
109
|
+
UIViewController *scanner = [RNSodyoScanner getSodyoScanner];
|
|
110
|
+
NSLog(@"SodyoSDK: startTroubleshoot - scanner: %@", scanner);
|
|
111
|
+
[SodyoSDK startTroubleshoot:scanner];
|
|
105
112
|
}
|
|
106
113
|
|
|
107
114
|
|
|
108
115
|
RCT_EXPORT_METHOD(setTroubleshootMode)
|
|
109
116
|
{
|
|
110
|
-
NSLog(@"setTroubleshootMode");
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
[SodyoSDK setMode:
|
|
117
|
+
NSLog(@"SodyoSDK: setTroubleshootMode");
|
|
118
|
+
UIViewController *scanner = [RNSodyoScanner getSodyoScanner];
|
|
119
|
+
NSLog(@"SodyoSDK: setTroubleshootMode - scanner: %@", scanner);
|
|
120
|
+
[SodyoSDK setMode:scanner mode:SodyoModeTroubleshoot];
|
|
114
121
|
}
|
|
115
122
|
|
|
116
123
|
RCT_EXPORT_METHOD(setNormalMode)
|
|
117
124
|
{
|
|
118
|
-
NSLog(@"setNormalMode");
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
[SodyoSDK setMode:
|
|
125
|
+
NSLog(@"SodyoSDK: setNormalMode");
|
|
126
|
+
UIViewController *scanner = [RNSodyoScanner getSodyoScanner];
|
|
127
|
+
NSLog(@"SodyoSDK: setNormalMode - scanner: %@", scanner);
|
|
128
|
+
[SodyoSDK setMode:scanner mode:SodyoModeNormal];
|
|
122
129
|
}
|
|
123
130
|
|
|
124
|
-
|
|
131
|
+
// Issue #3 fix: BOOL instead of BOOL*
|
|
132
|
+
RCT_EXPORT_METHOD(setSodyoLogoVisible:(BOOL) isVisible)
|
|
125
133
|
{
|
|
126
|
-
NSLog(@"setSodyoLogoVisible");
|
|
134
|
+
NSLog(@"SodyoSDK: setSodyoLogoVisible - isVisible: %@", isVisible ? @"YES" : @"NO");
|
|
127
135
|
if (isVisible) {
|
|
128
136
|
return [SodyoSDK showDefaultOverlay];
|
|
129
137
|
}
|
|
@@ -131,12 +139,19 @@ RCT_EXPORT_METHOD(setSodyoLogoVisible:(BOOL *) isVisible)
|
|
|
131
139
|
[SodyoSDK hideDefaultOverlay];
|
|
132
140
|
}
|
|
133
141
|
|
|
142
|
+
// Issue #8 fix: guard against nil env value
|
|
134
143
|
RCT_EXPORT_METHOD(setEnv:(NSString *) env)
|
|
135
144
|
{
|
|
136
|
-
NSLog(@"setEnv");
|
|
145
|
+
NSLog(@"SodyoSDK: setEnv - env: %@", env);
|
|
137
146
|
|
|
138
147
|
NSDictionary *envs = @{ @"DEV": @"3", @"QA": @"1", @"PROD": @"0" };
|
|
139
|
-
|
|
148
|
+
NSString *envValue = envs[env];
|
|
149
|
+
if (!envValue) {
|
|
150
|
+
NSLog(@"SodyoSDK: setEnv - Unknown env '%@', defaulting to PROD", env);
|
|
151
|
+
envValue = @"0";
|
|
152
|
+
}
|
|
153
|
+
NSDictionary *params = @{ @"SodyoAdEnv": envValue, @"ScanQR": @"false" };
|
|
154
|
+
NSLog(@"SodyoSDK: setEnv - resolved params: %@", params);
|
|
140
155
|
[SodyoSDK setScannerParams:params];
|
|
141
156
|
}
|
|
142
157
|
|
|
@@ -145,38 +160,43 @@ RCT_EXPORT_METHOD(setEnv:(NSString *) env)
|
|
|
145
160
|
return @[@"EventSodyoError", @"EventMarkerDetectSuccess", @"EventMarkerDetectError", @"EventMarkerContent", @"EventCloseSodyoContent", @"ModeChangeCallback"];
|
|
146
161
|
}
|
|
147
162
|
|
|
163
|
+
// Issue #2 fix: inverted null-check + use shared scanner accessor
|
|
148
164
|
- (void) launchSodyoScanner {
|
|
149
|
-
NSLog(@"launchSodyoScanner");
|
|
150
|
-
|
|
165
|
+
NSLog(@"SodyoSDK: launchSodyoScanner");
|
|
166
|
+
UIViewController *scanner = [RNSodyoScanner getSodyoScanner];
|
|
167
|
+
NSLog(@"SodyoSDK: launchSodyoScanner - scanner: %@", scanner);
|
|
151
168
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
169
|
+
if (!scanner) {
|
|
170
|
+
NSLog(@"SodyoSDK: launchSodyoScanner - scanner not initialized, aborting");
|
|
171
|
+
return;
|
|
155
172
|
}
|
|
156
173
|
|
|
157
|
-
if (
|
|
158
|
-
NSLog(@"
|
|
174
|
+
if (scanner.isViewLoaded && scanner.view.window) {
|
|
175
|
+
NSLog(@"SodyoSDK: launchSodyoScanner - scanner already active (isViewLoaded: %@, window: %@)", scanner.isViewLoaded ? @"YES" : @"NO", scanner.view.window);
|
|
159
176
|
return;
|
|
160
177
|
}
|
|
161
178
|
|
|
162
|
-
UIViewController *rootViewController = [
|
|
163
|
-
|
|
179
|
+
UIViewController *rootViewController = [self getRootViewController];
|
|
180
|
+
NSLog(@"SodyoSDK: launchSodyoScanner - rootViewController: %@", rootViewController);
|
|
181
|
+
scanner.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
164
182
|
[SodyoSDK setPresentingViewController:rootViewController];
|
|
165
|
-
[rootViewController presentViewController:
|
|
183
|
+
[rootViewController presentViewController:scanner animated:YES completion:nil];
|
|
166
184
|
}
|
|
167
185
|
|
|
168
186
|
- (void) closeScanner {
|
|
169
|
-
NSLog(@"closeScanner");
|
|
170
|
-
UIViewController *rootViewController = [
|
|
187
|
+
NSLog(@"SodyoSDK: closeScanner");
|
|
188
|
+
UIViewController *rootViewController = [self getRootViewController];
|
|
189
|
+
NSLog(@"SodyoSDK: closeScanner - rootViewController: %@", rootViewController);
|
|
171
190
|
[rootViewController dismissViewControllerAnimated:YES completion:nil];
|
|
172
191
|
}
|
|
173
192
|
|
|
174
193
|
- (void) sendCloseContentEvent {
|
|
175
|
-
NSLog(@"sendCloseContentEvent");
|
|
194
|
+
NSLog(@"SodyoSDK: sendCloseContentEvent - sending EventCloseSodyoContent");
|
|
176
195
|
[self sendEventWithName:@"EventCloseSodyoContent" body:nil];
|
|
177
196
|
}
|
|
178
197
|
|
|
179
198
|
- (NSString *) convertScannerModeToString:(SodyoMode)mode {
|
|
199
|
+
NSLog(@"SodyoSDK: convertScannerModeToString - mode: %ld", (long)mode);
|
|
180
200
|
switch (mode) {
|
|
181
201
|
case SodyoModeTroubleshoot:
|
|
182
202
|
return @"Troubleshoot";
|
|
@@ -187,49 +207,80 @@ RCT_EXPORT_METHOD(setEnv:(NSString *) env)
|
|
|
187
207
|
}
|
|
188
208
|
}
|
|
189
209
|
|
|
210
|
+
// Issue #11 fix: UIScene-compatible root view controller access
|
|
211
|
+
- (UIViewController *)getRootViewController {
|
|
212
|
+
UIWindow *keyWindow = nil;
|
|
213
|
+
if (@available(iOS 13.0, *)) {
|
|
214
|
+
for (UIWindowScene *scene in [UIApplication sharedApplication].connectedScenes) {
|
|
215
|
+
if (scene.activationState == UISceneActivationStateForegroundActive) {
|
|
216
|
+
for (UIWindow *window in scene.windows) {
|
|
217
|
+
if (window.isKeyWindow) {
|
|
218
|
+
keyWindow = window;
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (keyWindow) break;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (!keyWindow) {
|
|
227
|
+
keyWindow = [UIApplication sharedApplication].delegate.window;
|
|
228
|
+
}
|
|
229
|
+
return keyWindow.rootViewController;
|
|
230
|
+
}
|
|
231
|
+
|
|
190
232
|
#pragma mark - SodyoSDKDelegate
|
|
233
|
+
// Issue #5 fix: nil both callbacks after either fires
|
|
191
234
|
- (void) onSodyoAppLoadSuccess:(NSInteger)AppID {
|
|
192
|
-
NSLog(@"onSodyoAppLoadSuccess");
|
|
235
|
+
NSLog(@"SodyoSDK: onSodyoAppLoadSuccess - AppID: %ld, successCallback: %@", (long)AppID, self.successStartCallback ? @"provided" : @"nil");
|
|
193
236
|
|
|
194
237
|
if (self.successStartCallback != nil) {
|
|
195
238
|
self.successStartCallback(@[[NSNull null]]);
|
|
196
|
-
self.successStartCallback = nil;
|
|
197
239
|
}
|
|
240
|
+
self.successStartCallback = nil;
|
|
241
|
+
self.errorStartCallback = nil;
|
|
198
242
|
}
|
|
199
243
|
|
|
244
|
+
// Issue #6 fix: serialize NSError to string
|
|
200
245
|
- (void) onSodyoAppLoadFailed:(NSInteger)AppID error:(NSError *)error {
|
|
201
|
-
NSLog(@"
|
|
246
|
+
NSLog(@"SodyoSDK: onSodyoAppLoadFailed - AppID: %ld, error: %@, errorCode: %ld, errorDomain: %@", (long)AppID, error.localizedDescription, (long)error.code, error.domain);
|
|
202
247
|
if (self.errorStartCallback != nil) {
|
|
203
|
-
|
|
204
|
-
self.errorStartCallback
|
|
248
|
+
NSString *message = error.localizedDescription ?: @"Unknown error";
|
|
249
|
+
self.errorStartCallback(@[@{@"error": message}]);
|
|
205
250
|
}
|
|
251
|
+
self.successStartCallback = nil;
|
|
252
|
+
self.errorStartCallback = nil;
|
|
206
253
|
}
|
|
207
254
|
|
|
255
|
+
// Issue #7 fix: guard against nil error description
|
|
208
256
|
- (void) sodyoError:(NSError *)error {
|
|
209
257
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
[self sendEventWithName:@"EventSodyoError" body:@{@"error":
|
|
258
|
+
NSString *desc = error.localizedDescription ?: @"Unknown error";
|
|
259
|
+
NSLog(@"SodyoSDK: sodyoError - description: %@, code: %ld, domain: %@, userInfo: %@", desc, (long)error.code, error.domain, error.userInfo);
|
|
260
|
+
[self sendEventWithName:@"EventSodyoError" body:@{@"error": desc}];
|
|
213
261
|
});
|
|
214
262
|
}
|
|
215
263
|
|
|
264
|
+
// Issue #9 fix: guard against nil marker data
|
|
216
265
|
- (void) SodyoMarkerDetectedWithData:(NSDictionary*)Data {
|
|
217
|
-
NSLog(@"SodyoMarkerDetectedWithData: %@", Data[@"sodyoMarkerData"]);
|
|
218
|
-
|
|
266
|
+
NSLog(@"SodyoSDK: SodyoMarkerDetectedWithData - fullData: %@, sodyoMarkerData: %@", Data, Data[@"sodyoMarkerData"]);
|
|
267
|
+
id markerData = Data[@"sodyoMarkerData"] ?: [NSNull null];
|
|
268
|
+
[self sendEventWithName:@"EventMarkerDetectSuccess" body:@{@"data": markerData}];
|
|
219
269
|
}
|
|
220
270
|
|
|
221
271
|
- (void) SodyoMarkerContent:(NSString *)markerId Data:(NSDictionary *)Data {
|
|
222
|
-
NSLog(@"
|
|
223
|
-
|
|
272
|
+
NSLog(@"SodyoSDK: SodyoMarkerContent - markerId: %@, Data: %@", markerId, Data);
|
|
273
|
+
id data = Data ?: @{};
|
|
274
|
+
[self sendEventWithName:@"EventMarkerContent" body:@{@"markerId": markerId ?: @"", @"data": data}];
|
|
224
275
|
}
|
|
225
276
|
|
|
226
277
|
|
|
227
278
|
- (void) onModeChange:(SodyoMode)from to:(SodyoMode)to {
|
|
228
|
-
NSLog(@"onModeChange");
|
|
229
279
|
NSString* fromConverted = [self convertScannerModeToString:from];
|
|
230
280
|
NSString* toConverted = [self convertScannerModeToString:to];
|
|
281
|
+
NSLog(@"SodyoSDK: onModeChange - from: %@ (%ld) to: %@ (%ld)", fromConverted, (long)from, toConverted, (long)to);
|
|
231
282
|
|
|
232
283
|
[self sendEventWithName:@"ModeChangeCallback" body:@{@"oldMode": fromConverted, @"newMode": toConverted}];
|
|
233
284
|
}
|
|
234
285
|
|
|
235
|
-
@end
|
|
286
|
+
@end
|
package/ios/RNSodyoSdkManager.m
CHANGED
|
@@ -16,64 +16,87 @@
|
|
|
16
16
|
#import "RNSodyoSdkView.h"
|
|
17
17
|
#import "RNSodyoScanner.h"
|
|
18
18
|
|
|
19
|
-
@interface RNSodyoSdkManager : RCTViewManager
|
|
20
|
-
}
|
|
19
|
+
@interface RNSodyoSdkManager : RCTViewManager
|
|
21
20
|
@end
|
|
22
21
|
|
|
23
22
|
@implementation RNSodyoSdkManager
|
|
24
23
|
|
|
25
24
|
RCT_EXPORT_MODULE(RNSodyoSdkView)
|
|
26
25
|
|
|
26
|
+
// Issue #11 fix: UIScene-compatible root view controller access
|
|
27
|
+
- (UIViewController *)getRootViewController {
|
|
28
|
+
UIWindow *keyWindow = nil;
|
|
29
|
+
if (@available(iOS 13.0, *)) {
|
|
30
|
+
for (UIWindowScene *scene in [UIApplication sharedApplication].connectedScenes) {
|
|
31
|
+
if (scene.activationState == UISceneActivationStateForegroundActive) {
|
|
32
|
+
for (UIWindow *window in scene.windows) {
|
|
33
|
+
if (window.isKeyWindow) {
|
|
34
|
+
keyWindow = window;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (keyWindow) break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (!keyWindow) {
|
|
43
|
+
keyWindow = [UIApplication sharedApplication].delegate.window;
|
|
44
|
+
}
|
|
45
|
+
return keyWindow.rootViewController;
|
|
46
|
+
}
|
|
47
|
+
|
|
27
48
|
RCT_CUSTOM_VIEW_PROPERTY(isEnabled, BOOL, UIView)
|
|
28
49
|
{
|
|
29
50
|
NSLog(@"RNSodyoSdkManager set isEnabled");
|
|
30
51
|
|
|
31
|
-
|
|
52
|
+
UIViewController *scanner = [RNSodyoScanner getSodyoScanner];
|
|
32
53
|
|
|
33
|
-
if (!
|
|
54
|
+
if (!scanner) {
|
|
34
55
|
return;
|
|
35
56
|
}
|
|
36
57
|
|
|
37
58
|
if ([RCTConvert BOOL:json]) {
|
|
38
|
-
[SodyoSDK startScanning:
|
|
59
|
+
[SodyoSDK startScanning:scanner];
|
|
39
60
|
return;
|
|
40
61
|
}
|
|
41
62
|
|
|
42
|
-
[SodyoSDK stopScanning:
|
|
63
|
+
[SodyoSDK stopScanning:scanner];
|
|
43
64
|
}
|
|
44
65
|
|
|
66
|
+
// Issue #13 fix: add false branch for troubleshooting toggle
|
|
45
67
|
RCT_CUSTOM_VIEW_PROPERTY(isTroubleShootingEnabled, BOOL, UIView)
|
|
46
68
|
{
|
|
47
69
|
NSLog(@"RNSodyoSdkManager set isTroubleShootingEnabled");
|
|
48
70
|
|
|
49
|
-
|
|
71
|
+
UIViewController *scanner = [RNSodyoScanner getSodyoScanner];
|
|
50
72
|
|
|
51
|
-
if (!
|
|
73
|
+
if (!scanner) {
|
|
52
74
|
return;
|
|
53
75
|
}
|
|
54
76
|
|
|
55
77
|
if ([RCTConvert BOOL:json]) {
|
|
56
|
-
[SodyoSDK startTroubleshoot:
|
|
78
|
+
[SodyoSDK startTroubleshoot:scanner];
|
|
57
79
|
return;
|
|
58
80
|
}
|
|
81
|
+
|
|
82
|
+
[SodyoSDK setMode:scanner mode:SodyoModeNormal];
|
|
59
83
|
}
|
|
60
84
|
|
|
61
85
|
- (UIView *)view
|
|
62
86
|
{
|
|
63
|
-
UIViewController *rootViewController = [
|
|
87
|
+
UIViewController *rootViewController = [self getRootViewController];
|
|
64
88
|
|
|
65
|
-
|
|
89
|
+
UIViewController *scanner = [SodyoSDK initSodyoScanner];
|
|
66
90
|
|
|
67
|
-
[RNSodyoScanner setSodyoScanner:
|
|
68
|
-
[rootViewController addChildViewController:
|
|
91
|
+
[RNSodyoScanner setSodyoScanner:scanner];
|
|
92
|
+
[rootViewController addChildViewController:scanner];
|
|
69
93
|
|
|
70
|
-
RNSodyoSdkView *view = [[RNSodyoSdkView alloc] initWithView:
|
|
94
|
+
RNSodyoSdkView *view = [[RNSodyoSdkView alloc] initWithView:scanner.view scanner:scanner];
|
|
71
95
|
|
|
72
96
|
[SodyoSDK setPresentingViewController:rootViewController];
|
|
73
|
-
[
|
|
97
|
+
[scanner didMoveToParentViewController:rootViewController];
|
|
74
98
|
|
|
75
99
|
return view;
|
|
76
100
|
}
|
|
77
101
|
|
|
78
|
-
@end
|
|
79
|
-
|
|
102
|
+
@end
|
package/ios/RNSodyoSdkView.h
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#import <UIKit/UIKit.h>
|
|
2
2
|
|
|
3
3
|
@interface RNSodyoSdkView : UIView
|
|
4
|
-
|
|
5
|
-
@
|
|
4
|
+
@property (nonatomic, strong) UIView *scannerView;
|
|
5
|
+
@property (nonatomic, weak) UIViewController *scannerViewController;
|
|
6
|
+
- (instancetype)initWithView:(UIView *)view scanner:(UIViewController *)scanner;
|
|
7
|
+
@end
|
package/ios/RNSodyoSdkView.m
CHANGED
|
@@ -2,27 +2,51 @@
|
|
|
2
2
|
|
|
3
3
|
@implementation RNSodyoSdkView
|
|
4
4
|
|
|
5
|
-
- (instancetype)initWithView:(UIView*)
|
|
5
|
+
- (instancetype)initWithView:(UIView *)view scanner:(UIViewController *)scanner {
|
|
6
6
|
NSLog(@"RNSodyoSdkView init");
|
|
7
7
|
self = [super init];
|
|
8
8
|
|
|
9
|
-
if (
|
|
10
|
-
|
|
9
|
+
if (self) {
|
|
10
|
+
_scannerView = view;
|
|
11
|
+
_scannerViewController = scanner;
|
|
12
|
+
[self addSubview:view];
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
return self;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
- (void)
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
- (void)willMoveToSuperview:(UIView *)newSuperview {
|
|
19
|
+
// Temporarily detach scanner view before Fabric re-parents us
|
|
20
|
+
if (_scannerView && _scannerView.superview == self) {
|
|
21
|
+
[_scannerView removeFromSuperview];
|
|
22
|
+
}
|
|
23
|
+
[super willMoveToSuperview:newSuperview];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
- (void)didMoveToSuperview {
|
|
27
|
+
[super didMoveToSuperview];
|
|
28
|
+
// Reattach scanner view after re-parenting is complete
|
|
29
|
+
if (_scannerView && self.superview && _scannerView.superview != self) {
|
|
30
|
+
[self addSubview:_scannerView];
|
|
31
|
+
_scannerView.frame = self.bounds;
|
|
32
|
+
}
|
|
19
33
|
}
|
|
20
34
|
|
|
21
|
-
- (void)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
- (void)layoutSubviews {
|
|
36
|
+
[super layoutSubviews];
|
|
37
|
+
for (UIView *view in self.subviews) {
|
|
38
|
+
[view setFrame:self.bounds];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Issue #12 fix: remove child view controller on cleanup
|
|
43
|
+
- (void)removeFromSuperview {
|
|
44
|
+
if (_scannerViewController) {
|
|
45
|
+
[_scannerViewController willMoveToParentViewController:nil];
|
|
46
|
+
[_scannerViewController removeFromParentViewController];
|
|
47
|
+
_scannerViewController = nil;
|
|
48
|
+
}
|
|
49
|
+
[super removeFromSuperview];
|
|
26
50
|
}
|
|
27
51
|
|
|
28
|
-
@end
|
|
52
|
+
@end
|