@@ -40,7 +40,6 @@ class AnylineSDKPlugin extends ReactContextBaseJavaModule implements ResultRepor
40
40
}
41
41
42
42
public static final String REACT_CLASS = "AnylineSDKPlugin" ;
43
- public static final String EXTRA_LICENSE_KEY = "EXTRA_LICENSE_KEY" ;
44
43
public static final String EXTRA_CONFIG_JSON = "EXTRA_CONFIG_JSON" ;
45
44
public static final String EXTRA_SCANVIEW_INITIALIZATION_PARAMETERS = "EXTRA_SCANVIEW_INITIALIZATION_PARAMETERS" ;
46
45
public static final String EXTRA_SCAN_MODE = "EXTRA_SCAN_MODE" ;
@@ -100,6 +99,11 @@ public void licenseKeyExpiryDate(final Promise promise) {
100
99
}
101
100
}
102
101
102
+ @ ReactMethod
103
+ public void isInitialized (final Promise promise ) {
104
+ promise .resolve (AnylineSdk .isInitialized ());
105
+ }
106
+
103
107
@ ReactMethod
104
108
@ Deprecated
105
109
public void setupScanViewWithConfigJson (String config , String scanMode , Callback onResultReact , Callback onErrorReact ) {
@@ -315,19 +319,17 @@ private void scan() throws LicenseException, JSONException {
315
319
316
320
Intent intent = new Intent (getCurrentActivity (), ScanActivity .class );
317
321
318
- configObject = new JSONObject (this .config );
319
-
320
- if (this .license == null || this .license .isEmpty ()) {
321
- if (configObject .has ("license" )) {
322
- //if there is a license on JSON config then this license will be
323
- //used to init or re-init the SDK
324
- AnylineSdk .init (configObject .getString ("license" ), reactContext , "" , CacheConfig .Preset .Default .INSTANCE , wrapperConfig );
325
- license = configObject .get ("license" ).toString ();
326
- } else {
327
- throw new JSONException ("No License in config. Please check your configuration." );
322
+ if (!AnylineSdk .isInitialized ()) {
323
+ if (this .license != null ) {
324
+ AnylineSdk .init (this .license , reactContext , "" , CacheConfig .Preset .Default .INSTANCE , wrapperConfig );
325
+ }
326
+ else {
327
+ throw new JSONException ("SDK is not initialized. Please initialize SDK before scanning." );
328
328
}
329
329
}
330
330
331
+ configObject = new JSONObject (this .config );
332
+
331
333
JSONObject optionsJSONObject = configObject .optJSONObject ("options" );
332
334
333
335
if (optionsJSONObject != null ) {
@@ -337,7 +339,6 @@ private void scan() throws LicenseException, JSONException {
337
339
);
338
340
}
339
341
340
- intent .putExtra (EXTRA_LICENSE_KEY , license );
341
342
intent .putExtra (EXTRA_CONFIG_JSON , configObject .toString ());
342
343
intent .putExtra (EXTRA_SCANVIEW_INITIALIZATION_PARAMETERS , scanViewInitializationParameters );
343
344
0 commit comments