reactnative-plugin-appice 1.5.9 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +37 -37
  2. package/android/README.md +14 -14
  3. package/android/android.iml +150 -150
  4. package/android/build.gradle +152 -152
  5. package/android/gitignore +47 -47
  6. package/android/src/main/AndroidManifest.xml +234 -234
  7. package/android/src/main/java/com/reactlibrary/AppICEUtils.java +38 -38
  8. package/android/src/main/java/com/reactlibrary/AppIceReactPluginModule.java +473 -473
  9. package/android/src/main/java/com/reactlibrary/AppIceReactPluginPackage.java +28 -28
  10. package/android/src/main/java/com/reactlibrary/CampaignCampsReceiver.java +73 -73
  11. package/android/src/main/java/com/reactlibrary/InAppWebView.java +67 -67
  12. package/android/src/main/java/com/reactlibrary/NotificationEventService.java +62 -62
  13. package/example/App.js +148 -148
  14. package/example/Gemfile +6 -6
  15. package/example/__tests__/App-test.js +14 -14
  16. package/example/android/app/_BUCK +55 -55
  17. package/example/android/app/build.gradle +320 -320
  18. package/example/android/app/build_defs.bzl +19 -19
  19. package/example/android/app/proguard-rules.pro +10 -10
  20. package/example/android/app/src/debug/AndroidManifest.xml +13 -13
  21. package/example/android/app/src/debug/java/com/example/ReactNativeFlipper.java +73 -73
  22. package/example/android/app/src/main/AndroidManifest.xml +72 -72
  23. package/example/android/app/src/main/java/com/example/MainActivity.java +48 -48
  24. package/example/android/app/src/main/java/com/example/MainApplication.java +91 -91
  25. package/example/android/app/src/main/java/com/example/newarchitecture/MainApplicationReactNativeHost.java +116 -116
  26. package/example/android/app/src/main/java/com/example/newarchitecture/components/MainComponentsRegistry.java +36 -36
  27. package/example/android/app/src/main/java/com/example/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java +48 -48
  28. package/example/android/app/src/main/jni/Android.mk +48 -48
  29. package/example/android/app/src/main/jni/MainApplicationModuleProvider.cpp +24 -24
  30. package/example/android/app/src/main/jni/MainApplicationModuleProvider.h +16 -16
  31. package/example/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp +45 -45
  32. package/example/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h +38 -38
  33. package/example/android/app/src/main/jni/MainComponentsRegistry.cpp +61 -61
  34. package/example/android/app/src/main/jni/MainComponentsRegistry.h +32 -32
  35. package/example/android/app/src/main/jni/OnLoad.cpp +11 -11
  36. package/example/android/app/src/main/res/drawable/rn_edit_text_material.xml +36 -36
  37. package/example/android/app/src/main/res/values/strings.xml +3 -3
  38. package/example/android/app/src/main/res/values/styles.xml +9 -9
  39. package/example/android/build.gradle +53 -53
  40. package/example/android/gradle/wrapper/gradle-wrapper.properties +5 -5
  41. package/example/android/gradle.properties +40 -40
  42. package/example/android/gradlew +234 -234
  43. package/example/android/settings.gradle +11 -11
  44. package/example/app.json +3 -3
  45. package/example/babel.config.js +3 -3
  46. package/example/index.js +9 -9
  47. package/example/ios/Podfile +44 -44
  48. package/example/ios/Podfile.lock +561 -561
  49. package/example/ios/_xcode.env +11 -11
  50. package/example/ios/example/AppDelegate.h +8 -8
  51. package/example/ios/example/AppDelegate.mm +174 -174
  52. package/example/ios/example/Images.xcassets/AppIcon.appiconset/Contents.json +53 -53
  53. package/example/ios/example/Images.xcassets/Contents.json +6 -6
  54. package/example/ios/example/Info.plist +62 -62
  55. package/example/ios/example/LaunchScreen.storyboard +47 -47
  56. package/example/ios/example/example.entitlements +8 -8
  57. package/example/ios/example/main.m +10 -10
  58. package/example/ios/example.xcodeproj/project.pbxproj +712 -712
  59. package/example/ios/example.xcodeproj/xcshareddata/xcschemes/example.xcscheme +88 -88
  60. package/example/ios/example.xcworkspace/contents.xcworkspacedata +10 -10
  61. package/example/ios/example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -8
  62. package/example/ios/exampleTests/Info.plist +24 -24
  63. package/example/ios/exampleTests/exampleTests.m +66 -66
  64. package/example/metro.config.js +17 -17
  65. package/example/package.json +34 -34
  66. package/index.js +124 -124
  67. package/ios/AppICEReactEvent.h +23 -23
  68. package/ios/AppICEReactEvent.m +86 -77
  69. package/ios/AppIceReactPlugin.h +22 -22
  70. package/ios/AppIceReactPlugin.m +190 -191
  71. package/ios/AppIceReactPlugin.xcodeproj/project.pbxproj +364 -434
  72. package/ios/AppIceReactPlugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -4
  73. package/ios/AppIceReactPlugin.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -8
  74. package/ios/AppIceReactPlugin.xcodeproj/xcuserdata/Adi.xcuserdatad/xcschemes/xcschememanagement.plist +14 -14
  75. package/ios/AppIceReactPlugin.xcworkspace/contents.xcworkspacedata +10 -10
  76. package/ios/AppIceReactPlugin.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -8
  77. package/ios/Podfile +10 -10
  78. package/ios/Podfile.lock +3 -3
  79. package/ios/Pods/Manifest.lock +3 -3
  80. package/ios/Pods/Pods.xcodeproj/project.pbxproj +395 -395
  81. package/ios/Pods/Pods.xcodeproj/xcuserdata/Adi.xcuserdatad/xcschemes/Pods-AppIceReactPlugin.xcscheme +58 -58
  82. package/ios/Pods/Pods.xcodeproj/xcuserdata/Adi.xcuserdatad/xcschemes/xcschememanagement.plist +18 -18
  83. package/ios/Pods/Target Support Files/Pods-AppIceReactPlugin/Pods-AppIceReactPlugin-Info.plist +26 -26
  84. package/ios/Pods/Target Support Files/Pods-AppIceReactPlugin/Pods-AppIceReactPlugin-acknowledgements.markdown +3 -3
  85. package/ios/Pods/Target Support Files/Pods-AppIceReactPlugin/Pods-AppIceReactPlugin-acknowledgements.plist +29 -29
  86. package/ios/Pods/Target Support Files/Pods-AppIceReactPlugin/Pods-AppIceReactPlugin-dummy.m +5 -5
  87. package/ios/Pods/Target Support Files/Pods-AppIceReactPlugin/Pods-AppIceReactPlugin-umbrella.h +16 -16
  88. package/ios/Pods/Target Support Files/Pods-AppIceReactPlugin/Pods-AppIceReactPlugin.debug.xcconfig +6 -6
  89. package/ios/Pods/Target Support Files/Pods-AppIceReactPlugin/Pods-AppIceReactPlugin.modulemap +6 -6
  90. package/ios/Pods/Target Support Files/Pods-AppIceReactPlugin/Pods-AppIceReactPlugin.release.xcconfig +6 -6
  91. package/package.json +40 -40
  92. package/reactnative-plugin-appice.podspec +30 -30
  93. package/ios/AppICESDK/appICE.momd/VersionInfo.plist +0 -0
  94. package/ios/AppICESDK/appICE.momd/appICE 2.mom +0 -0
  95. package/ios/AppICESDK/appICE.momd/appICE 3.mom +0 -0
  96. package/ios/AppICESDK/appICE.momd/appICE 4.mom +0 -0
  97. package/ios/AppICESDK/appICE.momd/appICE 4.omo +0 -0
  98. package/ios/AppICESDK/appICE.momd/appICE.mom +0 -0
  99. package/ios/AppICESDK/appICE.momd/appICE2.mom +0 -0
  100. package/ios/AppICESDK/appICEBundle.bundle/APPChildViewController.nib +0 -0
  101. package/ios/AppICESDK/appICEBundle.bundle/AppICE_btn.png +0 -0
  102. package/ios/AppICESDK/appICEBundle.bundle/Black button.png +0 -0
  103. package/ios/AppICESDK/appICEBundle.bundle/HAlfFooterNOTINAppViewController.nib +0 -0
  104. package/ios/AppICESDK/appICEBundle.bundle/HAlfHeaderINAppViewController.nib +0 -0
  105. package/ios/AppICESDK/appICEBundle.bundle/HAlfINAppViewController.nib +0 -0
  106. package/ios/AppICESDK/appICEBundle.bundle/INAppViewController.nib/objects-11.0+.nib +0 -0
  107. package/ios/AppICESDK/appICEBundle.bundle/INAppViewController.nib/runtime.nib +0 -0
  108. package/ios/AppICESDK/appICEBundle.bundle/Info.plist +0 -0
  109. package/ios/AppICESDK/appICEBundle.bundle/RatingViewController.nib +0 -0
  110. package/ios/AppICESDK/appICEBundle.bundle/SurveyViewController.nib +0 -0
  111. package/ios/AppICESDK/appICEBundle.bundle/checked.png +0 -0
  112. package/ios/AppICESDK/appICEBundle.bundle/close-button.png +0 -0
  113. package/ios/AppICESDK/appICEBundle.bundle/sound2.caf +0 -0
  114. package/ios/AppICESDK/appICEBundle.bundle/unchecked.png +0 -0
  115. package/ios/AppICESDK/include/iosAppiceSDK/AppICEInboxMessage.h +0 -43
  116. package/ios/AppICESDK/include/iosAppiceSDK/AppICEJSInterface.h +0 -21
  117. package/ios/AppICESDK/include/iosAppiceSDK/appICE.h +0 -190
  118. package/ios/AppICESDK/include/iosAppiceSDK/appICEUserDetails.h +0 -87
  119. package/ios/AppICESDK/include/iosAppiceSDK/isrgrootx1.der +0 -0
  120. package/ios/AppICESDK/include/iosAppiceSDK/lets-encrypt-r3.der +0 -0
  121. package/ios/AppICESDK/libiosAppiceSDK_v1.7.56.a +0 -0
