react-native-okhi 1.2.31 → 1.2.32-beta.2
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/LICENSE +1 -1
- package/README.md +34 -4
- package/ReactNativeOkhi.podspec +21 -0
- package/android/build.gradle +38 -99
- package/android/gradle.properties +3 -3
- package/android/src/main/AndroidManifest.xml +1 -3
- package/android/src/main/java/com/okhi/OkhiModule.kt +336 -0
- package/android/src/main/java/com/okhi/OkhiPackage.kt +33 -0
- package/ios/OkHiWrapper.swift +348 -0
- package/ios/Okhi.h +5 -0
- package/ios/Okhi.mm +170 -0
- package/lib/commonjs/NativeOkhi.js +9 -0
- package/lib/commonjs/NativeOkhi.js.map +1 -0
- package/lib/commonjs/index.js +234 -28
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/NativeOkhi.js +5 -0
- package/lib/module/NativeOkhi.js.map +1 -0
- package/lib/module/index.js +221 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeOkhi.d.ts +25 -0
- package/lib/typescript/commonjs/src/NativeOkhi.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +22 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types.d.ts +81 -0
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeOkhi.d.ts +25 -0
- package/lib/typescript/module/src/NativeOkhi.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +22 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/types.d.ts +81 -0
- package/lib/typescript/module/src/types.d.ts.map +1 -0
- package/package.json +91 -112
- package/src/NativeOkhi.ts +68 -0
- package/src/index.tsx +271 -3
- package/src/types.ts +90 -0
- package/android/src/main/java/com/reactnativeokhi/OkhiModule.java +0 -389
- package/android/src/main/java/com/reactnativeokhi/OkhiPackage.java +0 -28
- package/ios/OkHiExtension.swift +0 -27
- package/ios/OkHiStruct.swift +0 -29
- package/ios/Okhi-Bridging-Header.h +0 -3
- package/ios/Okhi.m +0 -62
- package/ios/Okhi.swift +0 -325
- package/ios/Okhi.xcodeproj/project.pbxproj +0 -283
- package/lib/commonjs/OkCollect/Helpers.js +0 -40
- package/lib/commonjs/OkCollect/Helpers.js.map +0 -1
- package/lib/commonjs/OkCollect/OkHiLocationManager.js +0 -305
- package/lib/commonjs/OkCollect/OkHiLocationManager.js.map +0 -1
- package/lib/commonjs/OkCollect/Spinner.js +0 -27
- package/lib/commonjs/OkCollect/Spinner.js.map +0 -1
- package/lib/commonjs/OkCollect/Util.js +0 -226
- package/lib/commonjs/OkCollect/Util.js.map +0 -1
- package/lib/commonjs/OkCollect/app.json +0 -4
- package/lib/commonjs/OkCollect/index.js +0 -47
- package/lib/commonjs/OkCollect/index.js.map +0 -1
- package/lib/commonjs/OkCollect/types.js +0 -6
- package/lib/commonjs/OkCollect/types.js.map +0 -1
- package/lib/commonjs/OkCore/Helpers.js +0 -386
- package/lib/commonjs/OkCore/Helpers.js.map +0 -1
- package/lib/commonjs/OkCore/OkHiException.js +0 -96
- package/lib/commonjs/OkCore/OkHiException.js.map +0 -1
- package/lib/commonjs/OkCore/OkHiMode.js +0 -14
- package/lib/commonjs/OkCore/OkHiMode.js.map +0 -1
- package/lib/commonjs/OkCore/_helpers.js +0 -41
- package/lib/commonjs/OkCore/_helpers.js.map +0 -1
- package/lib/commonjs/OkCore/_types.js +0 -2
- package/lib/commonjs/OkCore/_types.js.map +0 -1
- package/lib/commonjs/OkCore/index.js +0 -119
- package/lib/commonjs/OkCore/index.js.map +0 -1
- package/lib/commonjs/OkCore/types.js +0 -6
- package/lib/commonjs/OkCore/types.js.map +0 -1
- package/lib/commonjs/OkHiNativeModule/index.js +0 -19
- package/lib/commonjs/OkHiNativeModule/index.js.map +0 -1
- package/lib/commonjs/OkVerify/index.js +0 -211
- package/lib/commonjs/OkVerify/index.js.map +0 -1
- package/lib/commonjs/OkVerify/types.js.map +0 -1
- package/lib/module/OkCollect/Helpers.js +0 -34
- package/lib/module/OkCollect/Helpers.js.map +0 -1
- package/lib/module/OkCollect/OkHiLocationManager.js +0 -298
- package/lib/module/OkCollect/OkHiLocationManager.js.map +0 -1
- package/lib/module/OkCollect/Spinner.js +0 -20
- package/lib/module/OkCollect/Spinner.js.map +0 -1
- package/lib/module/OkCollect/Util.js +0 -214
- package/lib/module/OkCollect/Util.js.map +0 -1
- package/lib/module/OkCollect/app.json +0 -4
- package/lib/module/OkCollect/index.js +0 -4
- package/lib/module/OkCollect/index.js.map +0 -1
- package/lib/module/OkCollect/types.js +0 -2
- package/lib/module/OkCollect/types.js.map +0 -1
- package/lib/module/OkCore/Helpers.js +0 -363
- package/lib/module/OkCore/Helpers.js.map +0 -1
- package/lib/module/OkCore/OkHiException.js +0 -89
- package/lib/module/OkCore/OkHiException.js.map +0 -1
- package/lib/module/OkCore/OkHiMode.js +0 -8
- package/lib/module/OkCore/OkHiMode.js.map +0 -1
- package/lib/module/OkCore/_helpers.js +0 -34
- package/lib/module/OkCore/_helpers.js.map +0 -1
- package/lib/module/OkCore/_types.js +0 -2
- package/lib/module/OkCore/_types.js.map +0 -1
- package/lib/module/OkCore/index.js +0 -65
- package/lib/module/OkCore/index.js.map +0 -1
- package/lib/module/OkCore/types.js +0 -2
- package/lib/module/OkCore/types.js.map +0 -1
- package/lib/module/OkHiNativeModule/index.js +0 -13
- package/lib/module/OkHiNativeModule/index.js.map +0 -1
- package/lib/module/OkVerify/index.js +0 -195
- package/lib/module/OkVerify/index.js.map +0 -1
- package/lib/module/OkVerify/types.js +0 -2
- package/lib/module/OkVerify/types.js.map +0 -1
- package/lib/typescript/OkCollect/Helpers.d.ts +0 -9
- package/lib/typescript/OkCollect/OkHiLocationManager.d.ts +0 -7
- package/lib/typescript/OkCollect/Spinner.d.ts +0 -5
- package/lib/typescript/OkCollect/Util.d.ts +0 -31
- package/lib/typescript/OkCollect/index.d.ts +0 -3
- package/lib/typescript/OkCollect/types.d.ts +0 -139
- package/lib/typescript/OkCore/Helpers.d.ts +0 -95
- package/lib/typescript/OkCore/OkHiException.d.ts +0 -81
- package/lib/typescript/OkCore/OkHiMode.d.ts +0 -7
- package/lib/typescript/OkCore/_helpers.d.ts +0 -3
- package/lib/typescript/OkCore/_types.d.ts +0 -38
- package/lib/typescript/OkCore/index.d.ts +0 -17
- package/lib/typescript/OkCore/types.d.ts +0 -203
- package/lib/typescript/OkHiNativeModule/index.d.ts +0 -48
- package/lib/typescript/OkVerify/index.d.ts +0 -65
- package/lib/typescript/OkVerify/types.d.ts +0 -0
- package/lib/typescript/index.d.ts +0 -3
- package/react-native-okhi.podspec +0 -35
- package/src/OkCollect/Helpers.ts +0 -53
- package/src/OkCollect/OkHiLocationManager.tsx +0 -391
- package/src/OkCollect/Spinner.tsx +0 -18
- package/src/OkCollect/Util.ts +0 -270
- package/src/OkCollect/app.json +0 -4
- package/src/OkCollect/index.ts +0 -3
- package/src/OkCollect/types.ts +0 -154
- package/src/OkCore/Helpers.ts +0 -477
- package/src/OkCore/OkHiException.ts +0 -93
- package/src/OkCore/OkHiMode.ts +0 -7
- package/src/OkCore/_helpers.ts +0 -47
- package/src/OkCore/_types.ts +0 -37
- package/src/OkCore/index.ts +0 -87
- package/src/OkCore/types.ts +0 -235
- package/src/OkHiNativeModule/index.ts +0 -92
- package/src/OkVerify/index.ts +0 -259
- package/src/OkVerify/types.ts +0 -0
- /package/lib/commonjs/{OkVerify/types.js → types.js} +0 -0
|
@@ -1,389 +0,0 @@
|
|
|
1
|
-
package com.reactnativeokhi;
|
|
2
|
-
|
|
3
|
-
import android.app.Activity;
|
|
4
|
-
import android.app.NotificationManager;
|
|
5
|
-
import android.content.Intent;
|
|
6
|
-
import android.net.Uri;
|
|
7
|
-
import android.os.Build;
|
|
8
|
-
import android.provider.Settings;
|
|
9
|
-
import android.util.Base64;
|
|
10
|
-
|
|
11
|
-
import androidx.annotation.NonNull;
|
|
12
|
-
|
|
13
|
-
import com.facebook.react.bridge.ActivityEventListener;
|
|
14
|
-
import com.facebook.react.bridge.Dynamic;
|
|
15
|
-
import com.facebook.react.bridge.Promise;
|
|
16
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
17
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
18
|
-
import com.facebook.react.bridge.ReactMethod;
|
|
19
|
-
import com.facebook.react.bridge.ReadableArray;
|
|
20
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
21
|
-
import com.facebook.react.bridge.WritableMap;
|
|
22
|
-
import com.facebook.react.bridge.WritableNativeMap;
|
|
23
|
-
import com.facebook.react.module.annotations.ReactModule;
|
|
24
|
-
|
|
25
|
-
import org.json.JSONObject;
|
|
26
|
-
|
|
27
|
-
import java.util.ArrayList;
|
|
28
|
-
|
|
29
|
-
import io.okhi.android_core.OkHi;
|
|
30
|
-
import io.okhi.android_core.interfaces.OkHiRequestHandler;
|
|
31
|
-
import io.okhi.android_core.models.OkCollectSuccessResponse;
|
|
32
|
-
import io.okhi.android_core.models.OkHiAppContext;
|
|
33
|
-
import io.okhi.android_core.models.OkHiAuth;
|
|
34
|
-
import io.okhi.android_core.models.OkHiException;
|
|
35
|
-
import io.okhi.android_core.models.OkHiLocation;
|
|
36
|
-
import io.okhi.android_core.models.OkHiLocationService;
|
|
37
|
-
import io.okhi.android_core.models.OkHiPermissionService;
|
|
38
|
-
import io.okhi.android_core.models.OkHiUsageType;
|
|
39
|
-
import io.okhi.android_core.models.OkHiUser;
|
|
40
|
-
import io.okhi.android_core.models.OkPreference;
|
|
41
|
-
import io.okhi.android_okverify.OkVerify;
|
|
42
|
-
import io.okhi.android_okverify.interfaces.OkVerifyCallback;
|
|
43
|
-
import io.okhi.android_okverify.models.OkHiNotification;
|
|
44
|
-
import io.okhi.android_okverify.models.StartVerificationService;
|
|
45
|
-
import io.okhi.android_okverify.models.OkVerifyInitConfig;
|
|
46
|
-
|
|
47
|
-
@ReactModule(name = OkhiModule.NAME)
|
|
48
|
-
public class OkhiModule extends ReactContextBaseJavaModule {
|
|
49
|
-
public static final String NAME = "Okhi";
|
|
50
|
-
OkHi okHi;
|
|
51
|
-
OkVerify okVerify;
|
|
52
|
-
OkHiAuth auth;
|
|
53
|
-
|
|
54
|
-
public OkhiModule(ReactApplicationContext reactContext) {
|
|
55
|
-
super(reactContext);
|
|
56
|
-
try {
|
|
57
|
-
ActivityEventListener activityEventListener = new ActivityEventListener() {
|
|
58
|
-
@Override
|
|
59
|
-
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
|
|
60
|
-
if (okHi != null) {
|
|
61
|
-
okHi.onActivityResult(requestCode, resultCode, data);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
@Override
|
|
66
|
-
public void onNewIntent(Intent intent) {
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
reactContext.addActivityEventListener(activityEventListener);
|
|
70
|
-
} catch (Exception e) {
|
|
71
|
-
e.printStackTrace();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
class RequestHandler implements OkHiRequestHandler<Boolean> {
|
|
76
|
-
Promise promise;
|
|
77
|
-
|
|
78
|
-
RequestHandler(Promise promise) {
|
|
79
|
-
this.promise = promise;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
@Override
|
|
83
|
-
public void onResult(Boolean result) {
|
|
84
|
-
promise.resolve(result);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
@Override
|
|
88
|
-
public void onError(OkHiException exception) {
|
|
89
|
-
promise.reject(exception);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
@Override
|
|
94
|
-
@NonNull
|
|
95
|
-
public String getName() {
|
|
96
|
-
return NAME;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
@ReactMethod
|
|
100
|
-
public void isLocationServicesEnabled(Promise promise) {
|
|
101
|
-
boolean result = OkHi.isLocationServicesEnabled(getReactApplicationContext());
|
|
102
|
-
promise.resolve(result);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
@ReactMethod
|
|
106
|
-
public void isLocationPermissionGranted(Promise promise) {
|
|
107
|
-
boolean result = OkHi.isLocationPermissionGranted(getReactApplicationContext());
|
|
108
|
-
promise.resolve(result);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
@ReactMethod
|
|
112
|
-
public void isBackgroundLocationPermissionGranted(Promise promise) {
|
|
113
|
-
boolean result = OkHi.isBackgroundLocationPermissionGranted(getReactApplicationContext());
|
|
114
|
-
promise.resolve(result);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
@ReactMethod
|
|
118
|
-
public void isGooglePlayServicesAvailable(Promise promise) {
|
|
119
|
-
promise.resolve(OkHi.isGooglePlayServicesAvailable(getReactApplicationContext()));
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
@ReactMethod
|
|
123
|
-
public void requestEnableLocationServices(Promise promise) {
|
|
124
|
-
if (OkHi.isLocationServicesEnabled(getReactApplicationContext())) {
|
|
125
|
-
promise.resolve(true);
|
|
126
|
-
} else if (getCurrentActivity() == null) {
|
|
127
|
-
promise.reject(new OkHiException(OkHiException.UNKNOWN_ERROR_CODE, "Main activity hasn't loaded yet"));
|
|
128
|
-
} else {
|
|
129
|
-
okHi = new OkHi(getCurrentActivity());
|
|
130
|
-
okHi.requestEnableLocationServices(new RequestHandler(promise));
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
@ReactMethod
|
|
135
|
-
public void requestEnableGooglePlayServices(Promise promise) {
|
|
136
|
-
if (OkHi.isGooglePlayServicesAvailable(getReactApplicationContext())) {
|
|
137
|
-
promise.resolve(true);
|
|
138
|
-
} else if (getCurrentActivity() == null) {
|
|
139
|
-
promise.reject(new OkHiException(OkHiException.UNKNOWN_ERROR_CODE, "Main activity hasn't loaded yet"));
|
|
140
|
-
} else {
|
|
141
|
-
okHi = new OkHi(getCurrentActivity());
|
|
142
|
-
okHi.requestEnableGooglePlayServices(new RequestHandler(promise));
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
@ReactMethod
|
|
147
|
-
public void getSystemVersion (Promise promise) {
|
|
148
|
-
promise.resolve(android.os.Build.VERSION.SDK_INT);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
@ReactMethod
|
|
152
|
-
public void getAuthToken(String branchId, String clientKey, Promise promise) {
|
|
153
|
-
String concat = branchId + ":" + clientKey;
|
|
154
|
-
String token = Base64.encodeToString(concat.getBytes(), Base64.NO_WRAP);
|
|
155
|
-
promise.resolve("Token " + token);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
@ReactMethod
|
|
159
|
-
public void initialize(String configuration, Promise promise) {
|
|
160
|
-
try {
|
|
161
|
-
JSONObject config = new JSONObject(configuration);
|
|
162
|
-
String branchId = config.getJSONObject("credentials").getString("branchId");
|
|
163
|
-
String clientKey = config.getJSONObject("credentials").getString("clientKey");
|
|
164
|
-
String mode = config.getJSONObject("context").getString("mode");
|
|
165
|
-
JSONObject configUser = null;
|
|
166
|
-
if (config.has("user")) {
|
|
167
|
-
configUser = config.getJSONObject("user");
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
auth = new OkHiAuth(getReactApplicationContext(), branchId, clientKey, mode);
|
|
171
|
-
if (getCurrentActivity() != null && getCurrentActivity().getApplicationContext() != null) {
|
|
172
|
-
okVerify = new OkVerify.Builder(getCurrentActivity(), auth).build();
|
|
173
|
-
|
|
174
|
-
if (config.has("notification")) {
|
|
175
|
-
JSONObject notificationConfig = config.getJSONObject("notification");
|
|
176
|
-
int importance = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? NotificationManager.IMPORTANCE_DEFAULT : 3;
|
|
177
|
-
|
|
178
|
-
OkHiNotification notification = new OkHiNotification(
|
|
179
|
-
notificationConfig.optString("title", "Verification in progress"),
|
|
180
|
-
notificationConfig.optString("text", "Address Verification in progress"),
|
|
181
|
-
notificationConfig.optString("channelId", "okhi"),
|
|
182
|
-
notificationConfig.optString("channelName", "OkHi Channel"),
|
|
183
|
-
notificationConfig.optString("channelDescription", "OkHi verification alerts"),
|
|
184
|
-
importance
|
|
185
|
-
);
|
|
186
|
-
if(configUser != null && configUser.has("phone")) {
|
|
187
|
-
String phone = configUser.getString("phone");
|
|
188
|
-
OkHiUser.Builder userBuilder = new OkHiUser.Builder(phone);
|
|
189
|
-
if (configUser.has("email")) {
|
|
190
|
-
userBuilder.withEmail(configUser.getString("email"));
|
|
191
|
-
}
|
|
192
|
-
if (configUser.has("firstName")) {
|
|
193
|
-
userBuilder.withFirstName(configUser.getString("firstName"));
|
|
194
|
-
}
|
|
195
|
-
if (configUser.has("lastName")) {
|
|
196
|
-
userBuilder.withLastName(configUser.getString("lastName"));
|
|
197
|
-
}
|
|
198
|
-
if (configUser.has("appUserId")) {
|
|
199
|
-
userBuilder.withAppUserId(configUser.getString("appUserId"));
|
|
200
|
-
}
|
|
201
|
-
OkHiUser user = userBuilder.build();
|
|
202
|
-
OkVerifyInitConfig okVerifyInitConfig = new OkVerifyInitConfig(auth, user);
|
|
203
|
-
OkVerify.init(getCurrentActivity(), notification, okVerifyInitConfig);
|
|
204
|
-
} else {
|
|
205
|
-
OkVerify.init(getCurrentActivity(), notification);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
promise.resolve(true);
|
|
209
|
-
} else {
|
|
210
|
-
promise.resolve(false);
|
|
211
|
-
}
|
|
212
|
-
} catch (Exception e) {
|
|
213
|
-
e.printStackTrace();
|
|
214
|
-
promise.reject("unauthorized", "unable to parse credentials", e);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
@ReactMethod
|
|
219
|
-
public void startAddressVerification(String token, String phoneNumber, String userId, String locationId, Float lat, Float lon, ReadableArray usageTypes, Promise promise) {
|
|
220
|
-
if (okVerify == null) {
|
|
221
|
-
promise.reject("unauthorized", "failed to initialise okhi");
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
String[] usageTypeList = new String[usageTypes.size()];
|
|
225
|
-
for (int i = 0; i < usageTypes.size(); i++) {
|
|
226
|
-
usageTypeList[i] = usageTypes.getString(i);
|
|
227
|
-
}
|
|
228
|
-
if (usageTypeList.length == 0) {
|
|
229
|
-
usageTypeList = new String[]{OkHiUsageType.digitalVerification.toString()};
|
|
230
|
-
}
|
|
231
|
-
OkHiLocation location = new OkHiLocation.Builder(locationId, lat, lon).setUsageTypes(usageTypeList).build();
|
|
232
|
-
OkHiUser user = new OkHiUser.Builder(phoneNumber).withOkHiUserId(userId).withToken(token).build();
|
|
233
|
-
OkCollectSuccessResponse response = new OkCollectSuccessResponse(user, location);
|
|
234
|
-
okVerify.start(response, new OkVerifyCallback<String>() {
|
|
235
|
-
@Override
|
|
236
|
-
public void onSuccess(String result) {
|
|
237
|
-
promise.resolve(result);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
@Override
|
|
241
|
-
public void onError(OkHiException e) {
|
|
242
|
-
promise.reject(e.getCode(), e.getMessage(), e);
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
@ReactMethod
|
|
248
|
-
public void stopAddressVerification(String phoneNumber, String locationId, Promise promise) {
|
|
249
|
-
OkVerify.stop(getReactApplicationContext(), locationId, new OkVerifyCallback<String>() {
|
|
250
|
-
@Override
|
|
251
|
-
public void onSuccess(String result) {
|
|
252
|
-
promise.resolve(result);
|
|
253
|
-
}
|
|
254
|
-
@Override
|
|
255
|
-
public void onError(OkHiException e) {
|
|
256
|
-
promise.reject(e.getCode(), e.getMessage(), e);
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
@ReactMethod
|
|
262
|
-
public void startForegroundService(Promise promise) {
|
|
263
|
-
try {
|
|
264
|
-
OkVerify.startForegroundService(getReactApplicationContext());
|
|
265
|
-
promise.resolve(true);
|
|
266
|
-
} catch (OkHiException e) {
|
|
267
|
-
e.printStackTrace();
|
|
268
|
-
promise.reject(e.getCode(), e.getMessage(), e);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
@ReactMethod
|
|
273
|
-
public void stopForegroundService(Promise promise) {
|
|
274
|
-
OkVerify.stopForegroundService(getReactApplicationContext());
|
|
275
|
-
promise.resolve(true);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
@ReactMethod
|
|
279
|
-
public void isForegroundServiceRunning(Promise promise) {
|
|
280
|
-
Boolean result = OkVerify.isForegroundServiceRunning(getReactApplicationContext());
|
|
281
|
-
promise.resolve(result);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
@ReactMethod
|
|
285
|
-
public void openAppSettings(Promise promise) {
|
|
286
|
-
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
|
287
|
-
Uri uri = Uri.fromParts("package", getReactApplicationContext().getPackageName(), null);
|
|
288
|
-
intent.setData(uri);
|
|
289
|
-
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
290
|
-
getReactApplicationContext().startActivity(intent);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
@ReactMethod
|
|
294
|
-
public void canOpenProtectedAppsSettings(Promise promise) {
|
|
295
|
-
promise.resolve(OkHiPermissionService.canOpenProtectedApps(getReactApplicationContext()));
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
@ReactMethod
|
|
299
|
-
public void openProtectedAppsSettings(Promise promise) {
|
|
300
|
-
try {
|
|
301
|
-
Activity activity = getCurrentActivity();
|
|
302
|
-
if (activity != null) {
|
|
303
|
-
OkHiPermissionService.openProtectedAppsSettings(getCurrentActivity(), 69);
|
|
304
|
-
promise.resolve(true);
|
|
305
|
-
} else {
|
|
306
|
-
throw new OkHiException(OkHiException.UNKNOWN_ERROR_CODE, "unable to retrieve current activity");
|
|
307
|
-
}
|
|
308
|
-
} catch (OkHiException e) {
|
|
309
|
-
promise.reject(e.getCode(), e.getMessage(), e);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
@ReactMethod
|
|
314
|
-
public void retrieveDeviceInfo(Promise promise) {
|
|
315
|
-
WritableMap map = new WritableNativeMap();
|
|
316
|
-
map.putString("manufacturer", Build.MANUFACTURER);
|
|
317
|
-
map.putString("model", Build.MODEL);
|
|
318
|
-
map.putString("osVersion", Build.VERSION.RELEASE);
|
|
319
|
-
map.putString("platform", "android");
|
|
320
|
-
promise.resolve(map);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
private Dynamic getConfig(ReadableMap map, String prop) {
|
|
324
|
-
if (map != null && map.hasKey("android")) {
|
|
325
|
-
ReadableMap config = map.getMap("android");
|
|
326
|
-
if (config.hasKey("withForeground")) {
|
|
327
|
-
return config.getDynamic("withForeground");
|
|
328
|
-
} else {
|
|
329
|
-
return null;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
return null;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
// Required for rn built in EventEmitter Calls.
|
|
336
|
-
@ReactMethod
|
|
337
|
-
public void addListener(String eventName) {
|
|
338
|
-
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
@ReactMethod
|
|
342
|
-
public void removeListeners(Integer count) {
|
|
343
|
-
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
@ReactMethod
|
|
347
|
-
public void setItem(String key, String value, Promise promise) {
|
|
348
|
-
try {
|
|
349
|
-
OkPreference.setItem(key, value, getReactApplicationContext());
|
|
350
|
-
promise.resolve(true);
|
|
351
|
-
} catch (OkHiException e) {
|
|
352
|
-
promise.reject(e.getCode(), e.getMessage(), e);
|
|
353
|
-
e.printStackTrace();
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
@ReactMethod
|
|
358
|
-
public void getItem(String key, Promise promise) {
|
|
359
|
-
try {
|
|
360
|
-
promise.resolve(OkPreference.getItem(key, getReactApplicationContext()));
|
|
361
|
-
} catch (OkHiException e) {
|
|
362
|
-
promise.reject(e.getCode(), e.getMessage(), e);
|
|
363
|
-
e.printStackTrace();
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
@ReactMethod
|
|
368
|
-
public void fetchRegisteredGeofences(Promise promise) {
|
|
369
|
-
promise.resolve(OkVerify.fetchRegisteredGeofences(getReactApplicationContext()));
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
@ReactMethod
|
|
373
|
-
public void onNewToken(String fcmPushNotificationToken, Promise promise) {
|
|
374
|
-
StartVerificationService.onNewToken(fcmPushNotificationToken, getReactApplicationContext());
|
|
375
|
-
promise.resolve(true);
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
@ReactMethod
|
|
379
|
-
public void onMessageReceived(Promise promise) {
|
|
380
|
-
StartVerificationService.onMessageReceived(getReactApplicationContext());
|
|
381
|
-
promise.resolve(true);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
@ReactMethod
|
|
385
|
-
public void getLocationAccuracyLevel(Promise promise) {
|
|
386
|
-
String level = OkHiLocationService.getLocationAccuracyLevel(getReactApplicationContext());
|
|
387
|
-
promise.resolve(level);
|
|
388
|
-
}
|
|
389
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
package com.reactnativeokhi;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.NonNull;
|
|
4
|
-
|
|
5
|
-
import com.facebook.react.ReactPackage;
|
|
6
|
-
import com.facebook.react.bridge.NativeModule;
|
|
7
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
|
-
import com.facebook.react.uimanager.ViewManager;
|
|
9
|
-
|
|
10
|
-
import java.util.ArrayList;
|
|
11
|
-
import java.util.Collections;
|
|
12
|
-
import java.util.List;
|
|
13
|
-
|
|
14
|
-
public class OkhiPackage implements ReactPackage {
|
|
15
|
-
@NonNull
|
|
16
|
-
@Override
|
|
17
|
-
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
|
|
18
|
-
List<NativeModule> modules = new ArrayList<>();
|
|
19
|
-
modules.add(new OkhiModule(reactContext));
|
|
20
|
-
return modules;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@NonNull
|
|
24
|
-
@Override
|
|
25
|
-
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
26
|
-
return Collections.emptyList();
|
|
27
|
-
}
|
|
28
|
-
}
|
package/ios/OkHiExtension.swift
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// OkHiExtension.swift
|
|
3
|
-
// react-native-okhi
|
|
4
|
-
//
|
|
5
|
-
// Created by Julius Kiano on 01/09/2022.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
import Foundation
|
|
9
|
-
|
|
10
|
-
extension String {
|
|
11
|
-
func fromBase64() -> String? {
|
|
12
|
-
guard let data = Data(base64Encoded: self) else {
|
|
13
|
-
return nil
|
|
14
|
-
}
|
|
15
|
-
return String(data: data, encoding: .utf8)
|
|
16
|
-
}
|
|
17
|
-
func toBase64() -> String {
|
|
18
|
-
return Data(self.utf8).base64EncodedString()
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
extension String {
|
|
23
|
-
func toJSON() -> Any? {
|
|
24
|
-
guard let data = self.data(using: .utf8, allowLossyConversion: false) else { return nil }
|
|
25
|
-
return try? JSONSerialization.jsonObject(with: data, options: .mutableContainers)
|
|
26
|
-
}
|
|
27
|
-
}
|
package/ios/OkHiStruct.swift
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// File.swift
|
|
3
|
-
// react-native-okhi
|
|
4
|
-
//
|
|
5
|
-
// Created by Julius Kiano on 01/09/2022.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
import Foundation
|
|
9
|
-
|
|
10
|
-
struct RNOkHiCredential: Codable {
|
|
11
|
-
let branchId: String
|
|
12
|
-
let clientKey: String
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
struct RNOkHiContext: Codable {
|
|
16
|
-
let mode: String
|
|
17
|
-
let developer: String?
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
struct RNOkHiApp: Codable {
|
|
21
|
-
let name: String?
|
|
22
|
-
let version: String?
|
|
23
|
-
let build: String?
|
|
24
|
-
}
|
|
25
|
-
struct RNOkHiConfiguration: Codable {
|
|
26
|
-
let credentials: RNOkHiCredential
|
|
27
|
-
let context: RNOkHiContext
|
|
28
|
-
let app: RNOkHiApp?
|
|
29
|
-
}
|
package/ios/Okhi.m
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#import <React/RCTBridgeModule.h>
|
|
2
|
-
#import "React/RCTEventEmitter.h"
|
|
3
|
-
|
|
4
|
-
@interface RCT_EXTERN_MODULE(Okhi, RCTEventEmitter)
|
|
5
|
-
|
|
6
|
-
RCT_EXTERN_METHOD(multiply:(float)a withB:(float)b
|
|
7
|
-
withResolver:(RCTPromiseResolveBlock)resolve
|
|
8
|
-
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
9
|
-
|
|
10
|
-
RCT_EXTERN_METHOD(isLocationServicesEnabled: (RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
11
|
-
|
|
12
|
-
RCT_EXTERN_METHOD(isLocationPermissionGranted: (RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
13
|
-
|
|
14
|
-
RCT_EXTERN_METHOD(isBackgroundLocationPermissionGranted: (RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
15
|
-
|
|
16
|
-
RCT_EXTERN_METHOD(requestLocationPermission: (RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
17
|
-
|
|
18
|
-
RCT_EXTERN_METHOD(requestBackgroundLocationPermission: (RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
19
|
-
|
|
20
|
-
RCT_EXTERN_METHOD(requestEnableLocationServices: (RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
21
|
-
|
|
22
|
-
RCT_EXTERN_METHOD(openAppSettings: (RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
23
|
-
|
|
24
|
-
RCT_EXTERN_METHOD(getSystemVersion: (RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
25
|
-
|
|
26
|
-
RCT_EXTERN_METHOD(getAuthToken:(NSString *)branchId clientKey:(NSString *)clientKey resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
27
|
-
|
|
28
|
-
RCT_EXTERN_METHOD(initializeIOS:(NSString *)branchId clientKey:(NSString *)clientKey environment:(NSString *)environment resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
29
|
-
|
|
30
|
-
RCT_EXTERN_METHOD(startAddressVerification:(NSString *)token
|
|
31
|
-
phoneNumber:(NSString *)phoneNumber
|
|
32
|
-
userId:(NSString *)userId
|
|
33
|
-
locationId:(NSString *)locationId
|
|
34
|
-
lat:(double)lat
|
|
35
|
-
lon:(double)lon
|
|
36
|
-
usageTypes:(NSArray<NSString *> *)usageTypes
|
|
37
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
38
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
39
|
-
|
|
40
|
-
RCT_EXTERN_METHOD(stopAddressVerification:(NSString *)phoneNumber locationId:(NSString *)locationId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
41
|
-
|
|
42
|
-
RCT_EXTERN_METHOD(retriveLocationPermissionStatus: (RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
43
|
-
|
|
44
|
-
RCT_EXTERN_METHOD(requestTrackingAuthorization: (RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
45
|
-
|
|
46
|
-
RCT_EXTERN_METHOD(isNotificationPermissionGranted: (RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
47
|
-
|
|
48
|
-
RCT_EXTERN_METHOD(requestNotificationPermission: (RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
49
|
-
|
|
50
|
-
RCT_EXTERN_METHOD(fetchCurrentLocation: (RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
51
|
-
|
|
52
|
-
RCT_EXTERN_METHOD(fetchIOSLocationPermissionStatus: (RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
53
|
-
|
|
54
|
-
RCT_EXTERN_METHOD(retrieveDeviceInfo: (RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
55
|
-
|
|
56
|
-
RCT_EXTERN_METHOD(onStart: (RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
57
|
-
|
|
58
|
-
RCT_EXTERN_METHOD(fetchRegisteredGeofences: (RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
59
|
-
|
|
60
|
-
RCT_EXTERN_METHOD(getLocationAccuracyLevel: (RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
61
|
-
|
|
62
|
-
@end
|