@sodyo/react-native-sodyo-sdk 3.4.0 → 3.6.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.
@@ -12,11 +12,11 @@ Pod::Spec.new do |s|
12
12
  s.author = package['author']
13
13
  s.homepage = package['homepage']
14
14
  s.platform = :ios, "11.0"
15
- s.source = { :git => "https://github.com/sodyo-ltd/SodyoSDKPod", :commit => "0f595bd" }
15
+ s.source = { :git => "https://github.com/sodyo-ltd/SodyoSDKPod", :commit => "43303e7" }
16
16
  s.source_files = "ios/**/*.{h,m}"
17
17
  s.requires_arc = true
18
18
 
19
19
  s.dependency "React"
20
- s.dependency "SodyoSDK", "3.54.28"
20
+ s.dependency "SodyoSDK", "3.55.01"
21
21
  end
22
22
 
@@ -51,11 +51,14 @@ android {
51
51
 
52
52
  repositories {
53
53
  mavenCentral()
54
+ maven {
55
+ url 'http://172.28.2.86:8082/artifactory/local-release-qa'
56
+ }
54
57
  }
55
58
 
56
59
  dependencies {
57
60
  implementation ('com.facebook.react:react-native:+')
58
- implementation ('com.sodyo:sodyo-android-sdk:3.54.39') {
61
+ implementation ('com.sodyo:sodyo-android-sdk:3.55.02@aar') {
59
62
  transitive = true
60
63
  exclude group: 'com.parse.bolts', module: 'bolts-android'
61
64
  }
@@ -31,6 +31,8 @@ import com.sodyo.sdk.SodyoInitCallback;
31
31
  import com.sodyo.sdk.SodyoScannerActivity;
32
32
  import com.sodyo.sdk.SodyoScannerCallback;
33
33
  import com.sodyo.sdk.SodyoMarkerContentCallback;
34
+ import com.sodyo.sdk.SodyoModeCallback;
35
+ import com.sodyo.app_sdk.data.SettingsHelper;
34
36
 
35
37
  public class RNSodyoSdkModule extends ReactContextBaseJavaModule {
36
38
  public static enum SodyoEnv {
@@ -78,7 +80,7 @@ public class RNSodyoSdkModule extends ReactContextBaseJavaModule {
78
80
  return "RNSodyoSdk";
79
81
  }
80
82
 
81
- private class SodyoCallback implements SodyoScannerCallback, SodyoInitCallback, SodyoMarkerContentCallback {
83
+ private class SodyoCallback implements SodyoScannerCallback, SodyoInitCallback, SodyoMarkerContentCallback, SodyoModeCallback {
82
84
 
83
85
  private Callback successCallback;
84
86
  private Callback errorCallback;
@@ -106,6 +108,7 @@ public class RNSodyoSdkModule extends ReactContextBaseJavaModule {
106
108
  SodyoCallback callbackClosure = new SodyoCallback(null, null);
107
109
  Sodyo.getInstance().setSodyoScannerCallback(callbackClosure);
108
110
  Sodyo.getInstance().setSodyoMarkerContentCallback(callbackClosure);
111
+ Sodyo.getInstance().setSodyoModeCallback(callbackClosure);
109
112
  }
110
113
 
111
114
  /**
@@ -185,6 +188,21 @@ public class RNSodyoSdkModule extends ReactContextBaseJavaModule {
185
188
 
186
189
  sendEvent("EventMarkerContent", params);
187
190
  }
191
+
192
+ /**
193
+ * SodyoModeCallback implementation
194
+ */
195
+ @Override
196
+ public void onModeChange(SettingsHelper.ScannerViewMode oldMode, SettingsHelper.ScannerViewMode newMode) {
197
+ Log.i(TAG, "onModeChange()");
198
+
199
+ WritableMap params = Arguments.createMap();
200
+
201
+ params.putString("oldMode", oldMode.toString());
202
+ params.putString("newMode", newMode.toString());
203
+
204
+ sendEvent("ModeChangeCallback", params);
205
+ }
188
206
  }
189
207
 
190
208
  @ReactMethod
@@ -271,6 +289,32 @@ public class RNSodyoSdkModule extends ReactContextBaseJavaModule {
271
289
  Sodyo.performMarker(markerId, activity);
272
290
  }
273
291
 
292
+ @ReactMethod
293
+ public void startTroubleshoot() {
294
+ Log.i(TAG, "startTroubleshoot()");
295
+ Activity activity = getCurrentActivity();
296
+ Sodyo.startTroubleshoot(activity);
297
+ }
298
+
299
+ @ReactMethod
300
+ public void setTroubleshootMode() {
301
+ Log.i(TAG, "setTroubleshootMode()");
302
+ Activity activity = getCurrentActivity();
303
+ Sodyo.setMode(activity, SettingsHelper.ScannerViewMode.Troubleshoot);
304
+ }
305
+
306
+ @ReactMethod
307
+ public void setNormalMode() {
308
+ Log.i(TAG, "setNormalMode()");
309
+ Activity activity = getCurrentActivity();
310
+ Sodyo.setMode(activity, SettingsHelper.ScannerViewMode.Normal);
311
+ }
312
+
313
+ @ReactMethod
314
+ public SettingsHelper.ScannerViewMode getMode() {
315
+ return Sodyo.getMode();
316
+ }
317
+
274
318
  @ReactMethod
275
319
  public void setSodyoLogoVisible(Boolean isVisible) {
276
320
  Log.i(TAG, "setSodyoLogoVisible()");
@@ -0,0 +1,19 @@
1
+ //
2
+ // RNSodyoScanner.h
3
+ // Pods
4
+ //
5
+ // Created by Bogdan on 20.06.2022.
6
+ //
7
+
8
+ #ifndef RNSodyoScanner_h
9
+ #define RNSodyoScanner_h
10
+
11
+
12
+ #endif /* RNSodyoScanner_h */
13
+
14
+ static UIViewController* sodyoScanner = nil;
15
+
16
+ @interface RNSodyoScanner : NSObject
17
+ + (UIViewController *)getSodyoScanner;
18
+ + (void)setSodyoScanner:(UIViewController *)sodyoScanner;
19
+ @end
@@ -0,0 +1,23 @@
1
+ //
2
+ // RNSodyoCallback.m
3
+ // RNSodyoSdk
4
+ //
5
+ // Created by Bogdan on 20.06.2022.
6
+ //
7
+ #import "RNSodyoScanner.h"
8
+ #import <Foundation/Foundation.h>
9
+
10
+ @implementation RNSodyoScanner
11
+
12
+ + (UIViewController *) getSodyoScanner {
13
+ return sodyoScanner;
14
+ }
15
+
16
+ + (void) setSodyoScanner:(UIViewController*) newSodyoScanner {
17
+ if(sodyoScanner != newSodyoScanner) {
18
+ sodyoScanner = newSodyoScanner;
19
+ }
20
+ }
21
+
22
+ @end
23
+ // implementation of getter and setter
package/ios/RNSodyoSdk.m CHANGED
@@ -1,5 +1,6 @@
1
1
 
2
2
  #import "RNSodyoSdk.h"
3
+ #import "RNSodyoScanner.h"
3
4
 
4
5
  @implementation RNSodyoSdk
5
6
 
@@ -90,6 +91,30 @@ RCT_EXPORT_METHOD(performMarker:(NSString *) markerId)
90
91
  [SodyoSDK performMarker:markerId];
91
92
  }
92
93
 
94
+ RCT_EXPORT_METHOD(startTroubleshoot)
95
+ {
96
+ NSLog(@"startTroubleshoot");
97
+
98
+ [SodyoSDK startTroubleshoot:sodyoScanner];
99
+ }
100
+
101
+
102
+ RCT_EXPORT_METHOD(setTroubleshootMode)
103
+ {
104
+ NSLog(@"setTroubleshootMode");
105
+ sodyoScanner = [RNSodyoScanner getSodyoScanner];
106
+
107
+ [SodyoSDK setMode:sodyoScanner mode:SodyoModeTroubleshoot];
108
+ }
109
+
110
+ RCT_EXPORT_METHOD(setNormalMode)
111
+ {
112
+ NSLog(@"setNormalMode");
113
+ sodyoScanner = [RNSodyoScanner getSodyoScanner];
114
+
115
+ [SodyoSDK setMode:sodyoScanner mode:SodyoModeNormal];
116
+ }
117
+
93
118
  RCT_EXPORT_METHOD(setSodyoLogoVisible:(BOOL *) isVisible)
94
119
  {
95
120
  NSLog(@"setSodyoLogoVisible");
@@ -111,13 +136,16 @@ RCT_EXPORT_METHOD(setEnv:(NSString *) env)
111
136
 
112
137
  - (NSArray<NSString *> *)supportedEvents
113
138
  {
114
- return @[@"EventSodyoError", @"EventMarkerDetectSuccess", @"EventMarkerDetectError", @"EventMarkerContent", @"EventCloseSodyoContent"];
139
+ return @[@"EventSodyoError", @"EventMarkerDetectSuccess", @"EventMarkerDetectError", @"EventMarkerContent", @"EventCloseSodyoContent", @"ModeChangeCallback"];
115
140
  }
116
141
 
117
142
  - (void) launchSodyoScanner {
118
143
  NSLog(@"launchSodyoScanner");
119
- if (!self->sodyoScanner) {
120
- self->sodyoScanner = [SodyoSDK initSodyoScanner];
144
+ sodyoScanner = [RNSodyoScanner getSodyoScanner];
145
+
146
+
147
+ if (!sodyoScanner) {
148
+ [RNSodyoScanner setSodyoScanner:sodyoScanner];
121
149
  }
122
150
 
123
151
  if (sodyoScanner.isViewLoaded && sodyoScanner.view.window) {
@@ -142,6 +170,17 @@ RCT_EXPORT_METHOD(setEnv:(NSString *) env)
142
170
  [self sendEventWithName:@"EventCloseSodyoContent" body:nil];
143
171
  }
144
172
 
173
+ - (NSString *) convertScannerModeToString:(SodyoMode)mode {
174
+ switch (mode) {
175
+ case SodyoModeTroubleshoot:
176
+ return @"Troubleshoot";
177
+ case SodyoModeNormal:
178
+ return @"Normal";
179
+ default:
180
+ return @"";
181
+ }
182
+ }
183
+
145
184
  #pragma mark - SodyoSDKDelegate
146
185
  - (void) onSodyoAppLoadSuccess:(NSInteger)AppID {
147
186
  NSLog(@"onSodyoAppLoadSuccess");
@@ -177,4 +216,14 @@ RCT_EXPORT_METHOD(setEnv:(NSString *) env)
177
216
  NSLog(@"SodyoMarkerDetectedWithData: %@", Data);
178
217
  [self sendEventWithName:@"EventMarkerContent" body:@{@"markerId": markerId, @"data": Data}];
179
218
  }
219
+
220
+
221
+ - (void) onModeChange:(SodyoMode)from to:(SodyoMode)to {
222
+ NSLog(@"onModeChange");
223
+ NSString* fromConverted = [self convertScannerModeToString:from];
224
+ NSString* toConverted = [self convertScannerModeToString:to];
225
+
226
+ [self sendEventWithName:@"ModeChangeCallback" body:@{@"oldMode": fromConverted, @"newMode": toConverted}];
227
+ }
228
+
180
229
  @end
@@ -14,9 +14,9 @@
14
14
 
15
15
  #import <UIKit/UIKit.h>
16
16
  #import "RNSodyoSdkView.m"
17
+ #import "RNSodyoScanner.h"
17
18
 
18
19
  @interface RNSodyoSdkManager : RCTViewManager {
19
- UIViewController *sodyoScanner;
20
20
  }
21
21
  @end
22
22
 
@@ -28,23 +28,43 @@ RCT_CUSTOM_VIEW_PROPERTY(isEnabled, BOOL, UIView)
28
28
  {
29
29
  NSLog(@"RNSodyoSdkManager set isEnabled");
30
30
 
31
- if (!self->sodyoScanner) {
31
+ sodyoScanner = [RNSodyoScanner getSodyoScanner];
32
+
33
+ if (!sodyoScanner) {
32
34
  return;
33
35
  }
34
36
 
35
37
  if ([RCTConvert BOOL:json]) {
36
- [SodyoSDK startScanning:self->sodyoScanner];
38
+ [SodyoSDK startScanning:sodyoScanner];
37
39
  return;
38
40
  }
39
41
 
40
- [SodyoSDK stopScanning:self->sodyoScanner];
42
+ [SodyoSDK stopScanning:sodyoScanner];
43
+ }
44
+
45
+ RCT_CUSTOM_VIEW_PROPERTY(isTroubleShootingEnabled, BOOL, UIView)
46
+ {
47
+ NSLog(@"RNSodyoSdkManager set isTroubleShootingEnabled");
48
+
49
+ sodyoScanner = [RNSodyoScanner getSodyoScanner];
50
+
51
+ if (!sodyoScanner) {
52
+ return;
53
+ }
54
+
55
+ if ([RCTConvert BOOL:json]) {
56
+ [SodyoSDK startTroubleshoot:sodyoScanner];
57
+ return;
58
+ }
41
59
  }
42
60
 
43
61
  - (UIView *)view
44
62
  {
45
63
  UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
46
64
 
47
- self->sodyoScanner = [SodyoSDK initSodyoScanner];
65
+ sodyoScanner = [SodyoSDK initSodyoScanner];
66
+
67
+ [RNSodyoScanner setSodyoScanner:sodyoScanner];
48
68
  [rootViewController addChildViewController:sodyoScanner];
49
69
 
50
70
  RNSodyoSdkView *view = [[RNSodyoSdkView alloc] initWithView:sodyoScanner.view];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sodyo/react-native-sodyo-sdk",
3
- "version": "3.4.0",
3
+ "version": "3.6.1",
4
4
  "description": "RNSodyoSdk",
5
5
  "main": "sodyosdk.js",
6
6
  "typings": "./sodyosdk.d.ts",
package/sodyosdk.d.ts CHANGED
@@ -17,13 +17,19 @@ declare const _default: {
17
17
  setAppUserId (appUserId: string): void
18
18
  removeAllListeners (eventType?: string): void
19
19
  onMarkerContent (callback: (markerId: string, data: { [key: string]: any }) => void): () => void,
20
+ onModeChange (callback: (data: { [key: string]: any }) => void): () => void,
20
21
  performMarker (markerId: string): void,
22
+ startTroubleshoot (): void,
21
23
  setSodyoLogoVisible (isVisible: boolean): void,
24
+ setTroubleshootMode (): void,
25
+ setNormalMode (): void,
26
+ getMode (): EScannerViewMode,
22
27
  setEnv(env: TEnv): void,
23
28
  }
24
29
 
25
30
  interface IScannerProps {
26
31
  isEnabled?: boolean
32
+ isTroubleShootingEnabled?: boolean
27
33
  }
28
34
 
29
35
  export declare class Scanner extends React.PureComponent<IScannerProps> {
@@ -33,4 +39,10 @@ export declare const SODYO_ENV: {
33
39
  [key in TEnv]: TEnv
34
40
  }
35
41
 
42
+ export enum EScannerViewMode {
43
+ Normal = 'Normal',
44
+ Troubleshoot = 'Troubleshoot',
45
+ DeviceTester = 'DeviceTester'
46
+ }
47
+
36
48
  export default _default
package/sodyosdk.js CHANGED
@@ -66,6 +66,20 @@ export default {
66
66
  };
67
67
  },
68
68
 
69
+ onModeChange: (callback) => {
70
+ eventEmitter.removeAllListeners('ModeChangeCallback');
71
+
72
+ const subscription = eventEmitter.addListener('ModeChangeCallback', (e) => {
73
+ if (typeof callback === 'function') {
74
+ callback(e);
75
+ }
76
+ });
77
+
78
+ return () => {
79
+ return subscription.remove();
80
+ };
81
+ },
82
+
69
83
  onCloseContent: (callback) => {
70
84
  if (Platform.OS !== 'ios') {
71
85
  return () => undefined;
@@ -89,6 +103,10 @@ export default {
89
103
  return RNSodyoSdk.performMarker(markerId);
90
104
  },
91
105
 
106
+ startTroubleshoot: () => {
107
+ return RNSodyoSdk.startTroubleshoot();
108
+ },
109
+
92
110
  start: (successCallback, errorCallback) => {
93
111
  eventEmitter.removeAllListeners('EventMarkerDetectSuccess');
94
112
  eventEmitter.removeAllListeners('EventMarkerDetectError');
@@ -147,29 +165,51 @@ export default {
147
165
  return RNSodyoSdk.setSodyoLogoVisible(isVisible);
148
166
  },
149
167
 
168
+ setTroubleshootMode: () => {
169
+ return RNSodyoSdk.setTroubleshootMode();
170
+ },
171
+
172
+ setNormalMode: () => {
173
+ return RNSodyoSdk.setNormalMode();
174
+ },
175
+
150
176
  setEnv: (env) => {
151
177
  return RNSodyoSdk.setEnv(env);
152
178
  },
179
+
180
+ getMode: () => {
181
+ return RNSodyoSdk.getMode();
182
+ },
153
183
  };
154
184
 
155
185
  export class Scanner extends Component {
156
186
  static defaultProps = {
157
187
  isEnabled: true,
188
+ isTroubleShootingEnabled: false,
158
189
  };
159
190
 
191
+ componentDidUpdate(prevProps: Readonly<P>, prevState: Readonly<S>, snapshot: SS) {
192
+ if (this.props.isTroubleShootingEnabled) {
193
+ if (Platform.OS !== 'ios') {
194
+ return RNSodyoSdk.startTroubleshoot()
195
+ }
196
+ }
197
+ }
198
+
160
199
  render () {
161
- const { isEnabled, children } = this.props;
200
+ const { isEnabled, isTroubleShootingEnabled, children } = this.props;
162
201
  return (
163
- <Fragment>
164
- <RNSodyoSdkView
165
- isEnabled={isEnabled}
166
- style={{ height: '100%', width: '100%' }}
167
- />
168
-
169
- <View style={styles.container} pointerEvents="box-none">
170
- {children}
171
- </View>
172
- </Fragment>
202
+ <Fragment>
203
+ <RNSodyoSdkView
204
+ isEnabled={isEnabled}
205
+ isTroubleShootingEnabled={isTroubleShootingEnabled}
206
+ style={{ height: '100%', width: '100%' }}
207
+ />
208
+
209
+ <View style={styles.container} pointerEvents="box-none">
210
+ {children}
211
+ </View>
212
+ </Fragment>
173
213
  );
174
214
  }
175
215
  }