@@ -1,473 +1,473 @@
1
- package com.reactlibrary;
2
-
3
- import android.content.Context;
4
- import android.content.Intent;
5
- import android.content.pm.PackageManager;
6
- import android.content.pm.ResolveInfo;
7
-
8
- import com.facebook.react.bridge.Arguments;
9
- import com.facebook.react.bridge.Callback;
10
- import com.facebook.react.bridge.ReactApplicationContext;
11
- import com.facebook.react.bridge.ReactContextBaseJavaModule;
12
- import com.facebook.react.bridge.ReactMethod;
13
- import com.facebook.react.bridge.ReadableMap;
14
- import com.facebook.react.bridge.ReadableMapKeySetIterator;
15
- import com.facebook.react.bridge.ReadableType;
16
-
17
- import android.util.Log;
18
-
19
- import java.util.HashMap;
20
- import java.util.List;
21
-
22
- import semusi.activitysdk.Api;
23
- import semusi.activitysdk.ContextSdk;
24
- import semusi.activitysdk.SdkConfig;
25
- import semusi.activitysdk.User;
26
-
27
- import java.util.*;
28
-
29
- //import semusi.context.utility.Utility;
30
- import androidx.annotation.NonNull;
31
- import androidx.annotation.Nullable;
32
-
33
- import com.facebook.react.bridge.ReadableArray;
34
- import com.facebook.react.bridge.WritableMap;
35
- import com.facebook.react.modules.core.DeviceEventManagerModule;
36
-
37
- import org.json.JSONArray;
38
- import org.json.JSONException;
39
- import org.json.JSONObject;
40
-
41
- public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
42
- private static ReactApplicationContext context = null;
43
- private static final String TAG = "AppIceReactPluginModule";
44
- private static final String APPICE_USER_NAME = "n";
45
- private static final String APPICE_USER_PHONE = "ph";
46
- private static final String APPICE_USER_EMAIL = "em";
47
- private static final String dateOfBirth = "dob";
48
- private static final String APPICE_USER_AGE = "a";
49
- private static final String APPICE_USER_EDUCATION = "ed";
50
- private static final String APPICE_USER_GENDER = "g";
51
- private static final String APPICE_USER_IS_EMPLOYED = "is_emp";
52
- private static final String APPICE_USER_EMPLOYMENT_TYPE = "et";
53
- private static final String APPICE_USER_MARRIED = "m";
54
- public static final String APPICE_PUSH_NOTIFICATION_CLICKED = "AppICEPushNotificationClicked";
55
- public static final String APPICE_INAPP_NOTIFICATION_CLICKED = "AppICEInAppClicked";
56
-
57
- public AppIceReactPluginModule(ReactApplicationContext reactContext) {
58
- super(reactContext);
59
- context = reactContext;
60
- }
61
-
62
- @NonNull
63
- @Override
64
- public String getName() {
65
- return "AppIceReactPlugin";
66
- }
67
-
68
- /**
69
- * @param appID
70
- * @param appKey
71
- * @param apiKey
72
- * @param region
73
- * @param baseUrl
74
- * @param certs
75
- */
76
- //appID, appKey, apiKey, gcmID, region, baseUrl, certs,success, error
77
- @ReactMethod
78
- public void startContext(String appID, String appKey, String apiKey, String deviceID,
79
- String region, String baseUrl, ReadableArray certs
80
- ) {
81
- Context context = getReactApplicationContext();
82
- Log.d(TAG, "in startContext : appID : " + appID + ", appkey : " + appKey + ", apiKey : " + apiKey);
83
- try {
84
- SdkConfig config = new SdkConfig();
85
- config.setAnalyticsTrackingAllowedState(true);
86
-
87
- System.out.println(certs.toString());
88
- //readaableArray can not read by java so converting it to list type array
89
- List<String> certList = new ArrayList<String>(certs.size());
90
-
91
- for (int i = 0; i < certs.size(); i++) {
92
-
93
- certList.add(certs.getString(i));
94
- }
95
-
96
-
97
- //as per new upgradation 27 jul 21r
98
- Api.initSdk(appID, appKey, apiKey, region, baseUrl
99
- , certList
100
- , context);
101
-
102
- Api.startContext(context, config);
103
-
104
- } catch (Exception e) {
105
- Log.d(TAG, "Exception in startContext : " + e);
106
- }
107
- }
108
-
109
- /**
110
- * @param eventName
111
- */
112
- @ReactMethod
113
- public void tagEvent(String eventName, ReadableMap props) {
114
- Context context = getReactApplicationContext();
115
- try {
116
- HashMap<String, Object> mapData = eventPropsFromReadableMap(props);
117
- if (eventName != null && eventName.length() > 0) {
118
- ContextSdk.tagEventObj(eventName, mapData, context);
119
- }
120
- } catch (Exception e) {
121
- Log.d(TAG, "Exception in tagEvent : " + e);
122
- }
123
- }
124
-
125
-
126
- @ReactMethod
127
- public void setCustomVariable(String eventName, String value) {
128
- Context context = getReactApplicationContext();
129
- try {
130
- if (value != null) {
131
- ContextSdk.setCustomVariable(eventName, (String) value, context);
132
- }
133
- } catch (Exception e) {
134
- Log.d(TAG, "Exception in customVar : " + e);
135
- }
136
- }
137
-
138
- /**
139
- * @return
140
- */
141
- @ReactMethod
142
- private void validateIntegration() {
143
- try {
144
- Context ctx = getReactApplicationContext();
145
- PackageManager pm = ctx.getPackageManager();
146
-
147
- Intent receiverIntent = new Intent();
148
- receiverIntent.setClass(ctx, CampaignCampsReceiver.class);
149
- List<ResolveInfo> receivers = pm.queryBroadcastReceivers(receiverIntent, 0);
150
- if (receivers == null || receivers.size() <= 0) {
151
- Log.d(TAG, "Missing Receiver entry in AndroidManifest : CampaignCampsReceiver");
152
- }
153
- Intent serviceIntent = new Intent();
154
- serviceIntent.setClass(ctx, NotificationEventService.class);
155
- ResolveInfo services = pm.resolveService(serviceIntent, 0);
156
- if (services == null) {
157
- Log.d(TAG, "Missing Service entry in AndroidManifest : NotificationEventService");
158
- }
159
-
160
- ContextSdk sdk = new ContextSdk(ctx);
161
- if (sdk.getAppId() == null || sdk.getAppId().length() <= 0 || sdk.getAppId().trim().length() <= 0) {
162
- Log.d(TAG, "Missing Meta-data entry : AppID");
163
- }
164
-
165
- if (sdk.getAppKey() == null || sdk.getAppKey().length() <= 0 || sdk.getAppKey().trim().length() <= 0) {
166
- Log.d(TAG, "Missing Meta-data entry : AppKey");
167
- }
168
-
169
- if (sdk.getApiKey() == null || sdk.getApiKey().length() <= 0 || sdk.getApiKey().trim().length() <= 0) {
170
- Log.d(TAG, "Missing Meta-data entry : ApiKey");
171
- }
172
- } catch (Exception e) {
173
- Log.d(TAG, "validateIntegration: " + e.getMessage());
174
- }
175
- }
176
-
177
- @ReactMethod
178
- public void setUser(ReadableMap userDetails) {
179
- Context context = getReactApplicationContext();
180
-
181
- Log.d(TAG, "setUser: " + userDetails);
182
- HashMap<String, Object> map = eventPropsFromReadableMap(userDetails);
183
-
184
- if (map != null) {
185
- try {
186
- User user = new User();
187
- try {
188
- if (map.containsKey(AppIceReactPluginModule.APPICE_USER_NAME)) {
189
- Object name = map.get(AppIceReactPluginModule.APPICE_USER_NAME);
190
- if (name != null) {
191
- user.setName(name.toString());
192
- }
193
- }
194
- } catch (Exception e) {
195
- Log.d(TAG, "setUser: name issue "+e.getMessage());
196
- }
197
-
198
- try {
199
- if (map.containsKey(AppIceReactPluginModule.APPICE_USER_PHONE)) {
200
- Object phone = map.get(AppIceReactPluginModule.APPICE_USER_PHONE);
201
- if (phone != null) {
202
- user.setPhone(phone.toString());
203
- }
204
- }
205
- } catch (Exception e) {
206
- Log.d(TAG, "setUser: phone issue "+e.getMessage());
207
- }
208
-
209
- try {
210
- if (map.containsKey(AppIceReactPluginModule.APPICE_USER_EMAIL)) {
211
- Object email = map.get(AppIceReactPluginModule.APPICE_USER_EMAIL);
212
- if (email != null) {
213
- user.setEmail(email.toString());
214
- }
215
- }
216
- } catch (Exception e) {
217
- Log.d(TAG, "setUser: email issue "+e.getMessage());
218
- }
219
-
220
- try {
221
- if (map.containsKey(AppIceReactPluginModule.APPICE_USER_AGE)) {
222
- Object age = map.get(AppIceReactPluginModule.APPICE_USER_AGE);
223
- if (age != null) {
224
- user.setAge((Integer) age);
225
- }
226
- }
227
- } catch (Exception e) {
228
- Log.d(TAG, "setUser: age issue "+e.getMessage());
229
- }
230
-
231
- try {
232
- if (map.containsKey(AppIceReactPluginModule.dateOfBirth)) {
233
- Object age = map.get(AppIceReactPluginModule.dateOfBirth);
234
- if (age != null) {
235
- user.setDob((Integer) age);
236
- }
237
- }
238
- } catch (Exception e) {
239
- Log.d(TAG, "setUser: dob issue "+e.getMessage());
240
- }
241
-
242
- try {
243
- if (map.containsKey(AppIceReactPluginModule.APPICE_USER_EDUCATION)) {
244
- Object ed = map.get(AppIceReactPluginModule.APPICE_USER_EDUCATION);
245
- if (ed != null) {
246
- user.setEducationType(ed.toString());
247
- }
248
- }
249
- } catch (Exception e) {
250
- Log.d(TAG, "setUser: ed issue "+e.getMessage());
251
- }
252
-
253
- try {
254
- if (map.containsKey(AppIceReactPluginModule.APPICE_USER_GENDER)) {
255
- Object g = map.get(AppIceReactPluginModule.APPICE_USER_GENDER);
256
- if (g != null) {
257
- user.setGender(g.toString());
258
- }
259
- }
260
- } catch (Exception e) {
261
- Log.d(TAG, "setUser: gender issue "+e.getMessage());
262
- }
263
-
264
-
265
- try {
266
- if (map.containsKey(AppIceReactPluginModule.APPICE_USER_IS_EMPLOYED)) {
267
- Object is_emp = map.get(AppIceReactPluginModule.APPICE_USER_IS_EMPLOYED);
268
- if (is_emp != null) {
269
- user.setEmployed((Boolean) is_emp);
270
- }
271
- }
272
- } catch (Exception e) {
273
- Log.d(TAG, "setUser: setEmployed issue "+e.getMessage());
274
- }
275
-
276
- try {
277
- if (map.containsKey(AppIceReactPluginModule.APPICE_USER_EMPLOYMENT_TYPE)) {
278
- Object et = map.get(AppIceReactPluginModule.APPICE_USER_EMPLOYMENT_TYPE);
279
- if (et != null) {
280
- user.setEmploymentType(et.toString());
281
- }
282
- }
283
- } catch (Exception e) {
284
- Log.d(TAG, "setUser: et issue "+e.getMessage());
285
- }
286
-
287
- try {
288
- if (map.containsKey(AppIceReactPluginModule.APPICE_USER_MARRIED)) {
289
- Object m = map.get(AppIceReactPluginModule.APPICE_USER_MARRIED);
290
- if (m != null) {
291
- user.setMarried((Boolean) m);
292
- }
293
- }
294
- } catch (Exception e) {
295
- Log.d(TAG, "setUser: married issue "+e.getMessage());
296
- }
297
- ContextSdk.setUser(user, context);
298
- } catch (Exception e) {
299
- }
300
- }
301
- }
302
-
303
- @ReactMethod
304
- public void setUserId(ReadableArray userIds) {
305
- Context context = getReactApplicationContext();
306
- try {
307
- ArrayList<String> finalValues = arrayListStringFromReadableArray(userIds);
308
- if (finalValues != null) {
309
- String[] usersId = finalValues.toArray(new String[finalValues.size()]);
310
- ContextSdk.setUser(usersId, context);
311
- }
312
- } catch (Exception e) {
313
- }
314
- }
315
-
316
- @Nullable
317
- @Override
318
- public Map<String, Object> getConstants() {
319
- final Map<String, Object> constants = new HashMap<>();
320
- constants.put(APPICE_USER_NAME, APPICE_USER_NAME);
321
- constants.put(APPICE_USER_PHONE, APPICE_USER_PHONE);
322
- constants.put(APPICE_USER_EMAIL, APPICE_USER_EMAIL);
323
- constants.put(APPICE_USER_IS_EMPLOYED, APPICE_USER_IS_EMPLOYED);
324
- constants.put(APPICE_USER_MARRIED, APPICE_USER_MARRIED);
325
- constants.put(APPICE_USER_EDUCATION, APPICE_USER_EDUCATION);
326
- constants.put(APPICE_USER_EMPLOYMENT_TYPE, APPICE_USER_EMPLOYMENT_TYPE);
327
- constants.put(APPICE_USER_AGE, APPICE_USER_AGE);
328
- constants.put(APPICE_USER_GENDER, APPICE_USER_GENDER);
329
- constants.put(APPICE_PUSH_NOTIFICATION_CLICKED, APPICE_PUSH_NOTIFICATION_CLICKED);
330
- constants.put(APPICE_INAPP_NOTIFICATION_CLICKED, APPICE_INAPP_NOTIFICATION_CLICKED);
331
- return constants;
332
- }
333
-
334
- @ReactMethod
335
- public void addListener(String eventName) {
336
- // Set up any upstream listeners or background tasks as necessary
337
- }
338
-
339
- @ReactMethod
340
- public void removeListeners(Integer count) {
341
- // Remove upstream listeners, stop unnecessary background tasks
342
- }
343
-
344
- @ReactMethod
345
- public void pushNotificationClicked(String payload) {
346
- Context ctx = getReactApplicationContext();
347
- ContextSdk.pushNotificationClicked(payload, ctx);
348
- }
349
-
350
- public static void sendEvent(String eventName, @Nullable WritableMap params) {
351
- try {
352
- context.
353
- getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
354
- .emit(eventName, params);
355
- } catch (RuntimeException e) {
356
- Log.e(TAG, "java.lang.RuntimeException: Trying to invoke JS before CatalystInstance has been set!", e);
357
- }
358
- }
359
-
360
- private static ArrayList<String> arrayListStringFromReadableArray(ReadableArray readableArray) {
361
- ArrayList<String> array = new ArrayList<>();
362
- for (int i = 0; i < readableArray.size(); i++) {
363
- switch (readableArray.getType(i)) {
364
- case Null:
365
- break;
366
- case Boolean:
367
- array.add(String.valueOf(readableArray.getBoolean(i)));
368
- break;
369
- case Number:
370
- array.add(String.valueOf(readableArray.getDouble(i)));
371
- break;
372
- case String:
373
- array.add(readableArray.getString(i));
374
- break;
375
- }
376
- }
377
- return array;
378
- }
379
-
380
- private static JSONArray jsonArrayFromReadableArray(ReadableArray readableArray) throws JSONException {
381
- JSONArray array = new JSONArray();
382
- for (int i = 0; i < readableArray.size(); i++) {
383
- switch (readableArray.getType(i)) {
384
- case Null:
385
- break;
386
- case Boolean:
387
- array.put(readableArray.getBoolean(i));
388
- break;
389
- case Number:
390
- array.put(readableArray.getDouble(i));
391
- break;
392
- case String:
393
- array.put(readableArray.getString(i));
394
- break;
395
- case Map:
396
- array.put(jsonObjectFromReadableMap(readableArray.getMap(i)));
397
- break;
398
- case Array:
399
- array.put(jsonArrayFromReadableArray(readableArray.getArray(i)));
400
- break;
401
- }
402
- }
403
- return array;
404
- }
405
-
406
- private static JSONObject jsonObjectFromReadableMap(ReadableMap readableMap) throws JSONException {
407
- JSONObject object = new JSONObject();
408
- ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
409
- while (iterator.hasNextKey()) {
410
- String key = iterator.nextKey();
411
- switch (readableMap.getType(key)) {
412
- case Null:
413
- object.put(key, JSONObject.NULL);
414
- break;
415
- case Boolean:
416
- object.put(key, readableMap.getBoolean(key));
417
- break;
418
- case Number:
419
- object.put(key, readableMap.getDouble(key));
420
- break;
421
- case String:
422
- object.put(key, readableMap.getString(key));
423
- break;
424
- case Map:
425
- object.put(key, jsonObjectFromReadableMap(readableMap.getMap(key)));
426
- break;
427
- case Array:
428
- object.put(key, jsonArrayFromReadableArray(readableMap.getArray(key)));
429
- break;
430
- }
431
- }
432
- return object;
433
- }
434
-
435
- /**
436
- * @param propsMap took data from js and iterate it and store in hashmap
437
- * @return map of the props data
438
- */
439
- private HashMap<String, Object> eventPropsFromReadableMap(ReadableMap propsMap) {
440
- if (propsMap == null) return null;
441
-
442
- HashMap<String, Object> props = new HashMap<>();
443
- ReadableMapKeySetIterator iterator = propsMap.keySetIterator();
444
-
445
- while (iterator.hasNextKey()) {
446
- try {
447
- String key = iterator.nextKey();
448
- ReadableType readableType = propsMap.getType(key);
449
-
450
- if (readableType == ReadableType.String) {
451
- props.put(key, propsMap.getString(key));
452
- } else if (readableType == ReadableType.Boolean) {
453
- props.put(key, propsMap.getBoolean(key));
454
- } else if (readableType == ReadableType.Number) {
455
- try {
456
- props.put(key, propsMap.getDouble(key));
457
- } catch (Throwable t) {
458
- try {
459
- props.put(key, propsMap.getInt(key));
460
- } catch (Throwable t1) {
461
- Log.d(TAG, "Unhandled ReadableType.Number from ReadableMap");
462
- }
463
- }
464
- } else {
465
- Log.d(TAG, "Unhandled event property ReadableType");
466
- }
467
- } catch (Throwable t) {
468
- Log.d(TAG, t.getLocalizedMessage());
469
- }
470
- }
471
- return props;
472
- }
473
- }
1
+ package com.reactlibrary;
2
+
3
+ import android.content.Context;
4
+ import android.content.Intent;
5
+ import android.content.pm.PackageManager;
6
+ import android.content.pm.ResolveInfo;
7
+
8
+ import com.facebook.react.bridge.Arguments;
9
+ import com.facebook.react.bridge.Callback;
10
+ import com.facebook.react.bridge.ReactApplicationContext;
11
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
12
+ import com.facebook.react.bridge.ReactMethod;
13
+ import com.facebook.react.bridge.ReadableMap;
14
+ import com.facebook.react.bridge.ReadableMapKeySetIterator;
15
+ import com.facebook.react.bridge.ReadableType;
16
+
17
+ import android.util.Log;
18
+
19
+ import java.util.HashMap;
20
+ import java.util.List;
21
+
22
+ import semusi.activitysdk.Api;
23
+ import semusi.activitysdk.ContextSdk;
24
+ import semusi.activitysdk.SdkConfig;
25
+ import semusi.activitysdk.User;
26
+
27
+ import java.util.*;
28
+
29
+ //import semusi.context.utility.Utility;
30
+ import androidx.annotation.NonNull;
31
+ import androidx.annotation.Nullable;
32
+
33
+ import com.facebook.react.bridge.ReadableArray;
34
+ import com.facebook.react.bridge.WritableMap;
35
+ import com.facebook.react.modules.core.DeviceEventManagerModule;
36
+
37
+ import org.json.JSONArray;
38
+ import org.json.JSONException;
39
+ import org.json.JSONObject;
40
+
41
+ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
42
+ private static ReactApplicationContext context = null;
43
+ private static final String TAG = "AppIceReactPluginModule";
44
+ private static final String APPICE_USER_NAME = "n";
45
+ private static final String APPICE_USER_PHONE = "ph";
46
+ private static final String APPICE_USER_EMAIL = "em";
47
+ private static final String dateOfBirth = "dob";
48
+ private static final String APPICE_USER_AGE = "a";
49
+ private static final String APPICE_USER_EDUCATION = "ed";
50
+ private static final String APPICE_USER_GENDER = "g";
51
+ private static final String APPICE_USER_IS_EMPLOYED = "is_emp";
52
+ private static final String APPICE_USER_EMPLOYMENT_TYPE = "et";
53
+ private static final String APPICE_USER_MARRIED = "m";
54
+ public static final String APPICE_PUSH_NOTIFICATION_CLICKED = "AppICEPushNotificationClicked";
55
+ public static final String APPICE_INAPP_NOTIFICATION_CLICKED = "AppICEInAppClicked";
56
+
57
+ public AppIceReactPluginModule(ReactApplicationContext reactContext) {
58
+ super(reactContext);
59
+ context = reactContext;
60
+ }
61
+
62
+ @NonNull
63
+ @Override
64
+ public String getName() {
65
+ return "AppIceReactPlugin";
66
+ }
67
+
68
+ /**
69
+ * @param appID
70
+ * @param appKey
71
+ * @param apiKey
72
+ * @param region
73
+ * @param baseUrl
74
+ * @param certs
75
+ */
76
+ //appID, appKey, apiKey, gcmID, region, baseUrl, certs,success, error
77
+ @ReactMethod
78
+ public void startContext(String appID, String appKey, String apiKey, String deviceID,
79
+ String region, String baseUrl, ReadableArray certs
80
+ ) {
81
+ Context context = getReactApplicationContext();
82
+ Log.d(TAG, "in startContext : appID : " + appID + ", appkey : " + appKey + ", apiKey : " + apiKey);
83
+ try {
84
+ SdkConfig config = new SdkConfig();
85
+ config.setAnalyticsTrackingAllowedState(true);
86
+
87
+ System.out.println(certs.toString());
88
+ //readaableArray can not read by java so converting it to list type array
89
+ List<String> certList = new ArrayList<String>(certs.size());
90
+
91
+ for (int i = 0; i < certs.size(); i++) {
92
+
93
+ certList.add(certs.getString(i));
94
+ }
95
+
96
+
97
+ //as per new upgradation 27 jul 21r
98
+ Api.initSdk(appID, appKey, apiKey, region, baseUrl
99
+ , certList
100
+ , context);
101
+
102
+ Api.startContext(context, config);
103
+
104
+ } catch (Exception e) {
105
+ Log.d(TAG, "Exception in startContext : " + e);
106
+ }
107
+ }
108
+
109
+ /**
110
+ * @param eventName
111
+ */
112
+ @ReactMethod
113
+ public void tagEvent(String eventName, ReadableMap props) {
114
+ Context context = getReactApplicationContext();
115
+ try {
116
+ HashMap<String, Object> mapData = eventPropsFromReadableMap(props);
117
+ if (eventName != null && eventName.length() > 0) {
118
+ ContextSdk.tagEventObj(eventName, mapData, context);
119
+ }
120
+ } catch (Exception e) {
121
+ Log.d(TAG, "Exception in tagEvent : " + e);
122
+ }
123
+ }
124
+
125
+
126
+ @ReactMethod
127
+ public void setCustomVariable(String eventName, String value) {
128
+ Context context = getReactApplicationContext();
129
+ try {
130
+ if (value != null) {
131
+ ContextSdk.setCustomVariable(eventName, (String) value, context);
132
+ }
133
+ } catch (Exception e) {
134
+ Log.d(TAG, "Exception in customVar : " + e);
135
+ }
136
+ }
137
+
138
+ /**
139
+ * @return
140
+ */
141
+ @ReactMethod
142
+ private void validateIntegration() {
143
+ try {
144
+ Context ctx = getReactApplicationContext();
145
+ PackageManager pm = ctx.getPackageManager();
146
+
147
+ Intent receiverIntent = new Intent();
148
+ receiverIntent.setClass(ctx, CampaignCampsReceiver.class);
149
+ List<ResolveInfo> receivers = pm.queryBroadcastReceivers(receiverIntent, 0);
150
+ if (receivers == null || receivers.size() <= 0) {
151
+ Log.d(TAG, "Missing Receiver entry in AndroidManifest : CampaignCampsReceiver");
152
+ }
153
+ Intent serviceIntent = new Intent();
154
+ serviceIntent.setClass(ctx, NotificationEventService.class);
155
+ ResolveInfo services = pm.resolveService(serviceIntent, 0);
156
+ if (services == null) {
157
+ Log.d(TAG, "Missing Service entry in AndroidManifest : NotificationEventService");
158
+ }
159
+
160
+ ContextSdk sdk = new ContextSdk(ctx);
161
+ if (sdk.getAppId() == null || sdk.getAppId().length() <= 0 || sdk.getAppId().trim().length() <= 0) {
162
+ Log.d(TAG, "Missing Meta-data entry : AppID");
163
+ }
164
+
165
+ if (sdk.getAppKey() == null || sdk.getAppKey().length() <= 0 || sdk.getAppKey().trim().length() <= 0) {
166
+ Log.d(TAG, "Missing Meta-data entry : AppKey");
167
+ }
168
+
169
+ if (sdk.getApiKey() == null || sdk.getApiKey().length() <= 0 || sdk.getApiKey().trim().length() <= 0) {
170
+ Log.d(TAG, "Missing Meta-data entry : ApiKey");
171
+ }
172
+ } catch (Exception e) {
173
+ Log.d(TAG, "validateIntegration: " + e.getMessage());
174
+ }
175
+ }
176
+
177
+ @ReactMethod
178
+ public void setUser(ReadableMap userDetails) {
179
+ Context context = getReactApplicationContext();
180
+
181
+ Log.d(TAG, "setUser: " + userDetails);
182
+ HashMap<String, Object> map = eventPropsFromReadableMap(userDetails);
183
+
184
+ if (map != null) {
185
+ try {
186
+ User user = new User();
187
+ try {
188
+ if (map.containsKey(AppIceReactPluginModule.APPICE_USER_NAME)) {
189
+ Object name = map.get(AppIceReactPluginModule.APPICE_USER_NAME);
190
+ if (name != null) {
191
+ user.setName(name.toString());
192
+ }
193
+ }
194
+ } catch (Exception e) {
195
+ Log.d(TAG, "setUser: name issue "+e.getMessage());
196
+ }
197
+
198
+ try {
199
+ if (map.containsKey(AppIceReactPluginModule.APPICE_USER_PHONE)) {
200
+ Object phone = map.get(AppIceReactPluginModule.APPICE_USER_PHONE);
201
+ if (phone != null) {
202
+ user.setPhone(phone.toString());
203
+ }
204
+ }
205
+ } catch (Exception e) {
206
+ Log.d(TAG, "setUser: phone issue "+e.getMessage());
207
+ }
208
+
209
+ try {
210
+ if (map.containsKey(AppIceReactPluginModule.APPICE_USER_EMAIL)) {
211
+ Object email = map.get(AppIceReactPluginModule.APPICE_USER_EMAIL);
212
+ if (email != null) {
213
+ user.setEmail(email.toString());
214
+ }
215
+ }
216
+ } catch (Exception e) {
217
+ Log.d(TAG, "setUser: email issue "+e.getMessage());
218
+ }
219
+
220
+ try {
221
+ if (map.containsKey(AppIceReactPluginModule.APPICE_USER_AGE)) {
222
+ Object age = map.get(AppIceReactPluginModule.APPICE_USER_AGE);
223
+ if (age != null) {
224
+ user.setAge((Integer) age);
225
+ }
226
+ }
227
+ } catch (Exception e) {
228
+ Log.d(TAG, "setUser: age issue "+e.getMessage());
229
+ }
230
+
231
+ try {
232
+ if (map.containsKey(AppIceReactPluginModule.dateOfBirth)) {
233
+ Object age = map.get(AppIceReactPluginModule.dateOfBirth);
234
+ if (age != null) {
235
+ user.setDob((Integer) age);
236
+ }
237
+ }
238
+ } catch (Exception e) {
239
+ Log.d(TAG, "setUser: dob issue "+e.getMessage());
240
+ }
241
+
242
+ try {
243
+ if (map.containsKey(AppIceReactPluginModule.APPICE_USER_EDUCATION)) {
244
+ Object ed = map.get(AppIceReactPluginModule.APPICE_USER_EDUCATION);
245
+ if (ed != null) {
246
+ user.setEducationType(ed.toString());
247
+ }
248
+ }
249
+ } catch (Exception e) {
250
+ Log.d(TAG, "setUser: ed issue "+e.getMessage());
251
+ }
252
+
253
+ try {
254
+ if (map.containsKey(AppIceReactPluginModule.APPICE_USER_GENDER)) {
255
+ Object g = map.get(AppIceReactPluginModule.APPICE_USER_GENDER);
256
+ if (g != null) {
257
+ user.setGender(g.toString());
258
+ }
259
+ }
260
+ } catch (Exception e) {
261
+ Log.d(TAG, "setUser: gender issue "+e.getMessage());
262
+ }
263
+
264
+
265
+ try {
266
+ if (map.containsKey(AppIceReactPluginModule.APPICE_USER_IS_EMPLOYED)) {
267
+ Object is_emp = map.get(AppIceReactPluginModule.APPICE_USER_IS_EMPLOYED);
268
+ if (is_emp != null) {
269
+ user.setEmployed((Boolean) is_emp);
270
+ }
271
+ }
272
+ } catch (Exception e) {
273
+ Log.d(TAG, "setUser: setEmployed issue "+e.getMessage());
274
+ }
275
+
276
+ try {
277
+ if (map.containsKey(AppIceReactPluginModule.APPICE_USER_EMPLOYMENT_TYPE)) {
278
+ Object et = map.get(AppIceReactPluginModule.APPICE_USER_EMPLOYMENT_TYPE);
279
+ if (et != null) {
280
+ user.setEmploymentType(et.toString());
281
+ }
282
+ }
283
+ } catch (Exception e) {
284
+ Log.d(TAG, "setUser: et issue "+e.getMessage());
285
+ }
286
+
287
+ try {
288
+ if (map.containsKey(AppIceReactPluginModule.APPICE_USER_MARRIED)) {
289
+ Object m = map.get(AppIceReactPluginModule.APPICE_USER_MARRIED);
290
+ if (m != null) {
291
+ user.setMarried((Boolean) m);
292
+ }
293
+ }
294
+ } catch (Exception e) {
295
+ Log.d(TAG, "setUser: married issue "+e.getMessage());
296
+ }
297
+ ContextSdk.setUser(user, context);
298
+ } catch (Exception e) {
299
+ }
300
+ }
301
+ }
302
+
303
+ @ReactMethod
304
+ public void setUserId(ReadableArray userIds) {
305
+ Context context = getReactApplicationContext();
306
+ try {
307
+ ArrayList<String> finalValues = arrayListStringFromReadableArray(userIds);
308
+ if (finalValues != null) {
309
+ String[] usersId = finalValues.toArray(new String[finalValues.size()]);
310
+ ContextSdk.setUser(usersId, context);
311
+ }
312
+ } catch (Exception e) {
313
+ }
314
+ }
315
+
316
+ @Nullable
317
+ @Override
318
+ public Map<String, Object> getConstants() {
319
+ final Map<String, Object> constants = new HashMap<>();
320
+ constants.put(APPICE_USER_NAME, APPICE_USER_NAME);
321
+ constants.put(APPICE_USER_PHONE, APPICE_USER_PHONE);
322
+ constants.put(APPICE_USER_EMAIL, APPICE_USER_EMAIL);
323
+ constants.put(APPICE_USER_IS_EMPLOYED, APPICE_USER_IS_EMPLOYED);
324
+ constants.put(APPICE_USER_MARRIED, APPICE_USER_MARRIED);
325
+ constants.put(APPICE_USER_EDUCATION, APPICE_USER_EDUCATION);
326
+ constants.put(APPICE_USER_EMPLOYMENT_TYPE, APPICE_USER_EMPLOYMENT_TYPE);
327
+ constants.put(APPICE_USER_AGE, APPICE_USER_AGE);
328
+ constants.put(APPICE_USER_GENDER, APPICE_USER_GENDER);
329
+ constants.put(APPICE_PUSH_NOTIFICATION_CLICKED, APPICE_PUSH_NOTIFICATION_CLICKED);
330
+ constants.put(APPICE_INAPP_NOTIFICATION_CLICKED, APPICE_INAPP_NOTIFICATION_CLICKED);
331
+ return constants;
332
+ }
333
+
334
+ @ReactMethod
335
+ public void addListener(String eventName) {
336
+ // Set up any upstream listeners or background tasks as necessary
337
+ }
338
+
339
+ @ReactMethod
340
+ public void removeListeners(Integer count) {
341
+ // Remove upstream listeners, stop unnecessary background tasks
342
+ }
343
+
344
+ @ReactMethod
345
+ public void pushNotificationClicked(String payload) {
346
+ Context ctx = getReactApplicationContext();
347
+ ContextSdk.pushNotificationClicked(payload, ctx);
348
+ }
349
+
350
+ public static void sendEvent(String eventName, @Nullable WritableMap params) {
351
+ try {
352
+ context.
353
+ getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
354
+ .emit(eventName, params);
355
+ } catch (RuntimeException e) {
356
+ Log.e(TAG, "java.lang.RuntimeException: Trying to invoke JS before CatalystInstance has been set!", e);
357
+ }
358
+ }
359
+
360
+ private static ArrayList<String> arrayListStringFromReadableArray(ReadableArray readableArray) {
361
+ ArrayList<String> array = new ArrayList<>();
362
+ for (int i = 0; i < readableArray.size(); i++) {
363
+ switch (readableArray.getType(i)) {
364
+ case Null:
365
+ break;
366
+ case Boolean:
367
+ array.add(String.valueOf(readableArray.getBoolean(i)));
368
+ break;
369
+ case Number:
370
+ array.add(String.valueOf(readableArray.getDouble(i)));
371
+ break;
372
+ case String:
373
+ array.add(readableArray.getString(i));
374
+ break;
375
+ }
376
+ }
377
+ return array;
378
+ }
379
+
380
+ private static JSONArray jsonArrayFromReadableArray(ReadableArray readableArray) throws JSONException {
381
+ JSONArray array = new JSONArray();
382
+ for (int i = 0; i < readableArray.size(); i++) {
383
+ switch (readableArray.getType(i)) {
384
+ case Null:
385
+ break;
386
+ case Boolean:
387
+ array.put(readableArray.getBoolean(i));
388
+ break;
389
+ case Number:
390
+ array.put(readableArray.getDouble(i));
391
+ break;
392
+ case String:
393
+ array.put(readableArray.getString(i));
394
+ break;
395
+ case Map:
396
+ array.put(jsonObjectFromReadableMap(readableArray.getMap(i)));
397
+ break;
398
+ case Array:
399
+ array.put(jsonArrayFromReadableArray(readableArray.getArray(i)));
400
+ break;
401
+ }
402
+ }
403
+ return array;
404
+ }
405
+
406
+ private static JSONObject jsonObjectFromReadableMap(ReadableMap readableMap) throws JSONException {
407
+ JSONObject object = new JSONObject();
408
+ ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
409
+ while (iterator.hasNextKey()) {
410
+ String key = iterator.nextKey();
411
+ switch (readableMap.getType(key)) {
412
+ case Null:
413
+ object.put(key, JSONObject.NULL);
414
+ break;
415
+ case Boolean:
416
+ object.put(key, readableMap.getBoolean(key));
417
+ break;
418
+ case Number:
419
+ object.put(key, readableMap.getDouble(key));
420
+ break;
421
+ case String:
422
+ object.put(key, readableMap.getString(key));
423
+ break;
424
+ case Map:
425
+ object.put(key, jsonObjectFromReadableMap(readableMap.getMap(key)));
426
+ break;
427
+ case Array:
428
+ object.put(key, jsonArrayFromReadableArray(readableMap.getArray(key)));
429
+ break;
430
+ }
431
+ }
432
+ return object;
433
+ }
434
+
435
+ /**
436
+ * @param propsMap took data from js and iterate it and store in hashmap
437
+ * @return map of the props data
438
+ */
439
+ private HashMap<String, Object> eventPropsFromReadableMap(ReadableMap propsMap) {
440
+ if (propsMap == null) return null;
441
+
442
+ HashMap<String, Object> props = new HashMap<>();
443
+ ReadableMapKeySetIterator iterator = propsMap.keySetIterator();
444
+
445
+ while (iterator.hasNextKey()) {
446
+ try {
447
+ String key = iterator.nextKey();
448
+ ReadableType readableType = propsMap.getType(key);
449
+
450
+ if (readableType == ReadableType.String) {
451
+ props.put(key, propsMap.getString(key));
452
+ } else if (readableType == ReadableType.Boolean) {
453
+ props.put(key, propsMap.getBoolean(key));
454
+ } else if (readableType == ReadableType.Number) {
455
+ try {
456
+ props.put(key, propsMap.getDouble(key));
457
+ } catch (Throwable t) {
458
+ try {
459
+ props.put(key, propsMap.getInt(key));
460
+ } catch (Throwable t1) {
461
+ Log.d(TAG, "Unhandled ReadableType.Number from ReadableMap");
462
+ }
463
+ }
464
+ } else {
465
+ Log.d(TAG, "Unhandled event property ReadableType");
466
+ }
467
+ } catch (Throwable t) {
468
+ Log.d(TAG, t.getLocalizedMessage());
469
+ }
470
+ }
471
+ return props;
472
+ }
473
+ }