react-native-repro 3.23.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/React-Repro.podspec +2 -2
  2. package/android/build.gradle +28 -1
  3. package/android/src/main/java/io/repro/android/reactbridge/{ReproReactBridgeModule.java → ReproReactBridgeModuleImpl.java} +265 -67
  4. package/android/src/main/java/io/repro/android/reactbridge/{ReproRemoteConfigBridge.java → ReproRemoteConfigBridgeModuleImpl.java} +19 -34
  5. package/android/src/newarch/java/io/repro/android/reactbridge/ReproEventEmitterOpenUrlModule.java +54 -0
  6. package/android/src/newarch/java/io/repro/android/reactbridge/ReproReactBridgeModule.java +367 -0
  7. package/android/src/newarch/java/io/repro/android/reactbridge/ReproReactBridgePackage.java +78 -0
  8. package/android/src/newarch/java/io/repro/android/reactbridge/ReproRemoteConfigBridgeModule.java +79 -0
  9. package/android/src/{main/java/io/repro/android/reactbridge/ReproEventEmitterOpenUrl.java → oldarch/java/io/repro/android/reactbridge/ReproEventEmitterOpenUrlModule.java} +4 -4
  10. package/android/src/oldarch/java/io/repro/android/reactbridge/ReproReactBridgeModule.java +365 -0
  11. package/android/src/oldarch/java/io/repro/android/reactbridge/ReproReactBridgePackage.java +29 -0
  12. package/android/src/oldarch/java/io/repro/android/reactbridge/ReproRemoteConfigBridgeModule.java +77 -0
  13. package/index.js +45 -228
  14. package/ios/RPRReproReactBridge.h +19 -4
  15. package/ios/{RPRReproReactBridge.m → RPRReproReactBridge.mm} +662 -187
  16. package/ios/RPRReproReactBridgeImpl.h +111 -0
  17. package/ios/RPRReproReactBridgeImpl.m +713 -0
  18. package/package.json +22 -1
  19. package/sdk-android/io/repro/repro-android-sdk/5.20.0/repro-android-sdk-5.20.0.aar +0 -0
  20. package/sdk-android/io/repro/repro-android-sdk/5.20.0/repro-android-sdk-5.20.0.aar.md5 +1 -0
  21. package/sdk-android/io/repro/repro-android-sdk/5.20.0/repro-android-sdk-5.20.0.aar.sha1 +1 -0
  22. package/sdk-android/io/repro/repro-android-sdk/5.20.0/repro-android-sdk-5.20.0.pom +24 -0
  23. package/sdk-android/io/repro/repro-android-sdk/5.20.0/repro-android-sdk-5.20.0.pom.md5 +1 -0
  24. package/sdk-android/io/repro/repro-android-sdk/5.20.0/repro-android-sdk-5.20.0.pom.sha1 +1 -0
  25. package/sdk-android/io/repro/repro-android-sdk/maven-metadata.xml +3 -3
  26. package/sdk-android/io/repro/repro-android-sdk/maven-metadata.xml.md5 +1 -1
  27. package/sdk-android/io/repro/repro-android-sdk/maven-metadata.xml.sha1 +1 -1
  28. package/sdk-ios/Repro.xcframework/_CodeSignature/CodeDirectory +0 -0
  29. package/sdk-ios/Repro.xcframework/_CodeSignature/CodeRequirements-1 +0 -0
  30. package/sdk-ios/Repro.xcframework/_CodeSignature/CodeResources +18 -18
  31. package/sdk-ios/Repro.xcframework/_CodeSignature/CodeSignature +0 -0
  32. package/sdk-ios/Repro.xcframework/ios-arm64_armv7_armv7s/Repro.framework/Headers/Repro.h +63 -0
  33. package/sdk-ios/Repro.xcframework/ios-arm64_armv7_armv7s/Repro.framework/Info.plist +0 -0
  34. package/sdk-ios/Repro.xcframework/ios-arm64_armv7_armv7s/Repro.framework/Repro +0 -0
  35. package/sdk-ios/Repro.xcframework/ios-arm64_i386_x86_64-simulator/Repro.framework/Headers/Repro.h +63 -0
  36. package/sdk-ios/Repro.xcframework/ios-arm64_i386_x86_64-simulator/Repro.framework/Info.plist +0 -0
  37. package/sdk-ios/Repro.xcframework/ios-arm64_i386_x86_64-simulator/Repro.framework/Repro +0 -0
  38. package/src/EventEmitterOpenUrl.js +24 -0
  39. package/src/NativeReproEventEmitterOpenUrl.ts +9 -0
  40. package/src/NativeReproReactBridge.ts +134 -0
  41. package/src/NativeReproRemoteConfigBridge.ts +26 -0
  42. package/src/NewsFeedManager.js +149 -0
  43. package/android/src/main/java/io/repro/android/reactbridge/ReproReactBridgePackage.java +0 -36
  44. package/repro-version.json +0 -5
  45. package/sdk-android/io/repro/repro-android-sdk/5.19.0/repro-android-sdk-5.19.0.aar +0 -0
  46. package/sdk-android/io/repro/repro-android-sdk/5.19.0/repro-android-sdk-5.19.0.aar.md5 +0 -1
  47. package/sdk-android/io/repro/repro-android-sdk/5.19.0/repro-android-sdk-5.19.0.aar.sha1 +0 -1
  48. package/sdk-android/io/repro/repro-android-sdk/5.19.0/repro-android-sdk-5.19.0.pom +0 -9
  49. package/sdk-android/io/repro/repro-android-sdk/5.19.0/repro-android-sdk-5.19.0.pom.md5 +0 -1
  50. package/sdk-android/io/repro/repro-android-sdk/5.19.0/repro-android-sdk-5.19.0.pom.sha1 +0 -1
