@sodyo/react-native-sodyo-sdk 4.0.0 → 5.0.0
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/README.md +2 -2
- package/RNSodyoSdk.podspec +2 -2
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/sodyo/RNSodyoSdk/RNSodyoSdkModule.java +9 -0
- package/android/src/main/java/com/sodyo/RNSodyoSdk/RNSodyoSdkView.java +56 -53
- package/ios/RNSodyoSdk.m +6 -0
- package/ios/RNSodyoSdkManager.m +1 -1
- package/package.json +2 -2
- package/sodyosdk.d.ts +1 -0
- package/sodyosdk.js +5 -1
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
# React Native Sodyo SDK Plugin that wraps Sodyo sdk for Android and iOS
|
|
3
3
|
|
|
4
|
-
[SodyoSDK for iOS](https://github.com/sodyo-ltd/SodyoSDKPod)
|
|
4
|
+
[SodyoSDK for iOS](https://github.com/sodyo-ltd/SodyoSDKPod) 3.68.04
|
|
5
5
|
|
|
6
|
-
[SodyoSDK for Android](https://search.maven.org/search?q=a:sodyo-android-sdk) 3.
|
|
6
|
+
[SodyoSDK for Android](https://search.maven.org/search?q=a:sodyo-android-sdk) 3.69.10
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
## Install
|
package/RNSodyoSdk.podspec
CHANGED
|
@@ -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 => "
|
|
15
|
+
s.source = { :git => "https://github.com/sodyo-ltd/SodyoSDKPod", :commit => "65b38d6" }
|
|
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.
|
|
20
|
+
s.dependency "SodyoSDK", "3.68.04"
|
|
21
21
|
end
|
|
22
22
|
|
package/android/build.gradle
CHANGED
|
@@ -55,7 +55,7 @@ repositories {
|
|
|
55
55
|
|
|
56
56
|
dependencies {
|
|
57
57
|
implementation ('com.facebook.react:react-native:+')
|
|
58
|
-
implementation ('com.sodyo:sodyo-android-sdk:3.
|
|
58
|
+
implementation ('com.sodyo:sodyo-android-sdk:3.69.10') {
|
|
59
59
|
transitive = true
|
|
60
60
|
exclude group: 'com.parse.bolts', module: 'bolts-android'
|
|
61
61
|
}
|
|
@@ -288,6 +288,15 @@ public class RNSodyoSdkModule extends ReactContextBaseJavaModule {
|
|
|
288
288
|
Sodyo.stopScanning();
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
+
@ReactMethod
|
|
292
|
+
public void setDynamicProfile(ReadableMap profile) {
|
|
293
|
+
Log.i(TAG, "setDynamicProfile()");
|
|
294
|
+
if (profile != null) {
|
|
295
|
+
HashMap<String, Object> profileMap = new HashMap<>(ConversionUtil.toMap(profile));
|
|
296
|
+
Sodyo.setDynamicProfile(profileMap);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
291
300
|
@ReactMethod
|
|
292
301
|
public void setDynamicProfileValue(String key, String value) {
|
|
293
302
|
Log.i(TAG, "setDynamicProfileValue()");
|
|
@@ -1,110 +1,113 @@
|
|
|
1
1
|
package com.sodyo.RNSodyoSDK;
|
|
2
2
|
|
|
3
|
-
import androidx.annotation.NonNull;
|
|
4
|
-
import androidx.annotation.Nullable;
|
|
5
|
-
import androidx.fragment.app.Fragment;
|
|
6
|
-
import androidx.fragment.app.FragmentActivity;
|
|
7
|
-
import androidx.fragment.app.FragmentManager;
|
|
8
|
-
import androidx.fragment.app.FragmentTransaction;
|
|
9
|
-
|
|
10
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
11
3
|
import com.facebook.react.uimanager.SimpleViewManager;
|
|
12
4
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
13
6
|
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
14
7
|
|
|
15
8
|
import android.util.Log;
|
|
16
9
|
import android.widget.FrameLayout;
|
|
10
|
+
import android.app.Fragment;
|
|
11
|
+
import android.app.FragmentManager;
|
|
12
|
+
import android.app.FragmentTransaction;
|
|
13
|
+
import android.app.Activity;
|
|
14
|
+
|
|
15
|
+
import javax.annotation.Nullable;
|
|
17
16
|
|
|
18
17
|
import com.sodyo.sdk.SodyoScannerFragment;
|
|
19
18
|
|
|
19
|
+
@SuppressWarnings("deprecation")
|
|
20
20
|
public class RNSodyoSdkView extends SimpleViewManager<FrameLayout> {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
static final String TAG = "RNSodyoSdkView";
|
|
22
|
+
|
|
23
|
+
static final String TAG_FRAGMENT = "SODYO_SCANNER";
|
|
24
|
+
|
|
23
25
|
public static final String REACT_CLASS = "RNSodyoSdkView";
|
|
24
26
|
|
|
25
27
|
private final @Nullable ReactApplicationContext mCallerContext;
|
|
28
|
+
|
|
26
29
|
private @Nullable SodyoScannerFragment sodyoFragment;
|
|
27
|
-
private boolean isCameraEnabled = true;
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
mCallerContext = callerContext;
|
|
31
|
-
}
|
|
31
|
+
private boolean isCameraEnabled = true;
|
|
32
32
|
|
|
33
|
-
@NonNull
|
|
34
33
|
@Override
|
|
35
34
|
public String getName() {
|
|
36
35
|
return REACT_CLASS;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
|
|
38
|
+
public RNSodyoSdkView(ReactApplicationContext callerContext) {
|
|
39
|
+
mCallerContext = callerContext;
|
|
40
|
+
}
|
|
41
|
+
|
|
40
42
|
@Override
|
|
41
|
-
public FrameLayout createViewInstance(
|
|
42
|
-
Log.i(TAG,
|
|
43
|
+
public FrameLayout createViewInstance(ThemedReactContext context) {
|
|
44
|
+
Log.i(TAG,"createViewInstance");
|
|
43
45
|
|
|
44
46
|
final FrameLayout view = new FrameLayout(context);
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
Activity currentActivity = mCallerContext.getCurrentActivity();
|
|
47
49
|
if (currentActivity == null) {
|
|
48
50
|
Log.e(TAG, "Current activity is null, cannot initialize SodyoScannerFragment");
|
|
49
51
|
return view;
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
FragmentManager fragmentManager = currentActivity.getFragmentManager();
|
|
55
|
+
|
|
56
|
+
// Clean up any previously added fragment to avoid "Fragment already added"
|
|
57
|
+
Fragment existing = fragmentManager.findFragmentByTag(TAG_FRAGMENT);
|
|
58
|
+
if (existing != null) {
|
|
59
|
+
Log.w(TAG, "Removing existing SodyoScannerFragment before re-adding");
|
|
60
|
+
fragmentManager.beginTransaction().remove(existing).commitNowAllowingStateLoss();
|
|
55
61
|
}
|
|
56
62
|
|
|
57
|
-
|
|
58
|
-
|
|
63
|
+
Log.i(TAG,"init SodyoScannerFragment");
|
|
64
|
+
sodyoFragment = new SodyoScannerFragment();
|
|
59
65
|
|
|
66
|
+
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
|
60
67
|
fragmentTransaction.add(sodyoFragment, TAG_FRAGMENT).commitAllowingStateLoss();
|
|
61
68
|
fragmentManager.executePendingTransactions();
|
|
62
69
|
|
|
63
|
-
view.addView(sodyoFragment.getView(),
|
|
64
|
-
FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
|
|
70
|
+
view.addView(sodyoFragment.getView(), FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
|
|
65
71
|
return view;
|
|
66
72
|
}
|
|
67
73
|
|
|
68
74
|
@Override
|
|
69
|
-
public void onDropViewInstance(
|
|
75
|
+
public void onDropViewInstance(FrameLayout view) {
|
|
70
76
|
super.onDropViewInstance(view);
|
|
71
77
|
|
|
72
|
-
Log.i(TAG,
|
|
78
|
+
Log.i(TAG,"onDropViewInstance");
|
|
73
79
|
|
|
74
80
|
sodyoFragment = null;
|
|
75
81
|
isCameraEnabled = true;
|
|
76
82
|
|
|
77
83
|
try {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
fragmentManager.beginTransaction().remove(fragment).commitAllowingStateLoss();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
84
|
+
FragmentManager fragmentManager = mCallerContext.getCurrentActivity().getFragmentManager();
|
|
85
|
+
Fragment fragment = fragmentManager.findFragmentByTag(TAG_FRAGMENT);
|
|
86
|
+
|
|
87
|
+
if (fragment != null) {
|
|
88
|
+
fragmentManager.beginTransaction().remove(fragment).commitNowAllowingStateLoss();
|
|
89
|
+
}
|
|
87
90
|
} catch (Exception e) {
|
|
88
|
-
|
|
91
|
+
e.printStackTrace();
|
|
89
92
|
}
|
|
90
93
|
}
|
|
91
94
|
|
|
92
|
-
@ReactProp(name = "isEnabled", defaultBoolean
|
|
95
|
+
@ReactProp(name = "isEnabled", defaultBoolean=true)
|
|
93
96
|
public void setIsEnabled(FrameLayout view, boolean isEnabled) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (isEnabled && !isCameraEnabled) {
|
|
99
|
-
Log.i(TAG, "start camera");
|
|
100
|
-
isCameraEnabled = true;
|
|
101
|
-
sodyoFragment.startCamera();
|
|
102
|
-
}
|
|
97
|
+
if (sodyoFragment == null) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
103
100
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
101
|
+
if (isEnabled && !isCameraEnabled) {
|
|
102
|
+
Log.i(TAG,"start camera");
|
|
103
|
+
isCameraEnabled = true;
|
|
104
|
+
sodyoFragment.startCamera();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!isEnabled && isCameraEnabled) {
|
|
108
|
+
Log.i(TAG,"stop camera");
|
|
109
|
+
isCameraEnabled = false;
|
|
110
|
+
sodyoFragment.stopCamera();
|
|
111
|
+
}
|
|
109
112
|
}
|
|
110
113
|
}
|
package/ios/RNSodyoSdk.m
CHANGED
|
@@ -77,6 +77,12 @@ RCT_EXPORT_METHOD(addScannerParam:(NSString *) key value:(NSString *) value)
|
|
|
77
77
|
[SodyoSDK addScannerParams:key value:value];
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
RCT_EXPORT_METHOD(setDynamicProfile:(NSDictionary *) profile)
|
|
81
|
+
{
|
|
82
|
+
NSLog(@"setDynamicProfile");
|
|
83
|
+
[SodyoSDK setDynamicProfile:profile];
|
|
84
|
+
}
|
|
85
|
+
|
|
80
86
|
RCT_EXPORT_METHOD(setDynamicProfileValue:(NSString *) key value:(NSString *) value)
|
|
81
87
|
{
|
|
82
88
|
NSLog(@"setDynamicProfileValue");
|
package/ios/RNSodyoSdkManager.m
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sodyo/react-native-sodyo-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "RNSodyoSdk",
|
|
5
5
|
"main": "sodyosdk.js",
|
|
6
6
|
"typings": "./sodyosdk.d.ts",
|
|
@@ -22,6 +22,6 @@
|
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"homepage": "https://www.sodyo.com",
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"react-native": "^0.
|
|
25
|
+
"react-native": "^0.69.12"
|
|
26
26
|
}
|
|
27
27
|
}
|
package/sodyosdk.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ declare const _default: {
|
|
|
14
14
|
setUserInfo (userInfo: { [key: string]: string | number }): void
|
|
15
15
|
setScannerParams (scannerPreferences: { [key: string]: string }): void
|
|
16
16
|
addScannerParam (key: string, value: string): void
|
|
17
|
+
setDynamicProfile (profile: { [key: string]: any }): void,
|
|
17
18
|
setDynamicProfileValue (key: string, value: string): void
|
|
18
19
|
setCustomAdLabel (label: string): void
|
|
19
20
|
setAppUserId (appUserId: string): void
|
package/sodyosdk.js
CHANGED
|
@@ -161,6 +161,10 @@ export default {
|
|
|
161
161
|
return RNSodyoSdk.setDynamicProfileValue(key, value);
|
|
162
162
|
},
|
|
163
163
|
|
|
164
|
+
setDynamicProfile: (profile) => {
|
|
165
|
+
return RNSodyoSdk.setDynamicProfile(profile);
|
|
166
|
+
},
|
|
167
|
+
|
|
164
168
|
setCustomAdLabel: (label) => {
|
|
165
169
|
return RNSodyoSdk.setCustomAdLabel(label);
|
|
166
170
|
},
|
|
@@ -196,7 +200,7 @@ export class Scanner extends Component {
|
|
|
196
200
|
isTroubleShootingEnabled: false,
|
|
197
201
|
};
|
|
198
202
|
|
|
199
|
-
componentDidUpdate(prevProps
|
|
203
|
+
componentDidUpdate(prevProps, prevState, snapshot) {
|
|
200
204
|
if (this.props.isTroubleShootingEnabled) {
|
|
201
205
|
if (Platform.OS !== 'ios') {
|
|
202
206
|
return RNSodyoSdk.startTroubleshoot()
|