react-native-repro 3.24.0 → 4.0.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 (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} +262 -70
  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 +44 -232
  14. package/ios/RPRReproReactBridge.h +19 -4
  15. package/ios/{RPRReproReactBridge.m → RPRReproReactBridge.mm} +660 -193
  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.1/repro-android-sdk-5.20.1.aar +0 -0
  20. package/sdk-android/io/repro/repro-android-sdk/5.20.1/repro-android-sdk-5.20.1.aar.md5 +1 -0
  21. package/sdk-android/io/repro/repro-android-sdk/5.20.1/repro-android-sdk-5.20.1.aar.sha1 +1 -0
  22. package/sdk-android/io/repro/repro-android-sdk/5.20.1/repro-android-sdk-5.20.1.pom +24 -0
  23. package/sdk-android/io/repro/repro-android-sdk/5.20.1/repro-android-sdk-5.20.1.pom.md5 +1 -0
  24. package/sdk-android/io/repro/repro-android-sdk/5.20.1/repro-android-sdk-5.20.1.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
@@ -0,0 +1,713 @@
1
+ //
2
+ // RPRReproReactBridgeImpl.m
3
+ // RPRReproReactBridgeImpl
4
+ //
5
+ // Created by Koki Oshima on 2025/07/16.
6
+ // Copyright © 2025 Repro Inc. All rights reserved.
7
+ //
8
+
9
+
10
+ #import "RPRReproReactBridgeImpl.h"
11
+ #import <Repro/Repro.h>
12
+ #import <Repro/RPRRemoteConfig.h>
13
+ #import <Repro/RPRNewsFeedEntry.h>
14
+ #import <Repro/RPRUserProfileTypes.h>
15
+ #import <React/RCTLog.h>
16
+
17
+ // ReactNative Version >= 0.41
18
+ #if __has_include(<React/RCTConvert.h>)
19
+ #import <React/RCTConvert.h>
20
+
21
+ // ReactNative Version < 0.41
22
+ #elif __has_include("RCTConvert.h")
23
+ #import "RCTConvert.h"
24
+
25
+ // if ReactNative is a cocoapod and the project has swift enabled
26
+ #elif __has_include("React/RCTConvert.h")
27
+ #import "React/RCTConvert.h"
28
+
29
+ #else
30
+ #error "Can't find RCTConvert.h anywhere."
31
+ #endif
32
+
33
+ static NSObject*
34
+ safe_value(id value)
35
+ {
36
+ return (value != nil) ? value : [NSNull null];
37
+ }
38
+
39
+ @interface Repro (NonPublicApi)
40
+ + (BOOL)_webviewJavaScriptOpenUrlHandler:(NSString *)url;
41
+ @end
42
+
43
+ @implementation RPRReproReactBridgeImpl
44
+
45
+ // Remote Config
46
+ - (NSDictionary *)toDictionary:(NSDictionary<NSString *, RPRRemoteConfigValue *> *)values
47
+ {
48
+ NSMutableDictionary *dict = [NSMutableDictionary.alloc initWithCapacity:values.count];
49
+
50
+ for (NSString* key in values.allKeys) {
51
+ RPRRemoteConfigValue* value = values[key];
52
+ if (value.stringValue) {
53
+ [dict setObject:value.stringValue forKey:key];
54
+ }
55
+ }
56
+
57
+ return [NSDictionary.alloc initWithDictionary: dict];
58
+ }
59
+
60
+ /// You may not need this method because the default behavior is:
61
+ /// - After a call to `Repro.setup()`, automatically fetch every time the app will enter foreground
62
+ /// - Run `activateFetched` as soon as a response was received.
63
+ ///
64
+ /// If you need a completionHandler to ensure the remoteConfig gets activated at a certain point in time
65
+ /// or want to validate remote config functionality while development, you should use this method. You can
66
+ /// only set one completionHandler at a time. Also only one fetch per app foreground/background cycle is
67
+ /// permitted. Therefore you should call this when your app comes to foreground, preferably
68
+ /// from `applicationWillEnterForeground`.
69
+ ///
70
+ /// If the completionHandler handler is called with status `RPRRemoteConfigFetchStatusSuccess`, you should
71
+ /// proceed with calling `activateFetched` in the completionHandler or after the completionHandler has
72
+ /// been executed.
73
+ ///
74
+ /// After `activateFetched` has been called, new remote config values are available. This completionHandler
75
+ /// is always guaranteed to be called on the main thread. The callback will be invalidated and not executed
76
+ /// if the app goes to background or the end-user OptsOut via the OptIn/OptOut API.
77
+ - (void)fetch:(double)timeout completionHandler:(RCTResponseSenderBlock)callback
78
+ {
79
+ double timeoutSecs = timeout * 0.001;
80
+ [[Repro remoteConfig] fetchWithTimeout:timeoutSecs completionHandler:^(RPRRemoteConfigFetchStatus status) {
81
+ callback(@[@(status)]);
82
+ }];
83
+ }
84
+
85
+ /// This is only needed if you use `fetchWithTimeout:completionHandler:`. See above.
86
+ /// Returns YES if a previously fetched remote config has replaced the current remote config.
87
+ - (void)activateFetched
88
+ {
89
+ [[Repro remoteConfig] activateFetched];
90
+ }
91
+
92
+ /// Set local defaults for remote config queries via dictionary.
93
+ - (void)setDefaultsFromDictionary:(NSDictionary<NSString *, id> *) json
94
+ {
95
+ [[Repro remoteConfig] setDefaultsFromDictionary: json];
96
+ }
97
+
98
+ /// Set local defaults for remote config queries via a json string.
99
+ - (void)setDefaultsFromJsonString:(NSString *)string
100
+ {
101
+ [[Repro remoteConfig] setDefaultsFromJsonString: string];
102
+ }
103
+
104
+ /// Access to remote config values.
105
+ - (void)getValue:(NSString*)key callback:(RCTResponseSenderBlock)callback
106
+ {
107
+ callback(@[safe_value([[[Repro remoteConfig] valueForKey: key] stringValue])]);
108
+ }
109
+
110
+ /// Return a dictonary with all key value pairs.
111
+ - (void)getAllValues:(RCTResponseSenderBlock)callback
112
+ {
113
+ callback(@[safe_value([self toDictionary: [[Repro remoteConfig] allValues]])]);
114
+ }
115
+
116
+ /// Return a dictonary with all key value pairs for a given prefix. Pass `nil` or an empty string to get all values.
117
+ - (void)getAllValuesWithPrefix:(NSString*)key callback:(RCTResponseSenderBlock)callback
118
+ {
119
+ callback(@[safe_value([self toDictionary:[[Repro remoteConfig] allValuesWithPrefix: key]])]);
120
+ }
121
+
122
+ /// Returns the local default value for a key.
123
+ - (void)getLocalDefaultValue:(NSString*)key callback:(RCTResponseSenderBlock)callback
124
+ {
125
+ callback(@[safe_value([[[Repro remoteConfig] localDefaultValueForKey: key] stringValue])]);
126
+ }
127
+
128
+ /// Reset all data. Local config & remote Config. Should only be used while in development.
129
+ - (void)forceReset
130
+ {
131
+ [[Repro remoteConfig] forceReset];
132
+ }
133
+
134
+ // Repro
135
+ // Opt In / Opt Out
136
+
137
+ - (void)optIn:(BOOL)endUserOptedIn
138
+ {
139
+ [Repro optIn:endUserOptedIn];
140
+ }
141
+
142
+ // User profile
143
+
144
+ - (void)setUserID:(NSString *)userID
145
+ {
146
+ [Repro setUserID:userID];
147
+ }
148
+
149
+ - (void)getUserID:(RCTResponseSenderBlock)callback
150
+ {
151
+ callback(@[[NSNull null], safe_value([Repro getUserID])]);
152
+ }
153
+
154
+ - (void)getDeviceID:(RCTResponseSenderBlock)callback
155
+ {
156
+ callback(@[[NSNull null], safe_value([Repro getDeviceID])]);
157
+ }
158
+
159
+ - (void)setStringUserProfile:(NSString *)key value:(NSString *)value
160
+ {
161
+ [Repro setStringUserProfile:value forKey:key];
162
+ }
163
+
164
+ - (void)setIntUserProfile:(NSString *)key value:(NSInteger)value
165
+ {
166
+ [Repro setIntUserProfile:value forKey:key];
167
+ }
168
+
169
+ - (void)setDoubleUserProfile:(NSString *)key value:(double)value
170
+ {
171
+ [Repro setDoubleUserProfile:value forKey:key];
172
+ }
173
+
174
+ - (void)setDateUserProfile:(NSString *)key value:(NSDate *)value
175
+ {
176
+ [Repro setDateUserProfile:value forKey:key];
177
+ }
178
+
179
+ - (void)setUserGender:(RPRUserProfileGender)value
180
+ {
181
+ [Repro setUserGender:value];
182
+ }
183
+
184
+ - (void)setUserEmailAddress:(NSString *)value
185
+ {
186
+ [Repro setUserEmailAddress:value];
187
+ }
188
+
189
+ - (void)setUserResidencePrefecture:(RPRUserProfilePrefecture)value
190
+ {
191
+ [Repro setUserResidencePrefecture:value];
192
+ }
193
+
194
+ - (void)setUserDateOfBirth:(NSDate *)value
195
+ {
196
+ [Repro setUserDateOfBirth:value];
197
+ }
198
+
199
+ - (void)setUserAge:(NSInteger)value
200
+ {
201
+ [Repro setUserAge:value];
202
+ }
203
+
204
+ - (void)onlySetIfAbsentStringUserProfile:(NSString *)key value:(NSString *)value
205
+ {
206
+ [Repro onlySetIfAbsentStringUserProfile:value forKey:key];
207
+ }
208
+
209
+ - (void)onlySetIfAbsentIntUserProfile:(NSString *)key value:(NSInteger)value
210
+ {
211
+ [Repro onlySetIfAbsentIntUserProfile:value forKey:key];
212
+ }
213
+
214
+ - (void)onlySetIfAbsentDoubleUserProfile:(NSString *)key value:(double)value
215
+ {
216
+ [Repro onlySetIfAbsentDoubleUserProfile:value forKey:key];
217
+ }
218
+
219
+ - (void)onlySetIfAbsentDateUserProfile:(NSString *)key value:(NSDate *)value
220
+ {
221
+ [Repro onlySetIfAbsentDateUserProfile:value forKey:key];
222
+ }
223
+
224
+ - (void)incrementIntUserProfileBy:(NSString *)key value:(NSInteger)value
225
+ {
226
+ [Repro incrementIntUserProfileBy:value forKey:key];
227
+ }
228
+
229
+ - (void)decrementIntUserProfileBy:(NSString *)key value:(NSInteger)value
230
+ {
231
+ [Repro decrementIntUserProfileBy:value forKey:key];
232
+ }
233
+
234
+ - (void)incrementDoubleUserProfileBy:(NSString *)key value:(double)value
235
+ {
236
+ [Repro incrementDoubleUserProfileBy:value forKey:key];
237
+ }
238
+
239
+ - (void)decrementDoubleUserProfileBy:(NSString *)key value:(double)value
240
+ {
241
+ [Repro decrementDoubleUserProfileBy:value forKey:key];
242
+ }
243
+
244
+ - (void)onlySetIfAbsentUserGender:(RPRUserProfileGender)value
245
+ {
246
+ [Repro onlySetIfAbsentUserGender:value];
247
+ }
248
+
249
+ - (void)onlySetIfAbsentUserEmailAddress:(NSString *)value
250
+ {
251
+ [Repro onlySetIfAbsentUserEmailAddress:value];
252
+ }
253
+
254
+ - (void)onlySetIfAbsentUserResidencePrefecture:(RPRUserProfilePrefecture)value
255
+ {
256
+ [Repro onlySetIfAbsentUserResidencePrefecture:value];
257
+ }
258
+
259
+ - (void)onlySetIfAbsentUserDateOfBirth:(NSDate *)value
260
+ {
261
+ [Repro onlySetIfAbsentUserDateOfBirth:value];
262
+ }
263
+
264
+ - (void)onlySetIfAbsentUserAge:(NSInteger)value
265
+ {
266
+ [Repro onlySetIfAbsentUserAge:value];
267
+ }
268
+
269
+ - (void)incrementUserAgeBy:(NSInteger)value
270
+ {
271
+ [Repro incrementUserAgeBy:value];
272
+ }
273
+
274
+ - (void)decrementUserAgeBy:(NSInteger)value
275
+ {
276
+ [Repro decrementUserAgeBy:value];
277
+ }
278
+
279
+ - (void)deleteUserProfile:(NSString *)key
280
+ {
281
+ [Repro deleteUserProfile:key];
282
+ }
283
+
284
+ - (void)deleteUserGender
285
+ {
286
+ [Repro deleteUserGender];
287
+ }
288
+
289
+ - (void)deleteUserEmailAddress
290
+ {
291
+ [Repro deleteUserEmailAddress];
292
+ }
293
+
294
+ - (void)deleteUserResidencePrefecture
295
+ {
296
+ [Repro deleteUserResidencePrefecture];
297
+ }
298
+
299
+ - (void)deleteUserDateOfBirth
300
+ {
301
+ [Repro deleteUserDateOfBirth];
302
+ }
303
+
304
+ - (void)deleteUserAge
305
+ {
306
+ [Repro deleteUserAge];
307
+ }
308
+
309
+ // Custom event tracking
310
+
311
+ - (void)track:(NSString *)eventName properties:(NSDictionary *)props
312
+ {
313
+ [Repro track:eventName properties:[RCTConvert NSDictionary:props]];
314
+ }
315
+
316
+ // Standard event tracking
317
+
318
+ - (void)trackViewContent:(NSString *)contentID properties:(NSDictionary *)props
319
+ {
320
+ RPRViewContentProperties *properties = [[RPRViewContentProperties alloc] init];
321
+
322
+ NSObject *val = nil;
323
+ if ((val = props[@"value"])) { properties.value = [RCTConvert double:val]; }
324
+ if ((val = props[@"currency"])) { properties.currency = [RCTConvert NSString:val]; }
325
+ if ((val = props[@"content_category"])) { properties.contentCategory = [RCTConvert NSString:val]; }
326
+ if ((val = props[@"content_name"])) { properties.contentName = [RCTConvert NSString:val]; }
327
+ if ((val = props[@"extras"])) { properties.extras = [RCTConvert NSDictionary:val]; }
328
+
329
+ [Repro trackViewContent:contentID properties:properties];
330
+ }
331
+
332
+ - (void)trackSearch:(NSDictionary *)props
333
+ {
334
+ RPRSearchProperties *properties = [[RPRSearchProperties alloc] init];
335
+
336
+ NSObject *val = nil;
337
+ if ((val = props[@"value"])) { properties.value = [RCTConvert double:val]; }
338
+ if ((val = props[@"currency"])) { properties.currency = [RCTConvert NSString:val]; }
339
+ if ((val = props[@"content_category"])) { properties.contentCategory = [RCTConvert NSString:val]; }
340
+ if ((val = props[@"content_id"])) { properties.contentID = [RCTConvert NSString:val]; }
341
+ if ((val = props[@"search_string"])) { properties.searchString = [RCTConvert NSString:val]; }
342
+ if ((val = props[@"extras"])) { properties.extras = [RCTConvert NSDictionary:val]; }
343
+
344
+ [Repro trackSearch:properties];
345
+ }
346
+
347
+
348
+
349
+ - (void)trackAddToCart:(NSString *)contentID properties:(NSDictionary *)props
350
+ {
351
+ RPRAddToCartProperties *properties = [[RPRAddToCartProperties alloc] init];
352
+
353
+ NSObject *val = nil;
354
+ if ((val = props[@"value"])) { properties.value = [RCTConvert double:val]; }
355
+ if ((val = props[@"currency"])) { properties.currency = [RCTConvert NSString:val]; }
356
+ if ((val = props[@"content_category"])) { properties.contentCategory = [RCTConvert NSString:val]; }
357
+ if ((val = props[@"content_name"])) { properties.contentName = [RCTConvert NSString:val]; }
358
+ if ((val = props[@"extras"])) { properties.extras = [RCTConvert NSDictionary:val]; }
359
+
360
+ [Repro trackAddToCart:contentID properties:properties];
361
+ }
362
+
363
+
364
+ - (void)trackAddToWishlist:(NSDictionary *)props
365
+ {
366
+ RPRAddToWishlistProperties *properties = [[RPRAddToWishlistProperties alloc] init];
367
+
368
+ NSObject *val = nil;
369
+ if ((val = props[@"value"])) { properties.value = [RCTConvert double:val]; }
370
+ if ((val = props[@"currency"])) { properties.currency = [RCTConvert NSString:val]; }
371
+ if ((val = props[@"content_category"])) { properties.contentCategory = [RCTConvert NSString:val]; }
372
+ if ((val = props[@"content_id"])) { properties.contentID = [RCTConvert NSString:val]; }
373
+ if ((val = props[@"content_name"])) { properties.contentName = [RCTConvert NSString:val]; }
374
+ if ((val = props[@"extras"])) { properties.extras = [RCTConvert NSDictionary:val]; }
375
+
376
+ [Repro trackAddToWishlist:properties];
377
+ }
378
+
379
+ - (void)trackInitiateCheckout:(NSDictionary *)props
380
+ {
381
+ RPRInitiateCheckoutProperties *properties = [[RPRInitiateCheckoutProperties alloc] init];
382
+
383
+ NSObject *val = nil;
384
+ if ((val = props[@"value"])) { properties.value = [RCTConvert double:val]; }
385
+ if ((val = props[@"currency"])) { properties.currency = [RCTConvert NSString:val]; }
386
+ if ((val = props[@"content_category"])) { properties.contentCategory = [RCTConvert NSString:val]; }
387
+ if ((val = props[@"content_id"])) { properties.contentID = [RCTConvert NSString:val]; }
388
+ if ((val = props[@"content_name"])) { properties.contentName = [RCTConvert NSString:val]; }
389
+ if ((val = props[@"num_items"])) { properties.numItems = [RCTConvert NSInteger:val]; }
390
+ if ((val = props[@"extras"])) { properties.extras = [RCTConvert NSDictionary:val]; }
391
+
392
+ [Repro trackInitiateCheckout:properties];
393
+ }
394
+
395
+ - (void)trackAddPaymentInfo:(NSDictionary *)props
396
+ {
397
+ RPRAddPaymentInfoProperties *properties = [[RPRAddPaymentInfoProperties alloc] init];
398
+
399
+ NSObject *val = nil;
400
+ if ((val = props[@"value"])) { properties.value = [RCTConvert double:val]; }
401
+ if ((val = props[@"currency"])) { properties.currency = [RCTConvert NSString:val]; }
402
+ if ((val = props[@"content_category"])) { properties.contentCategory = [RCTConvert NSString:val]; }
403
+ if ((val = props[@"content_id"])) { properties.contentID = [RCTConvert NSString:val]; }
404
+ if ((val = props[@"extras"])) { properties.extras = [RCTConvert NSDictionary:val]; }
405
+
406
+ [Repro trackAddPaymentInfo:properties];
407
+ }
408
+
409
+ - (void)trackPurchase:(NSString *)contentID value:(double)value currency:(NSString *)currency properties:(NSDictionary *)props
410
+ {
411
+ RPRPurchaseProperties *properties = [[RPRPurchaseProperties alloc] init];
412
+
413
+ NSObject *val = nil;
414
+ if ((val = props[@"content_category"])) { properties.contentCategory = [RCTConvert NSString:val]; }
415
+ if ((val = props[@"content_name"])) { properties.contentName = [RCTConvert NSString:val]; }
416
+ if ((val = props[@"num_items"])) { properties.numItems = [RCTConvert NSInteger:val]; }
417
+ if ((val = props[@"extras"])) { properties.extras = [RCTConvert NSDictionary:val]; }
418
+
419
+ [Repro trackPurchase:contentID value:value currency:currency properties:properties];
420
+ }
421
+
422
+ - (void)trackShare:(NSDictionary *)props
423
+ {
424
+ RPRShareProperties *properties = [[RPRShareProperties alloc] init];
425
+
426
+ NSObject *val = nil;
427
+ if ((val = props[@"service_name"])) { properties.serviceName = [RCTConvert NSString:val]; }
428
+ if ((val = props[@"content_category"])) { properties.contentCategory = [RCTConvert NSString:val]; }
429
+ if ((val = props[@"content_id"])) { properties.contentID = [RCTConvert NSString:val]; }
430
+ if ((val = props[@"content_name"])) { properties.contentName = [RCTConvert NSString:val]; }
431
+ if ((val = props[@"extras"])) { properties.extras = [RCTConvert NSDictionary:val]; }
432
+
433
+ [Repro trackShare:properties];
434
+ }
435
+
436
+ - (void)trackLead:(NSDictionary *)props
437
+ {
438
+ RPRLeadProperties *properties = [[RPRLeadProperties alloc] init];
439
+
440
+ NSObject *val = nil;
441
+ if ((val = props[@"value"])) { properties.value = [RCTConvert double:val]; }
442
+ if ((val = props[@"currency"])) { properties.currency = [RCTConvert NSString:val]; }
443
+ if ((val = props[@"content_category"])) { properties.contentCategory = [RCTConvert NSString:val]; }
444
+ if ((val = props[@"content_name"])) { properties.contentName = [RCTConvert NSString:val]; }
445
+ if ((val = props[@"extras"])) { properties.extras = [RCTConvert NSDictionary:val]; }
446
+
447
+ [Repro trackLead:properties];
448
+ }
449
+
450
+ - (void)trackCompleteRegistration:(NSDictionary *)props
451
+ {
452
+ RPRCompleteRegistrationProperties *properties = [[RPRCompleteRegistrationProperties alloc] init];
453
+
454
+ NSObject *val = nil;
455
+ if ((val = props[@"value"])) { properties.value = [RCTConvert double:val]; }
456
+ if ((val = props[@"currency"])) { properties.currency = [RCTConvert NSString:val]; }
457
+ if ((val = props[@"status"])) { properties.status = [RCTConvert NSString:val]; }
458
+ if ((val = props[@"content_name"])) { properties.contentName = [RCTConvert NSString:val]; }
459
+ if ((val = props[@"extras"])) { properties.extras = [RCTConvert NSDictionary:val]; }
460
+
461
+
462
+ [Repro trackCompleteRegistration:properties];
463
+ }
464
+
465
+ - (void)trackNotificationOpened:(NSString *)notificationId
466
+ {
467
+ // Only android method
468
+ }
469
+
470
+ // Other
471
+
472
+ - (void)setLogLevel:(RPRLogLevel)level
473
+ {
474
+ [Repro setLogLevel:level];
475
+ }
476
+
477
+ - (void)setPushDeviceTokenString:(NSString *)deviceTokenHexString
478
+ {
479
+ [Repro setPushDeviceTokenString:deviceTokenHexString];
480
+ }
481
+
482
+ - (void)setPushRegistrationID:(NSString *)pushRegId
483
+ {
484
+ // Only android method
485
+ }
486
+
487
+ - (void)setPushToken:(NSString *)token
488
+ {
489
+ [Repro setPushDeviceTokenString:token];
490
+ }
491
+
492
+ - (void)enablePushNotification
493
+ {
494
+ // Only android method
495
+ }
496
+
497
+ // NOTE: Should better be called native from AppDelegate::didFinishLaunchingWithOptions
498
+ - (void)setup:(NSString *)token
499
+ {
500
+ [Repro setup:token];
501
+ }
502
+
503
+ - (void)enableInAppMessagesOnForegroundTransition
504
+ {
505
+ [Repro enableInAppMessagesOnForegroundTransition];
506
+ }
507
+
508
+ // NOTE: Should better be called native from AppDelegate::didFinishLaunchingWithOptions if needed
509
+ - (void)disableInAppMessagesOnForegroundTransition
510
+ {
511
+ [Repro disableInAppMessagesOnForegroundTransition];
512
+ }
513
+
514
+ - (void)getNewsFeeds:(double)limit campaignType:(nonnull NSNumber *)type callback:(RCTResponseSenderBlock)callback
515
+ {
516
+ if (callback == nil) {
517
+ RCTLogWarn(@"[getNewsFeeds] callback is required. cannot return a value on success or failure.");
518
+ return;
519
+ }
520
+ NSError *error = nil;
521
+ RPRCampaignType campaignType = RPRCampaignTypeUnknown;
522
+
523
+ if (type) {
524
+ if ([type isEqualToNumber:@(RPRCampaignTypePushNotification)]) {
525
+ campaignType = RPRCampaignTypePushNotification;
526
+ } else if ([type isEqualToNumber:@(RPRCampaignTypeInAppMessage)]) {
527
+ campaignType = RPRCampaignTypeInAppMessage;
528
+ } else if ([type isEqualToNumber:@(RPRCampaignTypeWebMessage)]) {
529
+ campaignType = RPRCampaignTypeWebMessage;
530
+ } else if ([type isEqualToNumber:@(RPRCampaignTypeAll)]) {
531
+ campaignType = RPRCampaignTypeAll;
532
+ }
533
+ }
534
+
535
+ NSArray<RPRNewsFeedEntry *> * entries = [Repro getNewsFeeds:(uint64_t)limit campaignType:campaignType error:&error];
536
+
537
+ if (error) {
538
+ NSString *errString = [error localizedDescription];
539
+ callback(@[@{ @"message": errString }, [NSNull null]]);
540
+ return;
541
+ }
542
+
543
+ NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
544
+ formatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ssZZZ";
545
+ formatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
546
+ formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
547
+ formatter.calendar = [NSCalendar.alloc initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
548
+
549
+ NSMutableArray *entryJsons = [NSMutableArray.alloc initWithCapacity:entries.count];
550
+
551
+ for (RPRNewsFeedEntry *entry in entries) {
552
+
553
+ NSString *formattedDateString = [formatter stringFromDate:entry.deliveredAt];
554
+
555
+ NSDictionary *entryJson = @{
556
+ @"id": @(entry.ID),
557
+ @"deviceID": entry.deviceID,
558
+ @"title": entry.title,
559
+ @"summary": entry.summary,
560
+ @"body": entry.body,
561
+ @"campaignType": @(entry.campaignType),
562
+ @"deliveredAt": formattedDateString,
563
+ @"linkUrl": entry.linkUrl ? [entry.linkUrl absoluteString] : @"",
564
+ @"linkUrlString": entry.linkUrlString,
565
+ @"imageUrl": entry.imageUrl ? [entry.imageUrl absoluteString] : @"",
566
+ @"imageUrlString": entry.imageUrlString,
567
+ @"shown": @(entry.shown),
568
+ @"read": @(entry.read),
569
+ };
570
+
571
+ [entryJsons addObject:entryJson];
572
+ }
573
+
574
+ callback(@[[NSNull null], safe_value(entryJsons)]);
575
+ }
576
+
577
+ - (void)getNewsFeedsFor:(double)limit offsetID:(double)offsetID campaignType:(nonnull NSNumber *)type callback:(RCTResponseSenderBlock)callback
578
+ {
579
+ if (callback == nil) {
580
+ RCTLogWarn(@"[getNewsFeedsFor] callback is required. cannot return a value on success or failure.");
581
+ return;
582
+ }
583
+ NSError *error = nil;
584
+ RPRCampaignType campaignType = RPRCampaignTypeUnknown;
585
+
586
+ if (type) {
587
+ if ([type isEqualToNumber:@(RPRCampaignTypePushNotification)]) {
588
+ campaignType = RPRCampaignTypePushNotification;
589
+ } else if ([type isEqualToNumber:@(RPRCampaignTypeInAppMessage)]) {
590
+ campaignType = RPRCampaignTypeInAppMessage;
591
+ } else if ([type isEqualToNumber:@(RPRCampaignTypeWebMessage)]) {
592
+ campaignType = RPRCampaignTypeWebMessage;
593
+ } else if ([type isEqualToNumber:@(RPRCampaignTypeAll)]) {
594
+ campaignType = RPRCampaignTypeAll;
595
+ }
596
+ }
597
+
598
+ NSArray<RPRNewsFeedEntry *> *entries = [Repro getNewsFeeds:(uint64_t)limit offsetID:(uint64_t)offsetID campaignType:campaignType error:&error];
599
+
600
+ if (error) {
601
+ NSString *errString = [error localizedDescription];
602
+ callback(@[@{ @"message": errString }, [NSNull null]]);
603
+ return;
604
+ }
605
+
606
+ NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
607
+ formatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ssZZZ";
608
+ formatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
609
+ formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
610
+ formatter.calendar = [NSCalendar.alloc initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
611
+
612
+ NSMutableArray *entryJsons = [NSMutableArray.alloc initWithCapacity:entries.count];
613
+
614
+ for (RPRNewsFeedEntry *entry in entries) {
615
+
616
+ NSString *formattedDateString = [formatter stringFromDate:entry.deliveredAt];
617
+
618
+ NSDictionary *entryJson = @{
619
+ @"id": @(entry.ID),
620
+ @"deviceID": entry.deviceID,
621
+ @"title": entry.title,
622
+ @"summary": entry.summary,
623
+ @"body": entry.body,
624
+ @"campaignType": @(entry.campaignType),
625
+ @"deliveredAt": formattedDateString,
626
+ @"linkUrl": entry.linkUrl ? [entry.linkUrl absoluteString] : @"",
627
+ @"linkUrlString": entry.linkUrlString,
628
+ @"imageUrl": entry.imageUrl ? [entry.imageUrl absoluteString] : @"",
629
+ @"imageUrlString": entry.imageUrlString,
630
+ @"shown": @(entry.shown),
631
+ @"read": @(entry.read),
632
+ };
633
+
634
+ [entryJsons addObject:entryJson];
635
+ }
636
+
637
+ callback(@[[NSNull null], safe_value(entryJsons)]);
638
+ }
639
+
640
+ - (void)updateNewsFeeds:(NSArray<NSDictionary *> *)entryJsons callback:(RCTResponseSenderBlock)callback
641
+ {
642
+ if (callback == nil) {
643
+ RCTLogWarn(@"[updateNewsFeeds] callback is required. cannot return a value on success or failure.");
644
+ return;
645
+ }
646
+ NSMutableArray<RPRNewsFeedEntry *> *entries = [NSMutableArray.alloc initWithCapacity:entryJsons.count];
647
+
648
+ for (NSDictionary *entryJson in entryJsons) {
649
+ NSDictionary *entryDic = @{
650
+ @"newsfeed_id": [entryJson objectForKey:@"id"],
651
+ @"device_id": [entryJson objectForKey:@"deviceID"],
652
+ @"title": [entryJson objectForKey:@"title"],
653
+ @"summary": [entryJson objectForKey:@"summary"],
654
+ @"body": [entryJson objectForKey:@"body"],
655
+ @"campaign_type": [entryJson objectForKey:@"campaignType"],
656
+ @"delivered_at": [entryJson objectForKey:@"deliveredAt"],
657
+ @"linkUrl": [entryJson objectForKey:@"linkUrl"],
658
+ @"linkUrlString": [entryJson objectForKey:@"linkUrlString"],
659
+ @"imageUrl": [entryJson objectForKey:@"imageUrl"],
660
+ @"imageUrlString": [entryJson objectForKey:@"imageUrlString"],
661
+ @"shown": [entryJson objectForKey:@"shown"],
662
+ @"read": [entryJson objectForKey:@"read"],
663
+ };
664
+ RPRNewsFeedEntry *entry = [RPRNewsFeedEntry.alloc initWithDictionary: entryDic];
665
+ [entries addObject:entry];
666
+ }
667
+
668
+ NSError *error = nil;
669
+ [Repro updateNewsFeeds:entries error:&error];
670
+
671
+ if (error) {
672
+ NSString *errString = [error localizedDescription];
673
+ callback(@[@{ @"message": errString }]);
674
+ return;
675
+ }
676
+
677
+ callback(@[[NSNull null]]);
678
+ }
679
+
680
+ - (void)setSilverEggProdKey:(NSString *)silverEggProdKey
681
+ {
682
+ if (silverEggProdKey == nil) {
683
+ return;
684
+ }
685
+
686
+ [Repro setSilverEggProdKey:silverEggProdKey];
687
+ }
688
+
689
+ - (void)setSilverEggCookie:(NSString *)silverEggCookie
690
+ {
691
+ if (silverEggCookie == nil) {
692
+ return;
693
+ }
694
+
695
+ [Repro setSilverEggCookie:silverEggCookie];
696
+ }
697
+
698
+ - (void)linkLineID:(NSString *)lineUserId lineChannelID:(NSString *)lineChannelId
699
+ {
700
+ [Repro linkLineID:lineUserId lineChannelID:lineChannelId];
701
+ }
702
+
703
+ - (void)unlinkLineID:(NSString *)lineUserId lineChannelID:(NSString *)lineChannelId
704
+ {
705
+ [Repro unlinkLineID:lineUserId lineChannelID:lineChannelId];
706
+ }
707
+
708
+ - (void)_webviewJavaScriptOpenUrlHandler:(NSString *)webViewRequestUrl
709
+ {
710
+ [Repro _webviewJavaScriptOpenUrlHandler:webViewRequestUrl];
711
+ }
712
+
713
+ @end