@@ -13,12 +13,12 @@ Pod::Spec.new do |s|
13
13
  s.platforms = { :ios => "10.0" }
14
14
  s.source = { :git => "https://github.com/reproio/repro-ios-sdk", :tag => "local_link_only" }
15
15
 
16
- s.source_files = "ios/*.{h,m}"
16
+ s.source_files = "ios/*.{h,m,mm}"
17
17
 
18
18
  s.vendored_frameworks = "sdk-ios/Repro.xcframework"
19
19
 
20
20
  s.frameworks = 'UIKit', 'CoreGraphics', 'QuartzCore', 'SystemConfiguration', 'WebKit', 'UserNotifications'
21
21
 
22
- s.dependency "React"
22
+ install_modules_dependencies(s)
23
23
  end
24
24
 
@@ -1,6 +1,18 @@
1
+ def isNewArchitectureEnabled() {
2
+ return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
3
+ }
1
4
 
2
5
  apply plugin: 'com.android.library'
3
6
 
7
+ if (isNewArchitectureEnabled()) {
8
+ apply plugin: "com.facebook.react"
9
+ react {
10
+ jsRootDir = file("../../")
11
+ libraryName = "react-native-repro"
12
+ codegenJavaPackageName = "io.repro.android.reactbridge"
13
+ }
14
+ }
15
+
4
16
  def getMainProp(property, fallback) {
5
17
  return rootProject.ext.has(property) ? rootProject.ext.get(property) : fallback
6
18
  }
@@ -10,20 +22,35 @@ android {
10
22
  compileSdkVersion getMainProp('compileSdkVersion', 26)
11
23
  buildToolsVersion getMainProp('buildToolsVersion', '26.0.3')
12
24
 
25
+ namespace "io.repro.android.reactbridge"
26
+
13
27
  defaultConfig {
14
28
  minSdkVersion getMainProp('minSdkVersion', 16)
15
29
  // targetSdkVersion 26
16
30
  versionCode 1
17
31
  versionName "1.0.0"
32
+ buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
33
+ }
34
+
35
+ sourceSets {
36
+ main {
37
+ java.srcDirs += ['src/main/java']
38
+ if (isNewArchitectureEnabled()) {
39
+ java.srcDirs += ['src/newarch']
40
+ } else {
41
+ java.srcDirs += ['src/oldarch']
42
+ }
43
+ }
18
44
  }
19
45
  }
20
46
 
21
47
  repositories {
22
48
  mavenCentral()
49
+ google()
23
50
  }
24
51
 
