@customerglu/react-native-customerglu 2.1.2-1.0-beta → 3.0.0-beta-1.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/LICENSE +20 -15
- package/README.md +2 -2
- package/ReactNativeCustomerglu.podspec +42 -0
- package/android/build.gradle +78 -33
- package/android/generated/java/com/customerglu/reactnativecustomerglu/NativeReactNativeCustomergluSpec.java +144 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNReactNativeCustomergluSpec-generated.cpp +188 -0
- package/android/generated/jni/RNReactNativeCustomergluSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNReactNativeCustomergluSpec/RNReactNativeCustomergluSpecJSI-generated.cpp +237 -0
- package/android/generated/jni/react/renderer/components/RNReactNativeCustomergluSpec/RNReactNativeCustomergluSpecJSI.h +305 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +1 -6
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/customerglu/reactnativecustomerglu/BannerView.kt +76 -0
- package/android/src/main/java/com/customerglu/reactnativecustomerglu/BannerViewManager.kt +19 -0
- package/android/src/main/java/com/customerglu/reactnativecustomerglu/CGEmbededView.kt +102 -0
- package/android/src/main/java/com/customerglu/reactnativecustomerglu/CGEmbededViewManager.kt +18 -0
- package/android/src/main/java/com/customerglu/reactnativecustomerglu/RnCustomergluModule.kt +698 -0
- package/android/src/main/java/com/customerglu/reactnativecustomerglu/RnCustomergluPackage.kt +41 -0
- package/ios/Rncustomerglu.h +6 -0
- package/ios/Rncustomerglu.mm +18 -0
- package/ios/generated/RNReactNativeCustomergluSpec/RNReactNativeCustomergluSpec-generated.mm +221 -0
- package/ios/generated/RNReactNativeCustomergluSpec/RNReactNativeCustomergluSpec.h +106 -0
- package/ios/generated/RNReactNativeCustomergluSpecJSI-generated.cpp +237 -0
- package/ios/generated/RNReactNativeCustomergluSpecJSI.h +305 -0
- package/lib/commonjs/NativeReactNativeCustomerglu.js +9 -0
- package/lib/commonjs/NativeReactNativeCustomerglu.js.map +1 -0
- package/lib/commonjs/index.js +28 -191
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/NativeReactNativeCustomerglu.js +5 -0
- package/lib/module/NativeReactNativeCustomerglu.js.map +1 -0
- package/lib/module/index.js +30 -164
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeReactNativeCustomerglu.d.ts +33 -0
- package/lib/typescript/commonjs/src/NativeReactNativeCustomerglu.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +35 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeReactNativeCustomerglu.d.ts +33 -0
- package/lib/typescript/module/src/NativeReactNativeCustomerglu.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +35 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +91 -45
- package/react-native.config.js +12 -0
- package/src/NativeReactNativeCustomerglu.ts +36 -0
- package/src/index.tsx +73 -217
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
- package/android/gradlew +0 -185
- package/android/gradlew.bat +0 -89
- package/android/src/main/java/com/reactnativerncustomerglu/Bannerwidget/Bannerwidget/BannerWidgetViewGroupManager.java +0 -40
- package/android/src/main/java/com/reactnativerncustomerglu/Bannerwidget/Bannerwidget/bannerWidget.java +0 -43
- package/android/src/main/java/com/reactnativerncustomerglu/Bannerwidget/wrapperview/WrapperView.java +0 -61
- package/android/src/main/java/com/reactnativerncustomerglu/CGUtils.java +0 -13
- package/android/src/main/java/com/reactnativerncustomerglu/EmbedBannerwidget/EWrapperview/EWrapperView.java +0 -61
- package/android/src/main/java/com/reactnativerncustomerglu/EmbedBannerwidget/EmbedBannerwidget/EBannerWidget.java +0 -35
- package/android/src/main/java/com/reactnativerncustomerglu/EmbedBannerwidget/EmbedBannerwidget/EBannerWidgetVGManager.java +0 -40
- package/android/src/main/java/com/reactnativerncustomerglu/RncustomergluModule.java +0 -1033
- package/android/src/main/java/com/reactnativerncustomerglu/RncustomergluPackage.java +0 -35
- package/android/src/main/res/drawable/bottom_sheet_edges.xml +0 -7
- package/android/src/main/res/drawable/floating_close_layout.xml +0 -10
- package/android/src/main/res/drawable/ic_arrow_back.xml +0 -5
- package/android/src/main/res/drawable/ic_back.xml +0 -10
- package/android/src/main/res/drawable/ic_delete_bin.xml +0 -5
- package/android/src/main/res/drawable/ic_delete_bin_red.xml +0 -5
- package/android/src/main/res/drawable/ij.png +0 -0
- package/android/src/main/res/drawable/notification.png +0 -0
- package/android/src/main/res/drawable/progress_bg.xml +0 -33
- package/android/src/main/res/values/colors.xml +0 -13
- package/android/src/main/res/values/themes.xml +0 -15
- package/android/src/main/res/xml/provider_path.xml +0 -4
- package/ios/CustomPlayer.m +0 -30
- package/ios/Rncustomerglu-Bridging-Header.h +0 -4
- package/ios/Rncustomerglu.m +0 -83
- package/ios/Rncustomerglu.swift +0 -647
- package/ios/Rncustomerglu.xcodeproj/project.pbxproj +0 -293
- package/ios/Rncustomerglu.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
- package/ios/Rncustomerglu.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/lib/typescript/index.d.ts +0 -62
- package/react-native-customerglu.podspec +0 -23
|
@@ -1,1033 +0,0 @@
|
|
|
1
|
-
package com.reactnativerncustomerglu;
|
|
2
|
-
|
|
3
|
-
import static com.customerglu.sdk.Utils.Comman.printDebugLogs;
|
|
4
|
-
import static com.facebook.react.bridge.UiThreadUtil.runOnUiThread;
|
|
5
|
-
|
|
6
|
-
import android.content.BroadcastReceiver;
|
|
7
|
-
import android.content.Context;
|
|
8
|
-
import android.content.Intent;
|
|
9
|
-
import android.content.IntentFilter;
|
|
10
|
-
import android.content.pm.ApplicationInfo;
|
|
11
|
-
import android.content.pm.PackageManager;
|
|
12
|
-
import android.net.Uri;
|
|
13
|
-
import android.os.Build;
|
|
14
|
-
import android.os.Bundle;
|
|
15
|
-
import android.os.Handler;
|
|
16
|
-
import android.os.Looper;
|
|
17
|
-
import android.util.Log;
|
|
18
|
-
import android.widget.Toast;
|
|
19
|
-
|
|
20
|
-
import androidx.annotation.NonNull;
|
|
21
|
-
|
|
22
|
-
import com.customerglu.sdk.Interface.CGDeepLinkListener;
|
|
23
|
-
import com.customerglu.sdk.Interface.CampaignStatusListener;
|
|
24
|
-
import com.customerglu.sdk.Interface.CampaignValidListener;
|
|
25
|
-
import com.customerglu.sdk.Modal.DeepLinkWormholeModel;
|
|
26
|
-
import com.customerglu.sdk.Modal.NudgeConfiguration;
|
|
27
|
-
import com.customerglu.sdk.Utils.CGConstants;
|
|
28
|
-
import com.customerglu.sdk.Utils.Comman;
|
|
29
|
-
import com.customerglu.sdk.pip.PIPHelper;
|
|
30
|
-
import com.facebook.react.bridge.LifecycleEventListener;
|
|
31
|
-
import com.facebook.react.bridge.WritableArray;
|
|
32
|
-
import com.facebook.react.bridge.WritableNativeArray;
|
|
33
|
-
import com.facebook.react.bridge.WritableNativeMap;
|
|
34
|
-
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
35
|
-
import com.facebook.react.bridge.WritableMap;
|
|
36
|
-
import com.customerglu.sdk.CustomerGlu;
|
|
37
|
-
import com.customerglu.sdk.Interface.DataListner;
|
|
38
|
-
import com.customerglu.sdk.Modal.RegisterModal;
|
|
39
|
-
import com.facebook.react.bridge.Promise;
|
|
40
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
41
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
42
|
-
import com.facebook.react.bridge.ReactMethod;
|
|
43
|
-
import com.facebook.react.bridge.ReadableArray;
|
|
44
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
45
|
-
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
46
|
-
import com.facebook.react.bridge.ReadableType;
|
|
47
|
-
import com.facebook.react.module.annotations.ReactModule;
|
|
48
|
-
import com.google.gson.Gson;
|
|
49
|
-
|
|
50
|
-
import org.json.JSONArray;
|
|
51
|
-
import org.json.JSONException;
|
|
52
|
-
import org.json.JSONObject;
|
|
53
|
-
|
|
54
|
-
import java.net.MalformedURLException;
|
|
55
|
-
import java.util.ArrayList;
|
|
56
|
-
import java.util.Date;
|
|
57
|
-
import java.util.HashMap;
|
|
58
|
-
import java.util.Iterator;
|
|
59
|
-
import java.util.List;
|
|
60
|
-
import java.util.Map;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
@ReactModule(name = RncustomergluModule.NAME)
|
|
64
|
-
public class RncustomergluModule extends ReactContextBaseJavaModule implements LifecycleEventListener {
|
|
65
|
-
public static final String TAG = RncustomergluModule.class.getName();
|
|
66
|
-
public static String Myclassname = "";
|
|
67
|
-
public static final String NAME = "Rncustomerglu";
|
|
68
|
-
private static ReactApplicationContext mContext;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
public RncustomergluModule(ReactApplicationContext reactContext) {
|
|
72
|
-
super(reactContext);
|
|
73
|
-
mContext = reactContext;
|
|
74
|
-
reactContext.addLifecycleEventListener(this);
|
|
75
|
-
if (!CustomerGlu.isInitialized){
|
|
76
|
-
Log.e("Receiver Register","register");
|
|
77
|
-
registerBroadcastReceiver();
|
|
78
|
-
// CustomerGlu.getInstance().initializeSdk(getReactApplicationContext());
|
|
79
|
-
}
|
|
80
|
-
setPlatformAndSdkVersion();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
@ReactMethod
|
|
84
|
-
public void addListener(String eventName) {
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
@ReactMethod
|
|
88
|
-
public void removeListeners(Integer count) {
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
private void setPlatformAndSdkVersion() {
|
|
94
|
-
if (CustomerGlu.getInstance() != null) {
|
|
95
|
-
|
|
96
|
-
CustomerGlu.cg_sdk_version = "2.1.1";
|
|
97
|
-
CustomerGlu.cg_app_platform = "REACT_NATIVE";
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
private final BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
|
|
104
|
-
@Override
|
|
105
|
-
public void onReceive(Context context, Intent intent) {
|
|
106
|
-
Log.d(TAG, "on Received....");
|
|
107
|
-
try {
|
|
108
|
-
if (intent.getAction().equalsIgnoreCase("CUSTOMERGLU_ANALYTICS_EVENT")) {
|
|
109
|
-
/* If you want to listen CUSTOMERGLU_ANALYTICS_EVENT */
|
|
110
|
-
if (intent.getStringExtra("data") != null) {
|
|
111
|
-
String data = intent.getStringExtra("data");
|
|
112
|
-
JSONObject jsonObject = new JSONObject(data);
|
|
113
|
-
WritableMap map = jsonToWritableMap(jsonObject);
|
|
114
|
-
sendEventToJs("CUSTOMERGLU_ANALYTICS_EVENT", map);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/* If you want to listen CUSTOMERGLU_DEEPLINK_EVENT */
|
|
119
|
-
|
|
120
|
-
if (intent.getAction().equalsIgnoreCase("CUSTOMERGLU_DEEPLINK_EVENT")) {
|
|
121
|
-
if (intent.getStringExtra("data") != null) {
|
|
122
|
-
String data = intent.getStringExtra("data");
|
|
123
|
-
JSONObject jsonObject = new JSONObject(data);
|
|
124
|
-
WritableMap map = jsonToWritableMap(jsonObject);
|
|
125
|
-
sendEventToJs("CUSTOMERGLU_DEEPLINK_EVENT", map);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (intent.getAction().equalsIgnoreCase("CUSTOMERGLU_BANNER_LOADED")) {
|
|
131
|
-
/* If you want to listen CUSTOMERGLU_BANNER_LOADED */
|
|
132
|
-
if (intent.getStringExtra("data") != null) {
|
|
133
|
-
String data = intent.getStringExtra("data");
|
|
134
|
-
JSONObject jsonObject = new JSONObject(data);
|
|
135
|
-
WritableMap map = jsonToWritableMap(jsonObject);
|
|
136
|
-
sendEventToJs("CUSTOMERGLU_BANNER_LOADED", map);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (intent.getAction().equalsIgnoreCase("CG_INVALID_CAMPAIGN_ID")) {
|
|
141
|
-
/* If you want to listen CG_INVALID_CAMPAIGN_ID */
|
|
142
|
-
if (intent.getStringExtra("data") != null) {
|
|
143
|
-
String data = intent.getStringExtra("data");
|
|
144
|
-
JSONObject jsonObject = new JSONObject(data);
|
|
145
|
-
WritableMap map = jsonToWritableMap(jsonObject);
|
|
146
|
-
sendEventToJs("CG_INVALID_CAMPAIGN_ID", map);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
} catch (Exception e) {
|
|
153
|
-
System.out.println(e);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
private void registerBroadcastReceiver() {
|
|
160
|
-
try {
|
|
161
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
162
|
-
mContext.registerReceiver(mMessageReceiver, new IntentFilter("CUSTOMERGLU_ANALYTICS_EVENT"), Context.RECEIVER_EXPORTED);
|
|
163
|
-
|
|
164
|
-
mContext.registerReceiver(mMessageReceiver, new IntentFilter("CUSTOMERGLU_DEEPLINK_EVENT"), Context.RECEIVER_EXPORTED);
|
|
165
|
-
mContext.registerReceiver(mMessageReceiver, new IntentFilter("CUSTOMERGLU_BANNER_LOADED"), Context.RECEIVER_EXPORTED);
|
|
166
|
-
mContext.registerReceiver(mMessageReceiver, new IntentFilter("CG_INVALID_CAMPAIGN_ID"), Context.RECEIVER_EXPORTED);
|
|
167
|
-
}else {
|
|
168
|
-
|
|
169
|
-
mContext.registerReceiver(mMessageReceiver, new IntentFilter("CUSTOMERGLU_ANALYTICS_EVENT"));
|
|
170
|
-
mContext.registerReceiver(mMessageReceiver, new IntentFilter("CUSTOMERGLU_DEEPLINK_EVENT"));
|
|
171
|
-
mContext.registerReceiver(mMessageReceiver, new IntentFilter("CUSTOMERGLU_BANNER_LOADED"));
|
|
172
|
-
mContext.registerReceiver(mMessageReceiver, new IntentFilter("CG_INVALID_CAMPAIGN_ID"));
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
}catch (Exception e){
|
|
176
|
-
printDebugLogs(""+e);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
private void sendEventToJs(String eventName, WritableMap map) {
|
|
183
|
-
try {
|
|
184
|
-
getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
185
|
-
.emit(eventName, map);
|
|
186
|
-
} catch (Exception e) {
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
@Override
|
|
193
|
-
@NonNull
|
|
194
|
-
public String getName() {
|
|
195
|
-
return NAME;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
@Override
|
|
201
|
-
public void onHostResume() {
|
|
202
|
-
Log.e(TAG, "On Host Resume....");
|
|
203
|
-
CustomerGlu.getInstance().showEntryPoint(getReactApplicationContext().getCurrentActivity());
|
|
204
|
-
|
|
205
|
-
CustomerGlu.getInstance().setCgDeepLinkListener(new CGDeepLinkListener() {
|
|
206
|
-
@Override
|
|
207
|
-
public void onSuccess(CGConstants.CGSTATE message, DeepLinkWormholeModel.DeepLinkData deepLinkData) {
|
|
208
|
-
JSONObject jsonObject = null;
|
|
209
|
-
try {
|
|
210
|
-
if (message.equals(CGConstants.CGSTATE.DEEPLINK_URL)) {
|
|
211
|
-
String url = "";
|
|
212
|
-
if (deepLinkData.getContent().getUrl() != null) {
|
|
213
|
-
url = deepLinkData.getContent().getUrl();
|
|
214
|
-
Log.e("DeepLink URL", "Success " + message);
|
|
215
|
-
}
|
|
216
|
-
// Add your logic
|
|
217
|
-
}
|
|
218
|
-
Log.e("Onelink", "Success " + message);
|
|
219
|
-
jsonObject = new JSONObject();
|
|
220
|
-
jsonObject.put("status",message.toString());
|
|
221
|
-
Gson gson = new Gson();
|
|
222
|
-
String json = gson.toJson(deepLinkData);
|
|
223
|
-
JSONObject mJSONObject = new JSONObject(json);
|
|
224
|
-
jsonObject.put("data",mJSONObject);
|
|
225
|
-
|
|
226
|
-
Log.e("Onelink2", "Success " + jsonObject);
|
|
227
|
-
// Intent intent = new Intent("CG_UNI_DEEPLINK_EVENT");
|
|
228
|
-
// intent.putExtra("data", jsonObject.toString());
|
|
229
|
-
// context.sendBroadcast(intent);
|
|
230
|
-
|
|
231
|
-
WritableMap map = jsonToWritableMap(jsonObject);
|
|
232
|
-
sendEventToJs("CG_UNI_DEEPLINK_EVENT", map);
|
|
233
|
-
|
|
234
|
-
Log.e("Onelink4", "Success " + message);
|
|
235
|
-
}catch (Exception e)
|
|
236
|
-
{
|
|
237
|
-
Log.e("Onelink ex ",e.toString());
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
@Override
|
|
242
|
-
public void onFailure(CGConstants.CGSTATE exceptions) {
|
|
243
|
-
try {
|
|
244
|
-
Log.e("Onelink", "Success " + exceptions);
|
|
245
|
-
JSONObject jsonObject = new JSONObject();
|
|
246
|
-
jsonObject.put("status", exceptions.toString());
|
|
247
|
-
|
|
248
|
-
JSONObject mJSONObject = new JSONObject();
|
|
249
|
-
jsonObject.put("data", mJSONObject);
|
|
250
|
-
WritableMap map = jsonToWritableMap(jsonObject);
|
|
251
|
-
sendEventToJs("CG_UNI_DEEPLINK_EVENT", map);
|
|
252
|
-
|
|
253
|
-
Log.e("Onelink2", "Success " + jsonObject);
|
|
254
|
-
|
|
255
|
-
//
|
|
256
|
-
// Intent intent = new Intent("CG_UNI_DEEPLINK_EVENT");
|
|
257
|
-
// intent.putExtra("data", jsonObject.toString());
|
|
258
|
-
// context.sendBroadcast(intent);
|
|
259
|
-
}catch (Exception e)
|
|
260
|
-
{
|
|
261
|
-
Log.e("Onelink ex ",e.toString());
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
@ReactMethod
|
|
272
|
-
public void handleDeepLinkUri(String urls){
|
|
273
|
-
if(urls!=null){
|
|
274
|
-
Uri uri = Uri.parse(urls);
|
|
275
|
-
Comman.handleDeepLinkUri(uri);}
|
|
276
|
-
else
|
|
277
|
-
{
|
|
278
|
-
JSONObject jsonObject = new JSONObject();
|
|
279
|
-
try {
|
|
280
|
-
jsonObject.put("status", "EXCEPTION");
|
|
281
|
-
JSONObject mJSONObject = new JSONObject();
|
|
282
|
-
jsonObject.put("data", mJSONObject);
|
|
283
|
-
WritableMap map = jsonToWritableMap(jsonObject);
|
|
284
|
-
sendEventToJs("CG_UNI_DEEPLINK_EVENT", map);
|
|
285
|
-
} catch (JSONException e) {
|
|
286
|
-
e.printStackTrace();
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
@Override
|
|
294
|
-
public void onHostPause() {
|
|
295
|
-
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
@Override
|
|
299
|
-
public void onHostDestroy() {
|
|
300
|
-
try {
|
|
301
|
-
if (mContext != null) {
|
|
302
|
-
Log.e("Receiver unRegister","unregister");
|
|
303
|
-
mContext.unregisterReceiver(mMessageReceiver);
|
|
304
|
-
}
|
|
305
|
-
}catch (Exception e){
|
|
306
|
-
printDebugLogs(""+e);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
// Example method
|
|
311
|
-
// See https://reactnative.dev/docs/native-modules-android
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
@ReactMethod
|
|
315
|
-
public void registerDevice(ReadableMap map, Promise promise) {
|
|
316
|
-
if (map != null) {
|
|
317
|
-
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
|
318
|
-
@Override
|
|
319
|
-
public void run() {
|
|
320
|
-
JSONObject jsonObject = convertMapToJson(map);
|
|
321
|
-
HashMap<String, Object> userData = new Gson().fromJson(jsonObject.toString(), HashMap.class);
|
|
322
|
-
Log.d(TAG, "userdata----> " + userData.toString() + " " + new Date().getTime());
|
|
323
|
-
|
|
324
|
-
CustomerGlu.getInstance().registerDevice(getReactApplicationContext(), userData, new DataListner() {
|
|
325
|
-
//this method registers the user
|
|
326
|
-
|
|
327
|
-
@Override
|
|
328
|
-
public void onSuccess(Boolean registerModal) {
|
|
329
|
-
Log.d(TAG, "Registered!..." + " " + new Date().getTime());
|
|
330
|
-
promise.resolve(true);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
@Override
|
|
334
|
-
public void onFail(String message) {
|
|
335
|
-
// Toast.makeText(getReactApplicationContext(), "" + message, Toast.LENGTH_SHORT).show();
|
|
336
|
-
Log.d(TAG, "Registeration Failed!..." + message.toString());
|
|
337
|
-
|
|
338
|
-
promise.resolve(false);
|
|
339
|
-
|
|
340
|
-
}
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
},500);
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
@ReactMethod
|
|
350
|
-
public void setOpenWalletAsFallback(Boolean value) {
|
|
351
|
-
CustomerGlu.getInstance().openWalletAsFallback(value);
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
@ReactMethod
|
|
356
|
-
public void dataClear() {
|
|
357
|
-
CustomerGlu.getInstance().clearGluData(getCurrentActivity());
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
@ReactMethod
|
|
361
|
-
public void sendData(ReadableMap readableMap) {
|
|
362
|
-
Log.e(TAG, "rereadableMapquest----- " + readableMap);
|
|
363
|
-
if (readableMap != null) {
|
|
364
|
-
try {
|
|
365
|
-
String evnt = "";
|
|
366
|
-
JSONObject obj = convertMapToJson(readableMap);
|
|
367
|
-
Log.e(TAG, "request----- " + obj);
|
|
368
|
-
if (obj.has("eventName")) {
|
|
369
|
-
evnt = (String) obj.get("eventName");
|
|
370
|
-
}
|
|
371
|
-
if (obj.has("eventProperties")) {
|
|
372
|
-
Object eventProperties = obj.get("eventProperties");
|
|
373
|
-
if (eventProperties instanceof JSONObject) {
|
|
374
|
-
Log.e(TAG, "data>>>>>----- " + (JSONObject) eventProperties);
|
|
375
|
-
CustomerGlu.getInstance().sendEvent(getReactApplicationContext(), evnt, jsonToMap((JSONObject) eventProperties));
|
|
376
|
-
}
|
|
377
|
-
} else {
|
|
378
|
-
Map<String, Object> s = new HashMap<>();
|
|
379
|
-
CustomerGlu.getInstance().sendEvent(getReactApplicationContext(), evnt, s);
|
|
380
|
-
}
|
|
381
|
-
} catch (JSONException e) {
|
|
382
|
-
e.printStackTrace();
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
public static Map<String, Object> jsonToMap(JSONObject json) throws JSONException {
|
|
389
|
-
Map<String, Object> retMap = new HashMap<String, Object>();
|
|
390
|
-
if (json != JSONObject.NULL) {
|
|
391
|
-
retMap = toMap(json);
|
|
392
|
-
}
|
|
393
|
-
return retMap;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
public static Map<String, Object> toMap(JSONObject object) throws JSONException {
|
|
397
|
-
Map<String, Object> map = new HashMap<String, Object>();
|
|
398
|
-
Iterator<String> keysItr = object.keys();
|
|
399
|
-
while (keysItr.hasNext()) {
|
|
400
|
-
String key = keysItr.next();
|
|
401
|
-
Object value = object.get(key);
|
|
402
|
-
|
|
403
|
-
if (value instanceof JSONArray) {
|
|
404
|
-
value = toList((JSONArray) value);
|
|
405
|
-
} else if (value instanceof JSONObject) {
|
|
406
|
-
value = toMap((JSONObject) value);
|
|
407
|
-
}
|
|
408
|
-
map.put(key, value);
|
|
409
|
-
}
|
|
410
|
-
return map;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
public static List<Object> toList(JSONArray array) throws JSONException {
|
|
414
|
-
List<Object> list = new ArrayList<Object>();
|
|
415
|
-
for (int i = 0; i < array.length(); i++) {
|
|
416
|
-
Object value = array.get(i);
|
|
417
|
-
if (value instanceof JSONArray) {
|
|
418
|
-
value = toList((JSONArray) value);
|
|
419
|
-
} else if (value instanceof JSONObject) {
|
|
420
|
-
value = toMap((JSONObject) value);
|
|
421
|
-
}
|
|
422
|
-
list.add(value);
|
|
423
|
-
}
|
|
424
|
-
return list;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
@ReactMethod
|
|
428
|
-
public void initCGSDK(String env)
|
|
429
|
-
{
|
|
430
|
-
CustomerGlu.getInstance().initializeSdk(getReactApplicationContext(),env);
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
@ReactMethod
|
|
434
|
-
public void openWallet(ReadableMap readableMap) {
|
|
435
|
-
try {
|
|
436
|
-
if (readableMap.hasKey("nudgeConfiguration")) {
|
|
437
|
-
Log.e(TAG, "openwallet-----" + readableMap.toString());
|
|
438
|
-
|
|
439
|
-
JSONObject nudgeConfigurationdata;
|
|
440
|
-
NudgeConfiguration nudgeConfiguration = new NudgeConfiguration();
|
|
441
|
-
JSONObject obj = convertMapToJson(readableMap);
|
|
442
|
-
nudgeConfigurationdata = obj.getJSONObject("nudgeConfiguration");
|
|
443
|
-
if (nudgeConfigurationdata.has("layout")) {
|
|
444
|
-
nudgeConfiguration.setLayout(nudgeConfigurationdata.getString("layout"));
|
|
445
|
-
}
|
|
446
|
-
if (nudgeConfigurationdata.has("opacity")) {
|
|
447
|
-
nudgeConfiguration.setOpacity(Double.parseDouble(nudgeConfigurationdata.getString("opacity")));
|
|
448
|
-
}
|
|
449
|
-
if (nudgeConfigurationdata.has("closeOnDeepLink")) {
|
|
450
|
-
nudgeConfiguration.setCloseOnDeepLink(nudgeConfigurationdata.getBoolean("closeOnDeepLink"));
|
|
451
|
-
}
|
|
452
|
-
if (nudgeConfigurationdata.has("absoluteHeight")) {
|
|
453
|
-
nudgeConfiguration.setAbsoluteHeight(Double.parseDouble(nudgeConfigurationdata.getString("absoluteHeight")));
|
|
454
|
-
}
|
|
455
|
-
if (nudgeConfigurationdata.has("relativeHeight")) {
|
|
456
|
-
nudgeConfiguration.setRelativeHeight(Double.parseDouble(nudgeConfigurationdata.getString("relativeHeight")));
|
|
457
|
-
}
|
|
458
|
-
CustomerGlu.getInstance().openWallet(getReactApplicationContext(), nudgeConfiguration);
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
} else {
|
|
462
|
-
CustomerGlu.getInstance().openWallet(getReactApplicationContext());
|
|
463
|
-
}
|
|
464
|
-
} catch (JSONException e) {
|
|
465
|
-
e.printStackTrace();
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
@ReactMethod
|
|
471
|
-
public void loadCampaignById(String id, ReadableMap readableMap) {
|
|
472
|
-
Log.e(TAG, "loadCampaignById-----" + readableMap.toString());
|
|
473
|
-
try {
|
|
474
|
-
JSONObject nudgeConfigurationdata;
|
|
475
|
-
NudgeConfiguration nudgeConfiguration = new NudgeConfiguration();
|
|
476
|
-
if (readableMap.hasKey("nudgeConfiguration")) {
|
|
477
|
-
JSONObject obj = convertMapToJson(readableMap);
|
|
478
|
-
nudgeConfigurationdata = obj.getJSONObject("nudgeConfiguration");
|
|
479
|
-
if (nudgeConfigurationdata.has("layout")) {
|
|
480
|
-
nudgeConfiguration.setLayout(nudgeConfigurationdata.getString("layout"));
|
|
481
|
-
}
|
|
482
|
-
if (nudgeConfigurationdata.has("opacity")) {
|
|
483
|
-
nudgeConfiguration.setOpacity(Double.parseDouble(nudgeConfigurationdata.getString("opacity")));
|
|
484
|
-
}
|
|
485
|
-
if (nudgeConfigurationdata.has("closeOnDeepLink")) {
|
|
486
|
-
nudgeConfiguration.setCloseOnDeepLink(nudgeConfigurationdata.getBoolean("closeOnDeepLink"));
|
|
487
|
-
}
|
|
488
|
-
if (nudgeConfigurationdata.has("absoluteHeight")) {
|
|
489
|
-
nudgeConfiguration.setAbsoluteHeight(Double.parseDouble(nudgeConfigurationdata.getString("absoluteHeight")));
|
|
490
|
-
}
|
|
491
|
-
if (nudgeConfigurationdata.has("relativeHeight")) {
|
|
492
|
-
nudgeConfiguration.setRelativeHeight(Double.parseDouble(nudgeConfigurationdata.getString("relativeHeight")));
|
|
493
|
-
}
|
|
494
|
-
CustomerGlu.getInstance().loadCampaignById(getReactApplicationContext(), id, nudgeConfiguration);
|
|
495
|
-
} else {
|
|
496
|
-
CustomerGlu.getInstance().loadCampaignById(getReactApplicationContext(), id);
|
|
497
|
-
}
|
|
498
|
-
} catch (JSONException e) {
|
|
499
|
-
e.printStackTrace();
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
@ReactMethod
|
|
506
|
-
public void loadCampaignWithUrl(String url, ReadableMap readableMap) {
|
|
507
|
-
Log.e(TAG, "loadCampaignByUrl-----" + readableMap.toString());
|
|
508
|
-
try {
|
|
509
|
-
JSONObject nudgeConfigurationdata;
|
|
510
|
-
NudgeConfiguration nudgeConfiguration = new NudgeConfiguration();
|
|
511
|
-
if (readableMap.hasKey("nudgeConfiguration")) {
|
|
512
|
-
JSONObject obj = convertMapToJson(readableMap);
|
|
513
|
-
nudgeConfigurationdata = obj.getJSONObject("nudgeConfiguration");
|
|
514
|
-
if (nudgeConfigurationdata.has("layout")) {
|
|
515
|
-
nudgeConfiguration.setLayout(nudgeConfigurationdata.getString("layout"));
|
|
516
|
-
}
|
|
517
|
-
if (nudgeConfigurationdata.has("opacity")) {
|
|
518
|
-
nudgeConfiguration.setOpacity(Double.parseDouble(nudgeConfigurationdata.getString("opacity")));
|
|
519
|
-
}
|
|
520
|
-
if (nudgeConfigurationdata.has("closeOnDeepLink")) {
|
|
521
|
-
nudgeConfiguration.setCloseOnDeepLink(nudgeConfigurationdata.getBoolean("closeOnDeepLink"));
|
|
522
|
-
}
|
|
523
|
-
if (nudgeConfigurationdata.has("absoluteHeight")) {
|
|
524
|
-
nudgeConfiguration.setAbsoluteHeight(Double.parseDouble(nudgeConfigurationdata.getString("absoluteHeight")));
|
|
525
|
-
}
|
|
526
|
-
if (nudgeConfigurationdata.has("relativeHeight")) {
|
|
527
|
-
nudgeConfiguration.setRelativeHeight(Double.parseDouble(nudgeConfigurationdata.getString("relativeHeight")));
|
|
528
|
-
}
|
|
529
|
-
CustomerGlu.getInstance().displayCGNudge(getReactApplicationContext(), url, "",nudgeConfiguration);
|
|
530
|
-
} else {
|
|
531
|
-
CustomerGlu.getInstance().displayCGNudge(getReactApplicationContext(), url,"",nudgeConfiguration);
|
|
532
|
-
}
|
|
533
|
-
} catch (JSONException e) {
|
|
534
|
-
e.printStackTrace();
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
@ReactMethod
|
|
541
|
-
public void enableAnalytic(Boolean bool) {
|
|
542
|
-
CustomerGlu.getInstance().enableAnalyticsEvent(bool);
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
@ReactMethod
|
|
546
|
-
public void allowAnonymousRegistration(Boolean bool) {
|
|
547
|
-
CustomerGlu.getInstance().allowAnonymousRegistration(bool);
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
@ReactMethod
|
|
552
|
-
public void disableGluSdk(Boolean bool) {
|
|
553
|
-
CustomerGlu.getInstance().disableGluSdk(bool);
|
|
554
|
-
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
@ReactMethod
|
|
558
|
-
public void testIntegration()
|
|
559
|
-
{
|
|
560
|
-
CustomerGlu.getInstance().testIntegration();
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
@ReactMethod
|
|
564
|
-
public void configureLoaderColour(String color) {
|
|
565
|
-
CustomerGlu.getInstance().configureLoaderColour(getReactApplicationContext(), color);
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
@ReactMethod
|
|
569
|
-
public void addMarginsForPIP(int horizontal, int vertical, String type) {
|
|
570
|
-
if (type.equalsIgnoreCase("px")) {
|
|
571
|
-
CustomerGlu.getInstance().addMarginForPIP(horizontal, vertical, PIPHelper.DISPLAY_UNIT_TYPE.PX);
|
|
572
|
-
}else{
|
|
573
|
-
CustomerGlu.getInstance().addMarginForPIP(horizontal, vertical, PIPHelper.DISPLAY_UNIT_TYPE.DP);
|
|
574
|
-
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
@ReactMethod
|
|
578
|
-
public void addDelayForPIP(int delay) {
|
|
579
|
-
|
|
580
|
-
CustomerGlu.getInstance().addDelayForPIP(delay);
|
|
581
|
-
}
|
|
582
|
-
// @ReactMethod
|
|
583
|
-
// public void setPIPEnabled(boolean enabled) {
|
|
584
|
-
// CustomerGlu.getInstance().setPIPEnabled(getReactApplicationContext().getCurrentActivity(),enabled);
|
|
585
|
-
// }
|
|
586
|
-
// @ReactMethod
|
|
587
|
-
// public boolean isPIPEnabled() {
|
|
588
|
-
|
|
589
|
-
// return CustomerGlu.getInstance().isPIPEnabled();
|
|
590
|
-
// }
|
|
591
|
-
// @ReactMethod
|
|
592
|
-
// public void dismissPIP() {
|
|
593
|
-
|
|
594
|
-
// CustomerGlu.getInstance().dismissPIP();
|
|
595
|
-
// }
|
|
596
|
-
@ReactMethod
|
|
597
|
-
public void isCampaignValid( String campaignId,String dataFlag,Promise promise) {
|
|
598
|
-
CGConstants.DATA_FLAG flag = CGConstants.DATA_FLAG.API;
|
|
599
|
-
|
|
600
|
-
if (dataFlag.equalsIgnoreCase("CACHE"))
|
|
601
|
-
{
|
|
602
|
-
flag = CGConstants.DATA_FLAG.CACHED;
|
|
603
|
-
}
|
|
604
|
-
CustomerGlu.getInstance().isCampaignValid(campaignId, flag, new CampaignValidListener() {
|
|
605
|
-
@Override
|
|
606
|
-
public void validCampaign() {
|
|
607
|
-
promise.resolve(true);
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
@Override
|
|
611
|
-
public void invalidCampaign() {
|
|
612
|
-
promise.resolve(false);
|
|
613
|
-
}
|
|
614
|
-
});
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
@ReactMethod
|
|
618
|
-
public void getCampaignStatus( String campaignId,String dataFlag,Promise promise) {
|
|
619
|
-
CGConstants.DATA_FLAG flag = CGConstants.DATA_FLAG.API;
|
|
620
|
-
|
|
621
|
-
if (dataFlag.equalsIgnoreCase("CACHE"))
|
|
622
|
-
{
|
|
623
|
-
flag = CGConstants.DATA_FLAG.CACHED;
|
|
624
|
-
}
|
|
625
|
-
CustomerGlu.getInstance().getCampaignStatus(campaignId, CGConstants.DATA_FLAG.API, new CampaignStatusListener() {
|
|
626
|
-
@Override
|
|
627
|
-
public void onStatusReceived(CGConstants.CAMPAIGN_STATE campaignState) {
|
|
628
|
-
promise.resolve(campaignState.toString());
|
|
629
|
-
}
|
|
630
|
-
});
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
//2jan2023
|
|
634
|
-
|
|
635
|
-
@ReactMethod
|
|
636
|
-
public void configureDarkBackgroundColor(String color) {
|
|
637
|
-
if(color!=null){
|
|
638
|
-
CustomerGlu.getInstance().configureDarkBackgroundColor(color);}
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
@ReactMethod
|
|
642
|
-
public void configureLightBackgroundColor(String color) {
|
|
643
|
-
if(color!=null){
|
|
644
|
-
CustomerGlu.getInstance().configureLightBackgroundColor(color);}
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
@ReactMethod
|
|
648
|
-
public void listenToDarkMode(boolean isdarkmode) {
|
|
649
|
-
CustomerGlu.getInstance().listenToSystemDarkMode(isdarkmode);
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
@ReactMethod
|
|
653
|
-
public void enableDarkMode(boolean darkmode) {
|
|
654
|
-
CustomerGlu.getInstance().enableDarkMode(darkmode);
|
|
655
|
-
}
|
|
656
|
-
//end
|
|
657
|
-
|
|
658
|
-
//16jan2023
|
|
659
|
-
@ReactMethod
|
|
660
|
-
public void configureLightLoaderURL(String url){
|
|
661
|
-
if(url!=null){
|
|
662
|
-
CustomerGlu.getInstance().configureLightLoaderURL(getReactApplicationContext(), url);
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
@ReactMethod
|
|
666
|
-
public void configureDarkLoaderURL(String url){
|
|
667
|
-
if(url!=null){
|
|
668
|
-
CustomerGlu.getInstance().configureDarkLoaderURL(getReactApplicationContext(), url);
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
}
|
|
672
|
-
@ReactMethod
|
|
673
|
-
public void configureLightEmbedLoaderURL(String url){
|
|
674
|
-
if(url!=null){
|
|
675
|
-
CustomerGlu.getInstance().configureLightEmbedLoaderURL(getReactApplicationContext(), url);
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
}
|
|
679
|
-
@ReactMethod
|
|
680
|
-
public void configureDarkEmbedLoaderURL(String url){
|
|
681
|
-
if(url!=null){
|
|
682
|
-
CustomerGlu.getInstance().configureDarkEmbedLoaderURL(getReactApplicationContext(), url);
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
//end
|
|
686
|
-
@ReactMethod
|
|
687
|
-
public void configureStatusBarColour(String color) {
|
|
688
|
-
CustomerGlu.getInstance().configureStatusBarColour(color);
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
@ReactMethod
|
|
692
|
-
public void configureSafeArea(ReadableMap map) {
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
@ReactMethod
|
|
696
|
-
public void configureLoadingScreenColor(String clr) {
|
|
697
|
-
Log.e(TAG, "color->>>>>>" + clr);
|
|
698
|
-
if (clr != null && clr.length() == 9) {
|
|
699
|
-
int red = Integer.valueOf(clr.substring(1, 3), 16);
|
|
700
|
-
int green = Integer.valueOf(clr.substring(3, 5), 16);
|
|
701
|
-
int blue = Integer.valueOf(clr.substring(5, 7), 16);
|
|
702
|
-
int alpha = Integer.parseInt(clr.substring(7, 9), 16);
|
|
703
|
-
String alphaHex = To00Hex(alpha);
|
|
704
|
-
String blueHex = To00Hex(blue);
|
|
705
|
-
String greenHex = To00Hex(green);
|
|
706
|
-
String redHex = To00Hex(red);
|
|
707
|
-
StringBuilder str = new StringBuilder("#");
|
|
708
|
-
str.append(alphaHex);
|
|
709
|
-
str.append(redHex);
|
|
710
|
-
str.append(greenHex);
|
|
711
|
-
str.append(blueHex);
|
|
712
|
-
Log.e(TAG, "colo1-----" + red + " " + green + " " + blue + " " + alpha + " " + str.toString());
|
|
713
|
-
|
|
714
|
-
CustomerGlu.getInstance().configureLoadingScreenColor(str.toString());
|
|
715
|
-
|
|
716
|
-
} else {
|
|
717
|
-
CustomerGlu.getInstance().configureLoadingScreenColor(clr);
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
private static String To00Hex(int value) {
|
|
722
|
-
String hex = "00".concat(Integer.toHexString(value));
|
|
723
|
-
return hex.substring(hex.length() - 2, hex.length());
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
@ReactMethod
|
|
727
|
-
public void enablePrecaching() {
|
|
728
|
-
CustomerGlu.getInstance().enablePrecaching(getReactApplicationContext());
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
@ReactMethod
|
|
732
|
-
public void gluSDKDebuggingMode(Boolean bol) {
|
|
733
|
-
CustomerGlu.getInstance().gluSDKDebuggingMode(getCurrentActivity(), bol);
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
@ReactMethod
|
|
737
|
-
public void enableEntryPoints(Boolean bol) {
|
|
738
|
-
CustomerGlu.getInstance().enableEntryPoints(getCurrentActivity(), bol);
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
@ReactMethod
|
|
742
|
-
public void closeWebView(Boolean bol) {
|
|
743
|
-
CustomerGlu.getInstance().closeWebviewOnDeeplinkEvent(bol);
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
@ReactMethod
|
|
747
|
-
public void SetDefaultBannerImage(String url) {
|
|
748
|
-
CustomerGlu.getInstance().setDefaultBannerImage(getCurrentActivity(), url);
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
@ReactMethod
|
|
752
|
-
public void UpdateUserAttributes(ReadableMap map) {
|
|
753
|
-
if (map != null) {
|
|
754
|
-
JSONObject jsonObject = convertMapToJson(map);
|
|
755
|
-
HashMap<String, Object> userData = new Gson().fromJson(jsonObject.toString(), HashMap.class);
|
|
756
|
-
CustomerGlu.getInstance().updateUserAttributes(getReactApplicationContext(), userData);
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
@ReactMethod
|
|
761
|
-
public void UpdateProfile(ReadableMap map) {
|
|
762
|
-
if (map != null) {
|
|
763
|
-
JSONObject jsonObject = convertMapToJson(map);
|
|
764
|
-
HashMap<String, Object> userData = new Gson().fromJson(jsonObject.toString(), HashMap.class);
|
|
765
|
-
CustomerGlu.getInstance().updateProfile(getReactApplicationContext(), userData, new DataListner() {
|
|
766
|
-
@Override
|
|
767
|
-
public void onSuccess(Boolean registerModal) {
|
|
768
|
-
// Toast.makeText(getReactApplicationContext(), "Profile Updated", Toast.LENGTH_SHORT).show();
|
|
769
|
-
Log.d(TAG, "Profile Updated!...");
|
|
770
|
-
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
@Override
|
|
774
|
-
public void onFail(String message) {
|
|
775
|
-
Log.d(TAG, "Profile Not Updated!..." + message.toString());
|
|
776
|
-
|
|
777
|
-
}
|
|
778
|
-
});
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
@ReactMethod
|
|
783
|
-
public void DisplayCGNotification(ReadableMap data, Boolean autoclosewebview) {
|
|
784
|
-
JSONObject jsonObject = convertMapToJson(data);
|
|
785
|
-
if (getAppIcon(getReactApplicationContext()) != 0) {
|
|
786
|
-
CustomerGlu.getInstance().displayCustomerGluNotification(getReactApplicationContext(), jsonObject, getAppIcon(getReactApplicationContext()), 0.5, autoclosewebview);
|
|
787
|
-
} else {
|
|
788
|
-
CustomerGlu.getInstance().displayCustomerGluNotification(getReactApplicationContext(), jsonObject, R.drawable.notification, 0.5, autoclosewebview);
|
|
789
|
-
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
private static int getAppIcon(Context context) {
|
|
794
|
-
|
|
795
|
-
try {
|
|
796
|
-
ApplicationInfo ai = context.getPackageManager().getApplicationInfo(
|
|
797
|
-
context.getPackageName(), PackageManager.GET_META_DATA);
|
|
798
|
-
Bundle bundle = ai.metaData;
|
|
799
|
-
int myAPIKey = bundle.getInt("CUSTOMERGLU_NOTIFICATION_ICON");
|
|
800
|
-
return myAPIKey;
|
|
801
|
-
} catch (Exception e) {
|
|
802
|
-
Comman.printErrorLogs(e.toString());
|
|
803
|
-
return 0;
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
@ReactMethod
|
|
809
|
-
public void DisplayCGBackgroundNotification(ReadableMap data, Boolean autoclosewebview) {
|
|
810
|
-
JSONObject jsonObject = convertMapToJson(data);
|
|
811
|
-
Log.d(TAG, "DisplayCGBackgroundNotification---" + jsonObject + " " + autoclosewebview);
|
|
812
|
-
CustomerGlu.getInstance().displayCustomerGluBackgroundNotification(getReactApplicationContext(), jsonObject, autoclosewebview);
|
|
813
|
-
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
@ReactMethod
|
|
818
|
-
public void CGApplication() {
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
@ReactMethod
|
|
824
|
-
public void GetRefferalId(String url, Promise promise) throws MalformedURLException {
|
|
825
|
-
Uri myURL = Uri.parse(url);
|
|
826
|
-
String referID = CustomerGlu.getInstance().getReferralId(myURL);
|
|
827
|
-
promise.resolve(referID);
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
@ReactMethod
|
|
831
|
-
public void SetCurrentClassName(String classname) {
|
|
832
|
-
this.Myclassname = classname;
|
|
833
|
-
runOnUiThread(new Runnable() {
|
|
834
|
-
@Override
|
|
835
|
-
public void run() {
|
|
836
|
-
CustomerGlu.getInstance().setScreenName(getReactApplicationContext(), classname);
|
|
837
|
-
}
|
|
838
|
-
});
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
@ReactMethod
|
|
842
|
-
public void SetCGCurrentClassName(String classname,String time,Promise promise) {
|
|
843
|
-
this.Myclassname = classname;
|
|
844
|
-
runOnUiThread(new Runnable() {
|
|
845
|
-
@Override
|
|
846
|
-
public void run() {
|
|
847
|
-
CustomerGlu.getInstance().setScreenName(getReactApplicationContext(), classname);
|
|
848
|
-
}
|
|
849
|
-
});
|
|
850
|
-
promise.resolve(time);
|
|
851
|
-
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
@ReactMethod
|
|
856
|
-
public void configureWhiteListedDomains(ReadableArray readableArray) {
|
|
857
|
-
try {
|
|
858
|
-
JSONArray obj = convertArrayToJson(readableArray);
|
|
859
|
-
ArrayList<String> listdata = new ArrayList<String>();
|
|
860
|
-
for (int i = 0; i < obj.length(); i++) {
|
|
861
|
-
listdata.add((String) obj.get(i));
|
|
862
|
-
|
|
863
|
-
}
|
|
864
|
-
CustomerGlu.getInstance().configureWhiteListedDomains(listdata);
|
|
865
|
-
} catch (JSONException e) {
|
|
866
|
-
e.printStackTrace();
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
@ReactMethod
|
|
875
|
-
public void configureDomainCodeMsg(ReadableMap readableMap) {
|
|
876
|
-
try {
|
|
877
|
-
JSONObject obj = convertMapToJson(readableMap);
|
|
878
|
-
int code = obj.has("code") ? (int) obj.get("code") : 0;
|
|
879
|
-
String msg = obj.has("msg") ? (String) obj.get("msg") : "";
|
|
880
|
-
CustomerGlu.getInstance().configureDomainCodeMsg(code, msg);
|
|
881
|
-
} catch (JSONException e) {
|
|
882
|
-
e.printStackTrace();
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
private static JSONObject convertMapToJson(ReadableMap readableMap) {
|
|
889
|
-
JSONObject jsonObject = new JSONObject();
|
|
890
|
-
if (readableMap == null) {
|
|
891
|
-
return null;
|
|
892
|
-
}
|
|
893
|
-
ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
|
|
894
|
-
if (!iterator.hasNextKey()) {
|
|
895
|
-
return null;
|
|
896
|
-
}
|
|
897
|
-
while (iterator.hasNextKey()) {
|
|
898
|
-
String key = iterator.nextKey();
|
|
899
|
-
ReadableType readableType = readableMap.getType(key);
|
|
900
|
-
Log.e(TAG, "readableType" + readableType + " " + readableMap.toString());
|
|
901
|
-
try {
|
|
902
|
-
switch (readableType) {
|
|
903
|
-
case Null:
|
|
904
|
-
jsonObject.put(key, null);
|
|
905
|
-
break;
|
|
906
|
-
case Boolean:
|
|
907
|
-
jsonObject.put(key, readableMap.getBoolean(key));
|
|
908
|
-
break;
|
|
909
|
-
case Number:
|
|
910
|
-
// Can be int or double.
|
|
911
|
-
jsonObject.put(key, readableMap.getInt(key));
|
|
912
|
-
break;
|
|
913
|
-
case String:
|
|
914
|
-
jsonObject.put(key, readableMap.getString(key));
|
|
915
|
-
break;
|
|
916
|
-
case Array:
|
|
917
|
-
jsonObject.put(key, convertArrayToJson(readableMap.getArray(key)));
|
|
918
|
-
break;
|
|
919
|
-
case Map:
|
|
920
|
-
jsonObject.put(key, convertMapToJson(readableMap.getMap(key)));
|
|
921
|
-
break;
|
|
922
|
-
default:
|
|
923
|
-
// Do nothing and fail silently
|
|
924
|
-
}
|
|
925
|
-
} catch (JSONException ex) {
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
return jsonObject;
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
private static JSONArray convertArrayToJson(ReadableArray readableArray) throws JSONException {
|
|
932
|
-
JSONArray array = new JSONArray();
|
|
933
|
-
for (int i = 0; i < readableArray.size(); i++) {
|
|
934
|
-
switch (readableArray.getType(i)) {
|
|
935
|
-
case Null:
|
|
936
|
-
break;
|
|
937
|
-
case Boolean:
|
|
938
|
-
array.put(readableArray.getBoolean(i));
|
|
939
|
-
break;
|
|
940
|
-
case Number:
|
|
941
|
-
array.put(readableArray.getDouble(i));
|
|
942
|
-
break;
|
|
943
|
-
case String:
|
|
944
|
-
array.put(readableArray.getString(i));
|
|
945
|
-
break;
|
|
946
|
-
case Map:
|
|
947
|
-
array.put(convertMapToJson(readableArray.getMap(i)));
|
|
948
|
-
break;
|
|
949
|
-
case Array:
|
|
950
|
-
array.put(convertArrayToJson(readableArray.getArray(i)));
|
|
951
|
-
break;
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
return array;
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
public static WritableMap jsonToWritableMap(JSONObject jsonObject) {
|
|
959
|
-
WritableMap writableMap = new WritableNativeMap();
|
|
960
|
-
if (jsonObject == null) {
|
|
961
|
-
return null;
|
|
962
|
-
}
|
|
963
|
-
Iterator<String> iterator = jsonObject.keys();
|
|
964
|
-
if (!iterator.hasNext()) {
|
|
965
|
-
return null;
|
|
966
|
-
}
|
|
967
|
-
while (iterator.hasNext()) {
|
|
968
|
-
String key = iterator.next();
|
|
969
|
-
try {
|
|
970
|
-
Object value = jsonObject.get(key);
|
|
971
|
-
if (value == null) {
|
|
972
|
-
writableMap.putNull(key);
|
|
973
|
-
} else if (value instanceof Boolean) {
|
|
974
|
-
writableMap.putBoolean(key, (Boolean) value);
|
|
975
|
-
} else if (value instanceof Integer) {
|
|
976
|
-
writableMap.putInt(key, (Integer) value);
|
|
977
|
-
} else if (value instanceof Double) {
|
|
978
|
-
writableMap.putDouble(key, (Double) value);
|
|
979
|
-
} else if (value instanceof String) {
|
|
980
|
-
writableMap.putString(key, (String) value);
|
|
981
|
-
} else if (value instanceof JSONObject) {
|
|
982
|
-
writableMap.putMap(key, jsonToWritableMap((JSONObject) value));
|
|
983
|
-
} else if (value instanceof JSONArray) {
|
|
984
|
-
writableMap.putArray(key, jsonArrayToWritableArray((JSONArray) value));
|
|
985
|
-
}
|
|
986
|
-
} catch (JSONException ex) {
|
|
987
|
-
// Do nothing and fail silently
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
return writableMap;
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
public static WritableArray jsonArrayToWritableArray(JSONArray jsonArray) {
|
|
995
|
-
WritableArray writableArray = new WritableNativeArray();
|
|
996
|
-
|
|
997
|
-
if (jsonArray == null) {
|
|
998
|
-
return null;
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
if (jsonArray.length() <= 0) {
|
|
1002
|
-
return null;
|
|
1003
|
-
}
|
|
1004
|
-
|
|
1005
|
-
for (int i = 0; i < jsonArray.length(); i++) {
|
|
1006
|
-
try {
|
|
1007
|
-
Object value = jsonArray.get(i);
|
|
1008
|
-
if (value == null) {
|
|
1009
|
-
writableArray.pushNull();
|
|
1010
|
-
} else if (value instanceof Boolean) {
|
|
1011
|
-
writableArray.pushBoolean((Boolean) value);
|
|
1012
|
-
} else if (value instanceof Integer) {
|
|
1013
|
-
writableArray.pushInt((Integer) value);
|
|
1014
|
-
} else if (value instanceof Double) {
|
|
1015
|
-
writableArray.pushDouble((Double) value);
|
|
1016
|
-
} else if (value instanceof String) {
|
|
1017
|
-
writableArray.pushString((String) value);
|
|
1018
|
-
} else if (value instanceof JSONObject) {
|
|
1019
|
-
writableArray.pushMap(jsonToWritableMap((JSONObject) value));
|
|
1020
|
-
} else if (value instanceof JSONArray) {
|
|
1021
|
-
writableArray.pushArray(jsonArrayToWritableArray((JSONArray) value));
|
|
1022
|
-
}
|
|
1023
|
-
} catch (JSONException e) {
|
|
1024
|
-
// Do nothing and fail silently
|
|
1025
|
-
}
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
return writableArray;
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
// public static native int nativeMultiply(int a, int b);
|
|
1033
|
-
}
|