25
52
  dependencies {
26
- implementation "com.facebook.react:react-native:${getMainProp('reactNativeVersion', '+')}"
53
+ compileOnly "com.facebook.react:react-native:${getMainProp('reactNativeVersion', '+')}"
27
54
 
28
55
  api "io.repro:repro-android-sdk:+"
29
56
  }
@@ -1,12 +1,8 @@
1
-
2
1
  package io.repro.android.reactbridge;
3
2
 
4
3
  import android.util.Log;
4
+ import android.app.Activity;
5
5
 
6
-
7
- import com.facebook.react.bridge.ReactApplicationContext;
8
- import com.facebook.react.bridge.ReactContextBaseJavaModule;
9
- import com.facebook.react.bridge.ReactMethod;
10
6
  import com.facebook.react.bridge.Callback;
11
7
  import com.facebook.react.bridge.ReadableMap;
12
8
  import com.facebook.react.bridge.WritableMap;
@@ -43,8 +39,7 @@ import io.repro.android.user.UserProfileGender;
43
39
  import io.repro.android.user.UserProfilePrefecture;
44
40
  import io.repro.android.newsfeed.NewsFeedEntry;
45
41
 
46
-
47
- public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
42
+ public class ReproReactBridgeModuleImpl {
48
43
 
49
44
  public static final int GENDER_OTHER = 0;
50
45
  public static final int GENDER_MALE = 1;
@@ -56,15 +51,9 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
56
51
  public static final int CAMPAIGN_TYPE_WEB_MESSAGE = (1 << 2);
57
52
  public static final int CAMPAIGN_TYPE_ALL = (1 << 3);
58
53
 
59
- private final ReactApplicationContext reactContext;
54
+ private static final String REPRO_REACT_NATIVE_BRIDGE_VERSION = "4.0.0";
60
55
 
61
- private static final String REPRO_REACT_NATIVE_BRIDGE_VERSION = "3.23.0";
62
-
63
- public ReproReactBridgeModule(ReactApplicationContext reactContext) {
64
- super(reactContext);
65
- this.reactContext = reactContext;
66
- this.versionPassing();
67
- }
56
+ public static final String NAME = "ReproReactBridgeModule";
68
57
 
69
58
  private String getReactNativeVersion() {
70
59
  try {
@@ -78,7 +67,7 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
78
67
  }
79
68
  }
80
69
 
81
- private void versionPassing() {
70
+ public void versionPassing() {
82
71
  final Map<String, Object> platformValues = new HashMap<>();
83
72
  platformValues.put("sub_sdk_platform", "react_native");
84
73
  platformValues.put("sub_sdk_bridge_version", REPRO_REACT_NATIVE_BRIDGE_VERSION);
@@ -97,12 +86,6 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
97
86
  }
98
87
  }
99
88
 
100
- @Override
101
- public String getName() {
102
- return "Repro";
103
- }
104
-
105
- @Override
106
89
  public Map<String, Object> getConstants() {
107
90
  final Map<String, Object> constants = new HashMap<>();
108
91
 
@@ -129,52 +112,42 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
129
112
  return constants;
130
113
  }
131
114
 
132
- @ReactMethod
133
115
  public void optIn(boolean endUserOptedIn) {
134
116
  Repro.optIn(endUserOptedIn);
135
117
  }
136
118
 
137
- @ReactMethod
138
119
  public void setUserID(final String userId) {
139
120
  Repro.setUserID(userId);
140
121
  }
141
122
 
142
- @ReactMethod
143
123
  public void getUserID(Callback callback) {
144
124
  callback.invoke(null, Repro.getUserID());
145
125
  }
146
126
 
147
- @ReactMethod
148
127
  public void setSilverEggCookie(final String cookie) {
149
128
  Repro.setSilverEggCookie(cookie);
150
129
  }
151
130
 
152
- @ReactMethod
153
131
  public void setSilverEggProdKey(final String prodKey) {
154
132
  Repro.setSilverEggProdKey(prodKey);
155
133
  }
156
134
 
157
- @ReactMethod
158
135
  public void setLogLevel(final int logLevel) {
159
136
  Repro.setLogLevel(logLevel);
160
137
  }
161
138
 
162
- @ReactMethod
163
139
  public void setStringUserProfile(final String key, final String value) {
164
140
  Repro.setStringUserProfile(key, value);
165
141
  }
166
142
 
167
- @ReactMethod
168
143
  public void setIntUserProfile(final String key, final int value) {
169
144
  Repro.setIntUserProfile(key, value);
170
145
  }
171
146
 
172
- @ReactMethod
173
147
  public void setDoubleUserProfile(final String key, final double value) {
174
148
  Repro.setDoubleUserProfile(key, value);
175
149
  }
176
150
 
177
- @ReactMethod
178
151
  public void setDateUserProfile(final String key, final String value) {
179
152
  try{
180
153
  String isoTime = value.replace("Z", "+00:00");
@@ -186,12 +159,10 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
186
159
  }
187
160
  }
188
161
 
189
- @ReactMethod
190
162
  public void setUserEmailAddress(final String mailAddr) {
191
163
  Repro.setUserEmailAddress(mailAddr);
192
164
  }
193
165
 
194
- @ReactMethod
195
166
  public void setUserGender(final int gender) {
196
167
  if (BuildConfig.DEBUG) {
197
168
  Repro.setUserGender(UserProfileGender.values()[gender]);
@@ -206,7 +177,6 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
206
177
  }
207
178
  }
208
179
 
209
- @ReactMethod
210
180
  public void setUserResidencePrefecture(final int prefecture) {
211
181
  if (BuildConfig.DEBUG) {
212
182
  Repro.setUserResidencePrefecture(UserProfilePrefecture.values()[prefecture - 1]);
@@ -220,7 +190,6 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
220
190
  }
221
191
  }
222
192
 
223
- @ReactMethod
224
193
  public void setUserDateOfBirth(final String value) {
225
194
  try{
226
195
  String isoTime = value.replace("Z", "+00:00");
@@ -232,52 +201,166 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
232
201
  }
233
202
  }
234
203
 
235
- @ReactMethod
236
204
  public void setUserAge(int age) {
237
205
  Repro.setUserAge(age);
238
206
  }
239
207
 
240
- @ReactMethod
208
+ public void onlySetIfAbsentStringUserProfile(String key, String value) {
209
+ Repro.onlySetIfAbsentStringUserProfile(key, value);
210
+ }
211
+
212
+ public void onlySetIfAbsentIntUserProfile(String key, int value) {
213
+ Repro.onlySetIfAbsentIntUserProfile(key, value);
214
+ }
215
+
216
+ public void onlySetIfAbsentDoubleUserProfile(String key, double value) {
217
+ Repro.onlySetIfAbsentDoubleUserProfile(key, value);
218
+ }
219
+
220
+ public void onlySetIfAbsentDateUserProfile(String key, String value) {
221
+ try{
222
+ String isoTime = value.replace("Z", "+00:00");
223
+ Date date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").parse(isoTime);
224
+ Repro.onlySetIfAbsentDateUserProfile(key, date);
225
+ }
226
+ catch(Exception e) {
227
+ Log.e("Repro", "Wrong formatted date String: " + value);
228
+ }
229
+ }
230
+
231
+ public void incrementIntUserProfileBy(String key, int value) {
232
+ Repro.incrementIntUserProfileBy(key, value);
233
+ }
234
+
235
+ public void decrementIntUserProfileBy(String key, int value) {
236
+ Repro.decrementIntUserProfileBy(key, value);
237
+ }
238
+
239
+ public void incrementDoubleUserProfileBy(String key, double value) {
240
+ Repro.incrementDoubleUserProfileBy(key, value);
241
+ }
242
+
243
+ public void decrementDoubleUserProfileBy(String key, double value) {
244
+ Repro.decrementDoubleUserProfileBy(key, value);
245
+ }
246
+
247
+ public void onlySetIfAbsentUserGender(final int gender) {
248
+ if (BuildConfig.DEBUG) {
249
+ Repro.onlySetIfAbsentUserGender(UserProfileGender.values()[gender]);
250
+ return;
251
+ }
252
+ try {
253
+ Repro.onlySetIfAbsentUserGender(UserProfileGender.values()[gender]);
254
+ }
255
+ catch(ArrayIndexOutOfBoundsException exception) {
256
+ Log.e("Repro", "Wrong gender selected. Allowed values are GENDER_MALE, GENDER_FEMALE and GENDER_OTHER.");
257
+ }
258
+ }
259
+
260
+ public void onlySetIfAbsentUserEmailAddress(String email) {
261
+ Repro.onlySetIfAbsentUserEmailAddress(email);
262
+ }
263
+
264
+ public void onlySetIfAbsentUserResidencePrefecture(final int prefecture) {
265
+ if (BuildConfig.DEBUG) {
266
+ Repro.onlySetIfAbsentUserResidencePrefecture(UserProfilePrefecture.values()[prefecture - 1]);
267
+ return;
268
+ }
269
+ try {
270
+ Repro.onlySetIfAbsentUserResidencePrefecture(UserProfilePrefecture.values()[prefecture - 1]);
271
+ }
272
+ catch (ArrayIndexOutOfBoundsException exception) {
273
+ Log.e("Repro", "Wrong prefecture selected.");
274
+ }
275
+ }
276
+
277
+ public void onlySetIfAbsentUserDateOfBirth(final String value) {
278
+ try{
279
+ String isoTime = value.replace("Z", "+00:00");
280
+ Date date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").parse(isoTime);
281
+ Repro.onlySetIfAbsentUserDateOfBirth(date);
282
+ }
283
+ catch(Exception e) {
284
+ Log.e("Repro", "onlySetIfAbsentUserDateOfBirth: Wrong formatted date String: " + value);
285
+ }
286
+ }
287
+
288
+ public void onlySetIfAbsentUserAge(int age) {
289
+ Repro.onlySetIfAbsentUserAge(age);
290
+ }
291
+
292
+ public void incrementUserAgeBy(int value) {
293
+ Repro.incrementUserAgeBy(value);
294
+ }
295
+
296
+ public void decrementUserAgeBy(int value) {
297
+ Repro.decrementUserAgeBy(value);
298
+ }
299
+
300
+ public void deleteUserProfile(String key) {
301
+ Repro.deleteUserProfile(key);
302
+ }
303
+
304
+ public void deleteUserGender() {
305
+ Repro.deleteUserGender();
306
+ }
307
+
308
+ public void deleteUserEmailAddress() {
309
+ Repro.deleteUserEmailAddress();
310
+ }
311
+
312
+ public void deleteUserResidencePrefecture() {
313
+ Repro.deleteUserResidencePrefecture();
314
+ }
315
+
316
+ public void deleteUserDateOfBirth() {
317
+ Repro.deleteUserDateOfBirth();
318
+ }
319
+
320
+ public void deleteUserAge() {
321
+ Repro.deleteUserAge();
322
+ }
323
+
241
324
  public void getDeviceID(Callback callback) {
242
325
  callback.invoke(null, Repro.getDeviceID());
243
326
  }
244
327
 
245
- @ReactMethod
246
328
  public void disableInAppMessagesOnForegroundTransition() {
247
329
  Repro.disableInAppMessagesOnForegroundTransition();
248
330
  }
249
331
 
250
- @ReactMethod
251
- public void enableInAppMessagesOnForegroundTransition() {
252
- Repro.enableInAppMessagesOnForegroundTransition(this.getCurrentActivity());
332
+ public void enableInAppMessagesOnForegroundTransition(Activity activity) {
333
+ Repro.enableInAppMessagesOnForegroundTransition(activity);
334
+ }
335
+
336
+ public void setPushDeviceTokenString(final String deviceTokenHexString) {
337
+ Repro.setPushRegistrationID(deviceTokenHexString);
253
338
  }
254
339
 
255
- @ReactMethod
256
340
  public void setPushRegistrationID(final String pushRegId) {
257
341
  Repro.setPushRegistrationID(pushRegId);
258
342
  }
259
343
 
260
- @ReactMethod
261
344
  public void setPushToken(final String token) {
262
345
  Repro.setPushRegistrationID(token);
263
346
  }
264
347
 
265
- @ReactMethod
266
348
  public void enablePushNotification() {
267
349
  Repro.enablePushNotification();
268
350
  }
269
351
 
270
- @ReactMethod
271
352
  public void linkLineID(final String lineUserId, final String lineChannelId) {
272
353
  Repro.linkLineID(lineUserId, lineChannelId);
273
354
  }
274
355
 
275
- @ReactMethod
276
356
  public void unlinkLineID(final String lineUserId, final String lineChannelId) {
277
357
  Repro.unlinkLineID(lineUserId, lineChannelId);
278
358
  }
279
359
 
280
- @ReactMethod
360
+ public void _webviewJavaScriptOpenUrlHandler(String requestUrl) {
361
+ Repro._webviewJavaScriptOpenUrlHandler(requestUrl);
362
+ }
363
+
281
364
  public void track(final String name, final ReadableMap properties) {
282
365
  if (properties == null) {
283
366
  Repro.track(name);
@@ -286,7 +369,6 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
286
369
  }
287
370
  }
288
371
 
289
- @ReactMethod
290
372
  public void trackViewContent(final String contentId, final ReadableMap props) {
291
373
  ViewContentProperties properties = new ViewContentProperties();
292
374
 
@@ -299,7 +381,6 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
299
381
  Repro.trackViewContent(contentId, properties);
300
382
  }
301
383
 
302
- @ReactMethod
303
384
  public void trackSearch(final ReadableMap props) {
304
385
  SearchProperties properties = new SearchProperties();
305
386
 
@@ -313,7 +394,6 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
313
394
  Repro.trackSearch(properties);
314
395
  }
315
396
 
316
- @ReactMethod
317
397
  public void trackAddToWishlist(final ReadableMap props) {
318
398
  AddToWishlistProperties properties = new AddToWishlistProperties();
319
399
 
@@ -327,7 +407,6 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
327
407
  Repro.trackAddToWishlist(properties);
328
408
  }
329
409
 
330
- @ReactMethod
331
410
  public void trackAddToCart(final String contentId, final ReadableMap props) {
332
411
  AddToCartProperties properties = new AddToCartProperties();
333
412
 
@@ -340,7 +419,6 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
340
419
  Repro.trackAddToCart(contentId, properties);
341
420
  }
342
421
 
343
- @ReactMethod
344
422
  public void trackInitiateCheckout(final ReadableMap props) {
345
423
  InitiateCheckoutProperties properties = new InitiateCheckoutProperties();
346
424
 
@@ -355,7 +433,6 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
355
433
  Repro.trackInitiateCheckout(properties);
356
434
  }
357
435
 
358
- @ReactMethod
359
436
  public void trackAddPaymentInfo(final ReadableMap props) {
360
437
  AddPaymentInfoProperties properties = new AddPaymentInfoProperties();
361
438
 
@@ -368,7 +445,6 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
368
445
  Repro.trackAddPaymentInfo(properties);
369
446
  }
370
447
 
371
- @ReactMethod
372
448
  public void trackPurchase(final String contentId, final double value, final String currency, final ReadableMap props) {
373
449
  PurchaseProperties properties = new PurchaseProperties();
374
450
 
@@ -380,7 +456,6 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
380
456
  Repro.trackPurchase(contentId, value, currency, properties);
381
457
  }
382
458
 
383
- @ReactMethod
384
459
  public void trackShare(final ReadableMap props) {
385
460
  ShareProperties properties = new ShareProperties();
386
461
 
@@ -393,7 +468,6 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
393
468
  Repro.trackShare(properties);
394
469
  }
395
470
 
396
- @ReactMethod
397
471
  public void trackCompleteRegistration(final ReadableMap props) {
398
472
  CompleteRegistrationProperties properties = new CompleteRegistrationProperties();
399
473
 
@@ -406,7 +480,6 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
406
480
  Repro.trackCompleteRegistration(properties);
407
481
  }
408
482
 
409
- @ReactMethod
410
483
  public void trackLead(final ReadableMap props) {
411
484
  LeadProperties properties = new LeadProperties();
412
485
 
@@ -419,7 +492,6 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
419
492
  Repro.trackLead(properties);
420
493
  }
421
494
 
422
- @ReactMethod
423
495
  public void trackNotificationOpened(final String notificationId) {
424
496
  Repro.trackNotificationOpened(notificationId);
425
497
  }
@@ -470,8 +542,83 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
470
542
  return array;
471
543
  }
472
544
 
473
- @ReactMethod
474
- public void getNewsFeeds(final int limit, final int campaignType, Callback callback) {
545
+ private WritableArray toWritableArrayForNewArchitecture(List<NewsFeedEntry> entries) {
546
+ WritableArray array = new WritableNativeArray();
547
+
548
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US);
549
+ format.setTimeZone(TimeZone.getTimeZone("gmt"));
550
+
551
+ for (NewsFeedEntry entry : entries) {
552
+ WritableMap entryMap = Arguments.createMap();
553
+
554
+ String linkUrl;
555
+ if (entry.linkUrl == null) {
556
+ linkUrl = "";
557
+ } else {
558
+ linkUrl = entry.linkUrl.toString().equals("null") ? "" : entry.linkUrl.toString();
559
+ }
560
+
561
+ String imageUrl;
562
+ if (entry.imageUrl == null) {
563
+ imageUrl = "";
564
+ } else {
565
+ imageUrl = entry.imageUrl.toString().equals("null") ? "" : entry.imageUrl.toString();
566
+ }
567
+
568
+ entryMap.putDouble("id", entry.id);
569
+ entryMap.putString("deviceID", entry.deviceID);
570
+ entryMap.putString("title", entry.title.equals("null") ? null : entry.title);
571
+ entryMap.putString("summary", entry.summary.equals("null") ? null : entry.summary);
572
+ entryMap.putString("body", entry.body.equals("null") ? null : entry.body);
573
+ entryMap.putInt("campaignType", convertCampaignTypeToInt(entry.campaignType));
574
+
575
+ entryMap.putBoolean("shown", entry.shown);
576
+ entryMap.putBoolean("read", entry.read);
577
+
578
+ entryMap.putString("deliveredAt", format.format(entry.deliveredAt));
579
+
580
+ entryMap.putString("linkUrl", linkUrl);
581
+ entryMap.putString("linkUrlString", entry.linkUrlString);
582
+ entryMap.putString("imageUrl", imageUrl);
583
+ entryMap.putString("imageUrlString", entry.imageUrlString);
584
+
585
+ array.pushMap(entryMap);
586
+ }
587
+
588
+ return array;
589
+ }
590
+
591
+ private JSONObject toNewsFeedEntryJsonObject(Map<String, Object> map) {
592
+ Map<String, Object> newsFeedEntryMap = new HashMap<>();
593
+
594
+ newsFeedEntryMap.put("newsfeed_id", map.get("id"));
595
+ newsFeedEntryMap.put("device_id", map.get("deviceID"));
596
+ newsFeedEntryMap.put("title", map.get("title"));
597
+ newsFeedEntryMap.put("summary", map.get("summary"));
598
+ newsFeedEntryMap.put("body", map.get("body"));
599
+ newsFeedEntryMap.put("shown", map.get("shown"));
600
+ newsFeedEntryMap.put("read", map.get("read"));
601
+ newsFeedEntryMap.put("delivered_at", map.get("deliveredAt"));
602
+ newsFeedEntryMap.put("campaign_type", map.get("campaignType"));
603
+ newsFeedEntryMap.put("link_url", map.get("linkUrl"));
604
+ newsFeedEntryMap.put("image_url", map.get("imageUrl"));
605
+
606
+ return new JSONObject(newsFeedEntryMap);
607
+ }
608
+
609
+ public void getNewsFeeds(final int limit, Callback callback) {
610
+ NewsFeedCampaignType type = NewsFeedCampaignType.PushNotification;
611
+
612
+ try {
613
+ callback.invoke(null, toWritableArrayForNewArchitecture(Repro.getNewsFeeds(limit, type)));
614
+ } catch (Exception e) {
615
+ WritableMap entryMap = Arguments.createMap();
616
+ entryMap.putString("message", e.getMessage());
617
+ callback.invoke(entryMap, null);
618
+ }
619
+ }
620
+
621
+ public void oldArchGetNewsFeeds(final int limit, final int campaignType, Callback callback) {
475
622
  NewsFeedCampaignType type = convertCampaignTypeFromInt(campaignType);
476
623
 
477
624
  try {
@@ -483,8 +630,19 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
483
630
  }
484
631
  }
485
632
 
486
- @ReactMethod
487
- public void getNewsFeedsFor(final int limit, final int offsetID, final int campaignType, Callback callback) {
633
+ public void getNewsFeedsFor(final int limit, final int offsetID, Callback callback) {
634
+ NewsFeedCampaignType type = NewsFeedCampaignType.PushNotification;
635
+
636
+ try {
637
+ callback.invoke(null, toWritableArrayForNewArchitecture(Repro.getNewsFeeds(limit, offsetID, type)));
638
+ } catch (Exception e) {
639
+ WritableMap entryMap = Arguments.createMap();
640
+ entryMap.putString("message", e.getMessage());
641
+ callback.invoke(entryMap, null);
642
+ }
643
+ }
644
+
645
+ public void oldArchGetNewsFeedsFor(final int limit, final int offsetID, final int campaignType, Callback callback) {
488
646
  NewsFeedCampaignType type = convertCampaignTypeFromInt(campaignType);
489
647
 
490
648
  try {
@@ -496,10 +654,52 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
496
654
  }
497
655
  }
498
656
 
499
- @ReactMethod
657
+ public void getNewsFeedsWithCampaignType(final int limit, final int campaignType, Callback callback) {
658
+ NewsFeedCampaignType type = convertCampaignTypeFromInt(campaignType);
659
+
660
+ try {
661
+ callback.invoke(null, toWritableArrayForNewArchitecture(Repro.getNewsFeeds(limit, type)));
662
+ } catch (Exception e) {
663
+ WritableMap entryMap = Arguments.createMap();
664
+ entryMap.putString("message", e.getMessage());
665
+ callback.invoke(entryMap, null);
666
+ }
667
+ }
668
+
669
+ public void getNewsFeedsWithCampaignTypeFor(final int limit, final int offsetID, final int campaignType, Callback callback) {
670
+ NewsFeedCampaignType type = convertCampaignTypeFromInt(campaignType);
671
+
672
+ try {
673
+ callback.invoke(null, toWritableArrayForNewArchitecture(Repro.getNewsFeeds(limit, offsetID, type)));
674
+ } catch (Exception e) {
675
+ WritableMap entryMap = Arguments.createMap();
676
+ entryMap.putString("message", e.getMessage());
677
+ callback.invoke(entryMap, null);
678
+ }
679
+ }
680
+
500
681
  public void updateNewsFeeds(ReadableArray array, Callback callback) {
501
682
  List<NewsFeedEntry> entries = new ArrayList<>();
502
683
 
684
+ for (int i = 0; i < array.size() ; i++) {
685
+ Map<String, Object> map = array.getMap(i).toHashMap();
686
+ JSONObject json = toNewsFeedEntryJsonObject(map);
687
+ entries.add(new NewsFeedEntry(json));
688
+ }
689
+
690
+ try {
691
+ Repro.updateNewsFeeds(entries);
692
+ callback.invoke(null, null);
693
+ } catch(Exception e) {
694
+ WritableMap error = Arguments.createMap();
695
+ error.putString("message", e.getMessage());
696
+ callback.invoke(error);
697
+ }
698
+ }
699
+
700
+ public void oldArchUpdateNewsFeeds(ReadableArray array, Callback callback) {
701
+ List<NewsFeedEntry> entries = new ArrayList<>();
702
+
503
703
  for (int i = 0; i < array.size() ; i++) {
504
704
  Map<String, Object> map = array.getMap(i).toHashMap();
505
705
  JSONObject json = new JSONObject(map);
@@ -508,6 +708,7 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
508
708
 
509
709
  try {
510
710
  Repro.updateNewsFeeds(entries);
711
+ callback.invoke(null, null);
511
712
  } catch(Exception e) {
512
713
  WritableMap error = Arguments.createMap();
513
714
  error.putString("message", e.getMessage());
@@ -544,6 +745,3 @@ public class ReproReactBridgeModule extends ReactContextBaseJavaModule {
544
745
  return CAMPAIGN_TYPE_UNKNOWN;
545
746
  }
546
747
  }
547
-
548
-
549
-