clevertap-react-native 0.9.3 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +5 -0
- package/android/build.gradle +3 -3
- package/android/src/main/java/com/clevertap/react/CleverTapModule.java +40 -13
- package/clevertap-react-native.podspec +1 -1
- package/docs/install.md +3 -1
- package/docs/iospushtemplates.md +449 -0
- package/docs/usage.md +5 -0
- package/index.d.ts +17 -0
- package/index.js +18 -1
- package/ios/CleverTapReact/CleverTapReact.m +103 -69
- package/ios/CleverTapReact/CleverTapReactEventEmitter.h +0 -1
- package/ios/CleverTapReact/CleverTapReactEventEmitter.m +0 -2
- package/ios/CleverTapReact/CleverTapReactManager.h +3 -0
- package/ios/CleverTapReact/CleverTapReactManager.m +11 -10
- package/ios/CleverTapReact.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/CleverTapReact.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/CleverTapReact.xcodeproj/project.xcworkspace/xcuserdata/kushagra.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/CleverTapReact.xcodeproj/xcuserdata/kushagra.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/package.json +1 -1
- package/static/Finder.png +0 -0
- package/static/GenerateSpecs.png +0 -0
- package/static/NotificationContent.png +0 -0
- package/static/NotificationContentTarget.png +0 -0
- package/android/local.properties +0 -8
- package/ios/CleverTapReact/CleverTapSDK.framework.zip +0 -0
package/index.js
CHANGED
|
@@ -45,7 +45,7 @@ var CleverTap = {
|
|
|
45
45
|
CleverTapInboxDidInitialize: CleverTapReact.CleverTapInboxDidInitialize,
|
|
46
46
|
CleverTapInboxMessagesDidUpdate: CleverTapReact.CleverTapInboxMessagesDidUpdate,
|
|
47
47
|
CleverTapInboxMessageButtonTapped: CleverTapReact.CleverTapInboxMessageButtonTapped,
|
|
48
|
-
CleverTapInboxMessageTapped:CleverTapReact.CleverTapInboxMessageTapped,
|
|
48
|
+
CleverTapInboxMessageTapped: CleverTapReact.CleverTapInboxMessageTapped,
|
|
49
49
|
CleverTapDisplayUnitsLoaded: CleverTapReact.CleverTapDisplayUnitsLoaded,
|
|
50
50
|
CleverTapInAppNotificationButtonTapped: CleverTapReact.CleverTapInAppNotificationButtonTapped,
|
|
51
51
|
CleverTapFeatureFlagsDidUpdate: CleverTapReact.CleverTapFeatureFlagsDidUpdate,
|
|
@@ -525,6 +525,13 @@ var CleverTap = {
|
|
|
525
525
|
CleverTapReact.showInbox(styleConfig);
|
|
526
526
|
},
|
|
527
527
|
|
|
528
|
+
/**
|
|
529
|
+
* Method to dismiss the App Inbox
|
|
530
|
+
*/
|
|
531
|
+
dismissInbox: function () {
|
|
532
|
+
CleverTapReact.dismissInbox();
|
|
533
|
+
},
|
|
534
|
+
|
|
528
535
|
/**
|
|
529
536
|
* Get the total number of Inbox Messages
|
|
530
537
|
* @param {function(err, res)} callback that returns a res of count of inbox messages or -1
|
|
@@ -775,6 +782,16 @@ var CleverTap = {
|
|
|
775
782
|
*/
|
|
776
783
|
setDebugLevel: function (level) {
|
|
777
784
|
CleverTapReact.setDebugLevel(level);
|
|
785
|
+
},
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* Change the native instance of CleverTapAPI by using the instance for
|
|
789
|
+
* specific account. Used by Leanplum RN SDK.
|
|
790
|
+
*
|
|
791
|
+
* @param accountId The ID of the account to use when switching instance.
|
|
792
|
+
*/
|
|
793
|
+
setInstanceWithAccountId: function(accountId) {
|
|
794
|
+
CleverTapReact.setInstanceWithAccountId(accountId);
|
|
778
795
|
}
|
|
779
796
|
};
|
|
780
797
|
|
|
@@ -14,11 +14,18 @@
|
|
|
14
14
|
#import "CleverTap+FeatureFlags.h"
|
|
15
15
|
#import "CleverTap+ProductConfig.h"
|
|
16
16
|
#import "CleverTap+InAppNotifications.h"
|
|
17
|
+
#import "CleverTapInstanceConfig.h"
|
|
17
18
|
|
|
18
19
|
static NSDateFormatter *dateFormatter;
|
|
19
20
|
|
|
21
|
+
@interface CleverTapReact()
|
|
22
|
+
@property CleverTap *cleverTapInstance;
|
|
23
|
+
@end
|
|
24
|
+
|
|
20
25
|
@implementation CleverTapReact
|
|
21
26
|
|
|
27
|
+
@synthesize cleverTapInstance = _cleverTapInstance;
|
|
28
|
+
|
|
22
29
|
RCT_EXPORT_MODULE();
|
|
23
30
|
|
|
24
31
|
+ (BOOL)requiresMainQueueSetup {
|
|
@@ -52,6 +59,30 @@ RCT_EXPORT_MODULE();
|
|
|
52
59
|
|
|
53
60
|
# pragma mark - Launch
|
|
54
61
|
|
|
62
|
+
- (CleverTap *)cleverTapInstance {
|
|
63
|
+
if (_cleverTapInstance != nil) {
|
|
64
|
+
return _cleverTapInstance;
|
|
65
|
+
}
|
|
66
|
+
return [CleverTap sharedInstance];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
- (void)setCleverTapInstance:(CleverTap *)instance {
|
|
70
|
+
_cleverTapInstance = instance;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
RCT_EXPORT_METHOD(setInstanceWithAccountId:(NSString*)accountId) {
|
|
74
|
+
RCTLogInfo(@"[CleverTap setInstanceWithAccountId]");
|
|
75
|
+
|
|
76
|
+
CleverTap *instance = [CleverTap getGlobalInstance:accountId];
|
|
77
|
+
if (instance == nil) {
|
|
78
|
+
RCTLogWarn(@"CleverTapInstance not found for accountId: %@", accountId);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
[self setCleverTapInstance:instance];
|
|
83
|
+
[[CleverTapReactManager sharedInstance] setDelegates:instance];
|
|
84
|
+
}
|
|
85
|
+
|
|
55
86
|
RCT_EXPORT_METHOD(getInitialUrl:(RCTResponseSenderBlock)callback) {
|
|
56
87
|
RCTLogInfo(@"[CleverTap getInitialUrl]");
|
|
57
88
|
NSString *launchDeepLink = [CleverTapReactManager sharedInstance].launchDeepLink;
|
|
@@ -89,7 +120,7 @@ RCT_EXPORT_METHOD(registerForPush) {
|
|
|
89
120
|
RCT_EXPORT_METHOD(setPushTokenAsString:(NSString*)token withType:(NSString *)type) {
|
|
90
121
|
// type is a no-op in iOS
|
|
91
122
|
RCTLogInfo(@"[CleverTap setPushTokenAsString: %@]", token);
|
|
92
|
-
[[
|
|
123
|
+
[[self cleverTapInstance] setPushTokenAsString:token];
|
|
93
124
|
}
|
|
94
125
|
|
|
95
126
|
// setPushTokenAsStringWithRegion is a no-op in iOS
|
|
@@ -114,7 +145,7 @@ RCT_EXPORT_METHOD(disablePersonalization) {
|
|
|
114
145
|
|
|
115
146
|
RCT_EXPORT_METHOD(setOffline:(BOOL)enabled) {
|
|
116
147
|
RCTLogInfo(@"[CleverTap setOffline: %i]", enabled);
|
|
117
|
-
[[
|
|
148
|
+
[[self cleverTapInstance] setOffline:enabled];
|
|
118
149
|
}
|
|
119
150
|
|
|
120
151
|
|
|
@@ -122,12 +153,12 @@ RCT_EXPORT_METHOD(setOffline:(BOOL)enabled) {
|
|
|
122
153
|
|
|
123
154
|
RCT_EXPORT_METHOD(setOptOut:(BOOL)enabled) {
|
|
124
155
|
RCTLogInfo(@"[CleverTap setOptOut: %i]", enabled);
|
|
125
|
-
[[
|
|
156
|
+
[[self cleverTapInstance] setOptOut:enabled];
|
|
126
157
|
}
|
|
127
158
|
|
|
128
159
|
RCT_EXPORT_METHOD(enableDeviceNetworkInfoReporting:(BOOL)enabled) {
|
|
129
160
|
RCTLogInfo(@"[CleverTap enableDeviceNetworkInfoReporting: %i]", enabled);
|
|
130
|
-
[[
|
|
161
|
+
[[self cleverTapInstance] enableDeviceNetworkInfoReporting:enabled];
|
|
131
162
|
}
|
|
132
163
|
|
|
133
164
|
|
|
@@ -135,47 +166,47 @@ RCT_EXPORT_METHOD(enableDeviceNetworkInfoReporting:(BOOL)enabled) {
|
|
|
135
166
|
|
|
136
167
|
RCT_EXPORT_METHOD(recordScreenView:(NSString*)screenName) {
|
|
137
168
|
RCTLogInfo(@"[CleverTap recordScreenView]");
|
|
138
|
-
[[
|
|
169
|
+
[[self cleverTapInstance] recordScreenView:screenName];
|
|
139
170
|
}
|
|
140
171
|
|
|
141
172
|
RCT_EXPORT_METHOD(recordEvent:(NSString*)eventName withProps:(NSDictionary*)props) {
|
|
142
173
|
RCTLogInfo(@"[CleverTap recordEvent:withProps]");
|
|
143
|
-
[[
|
|
174
|
+
[[self cleverTapInstance] recordEvent:eventName withProps:props];
|
|
144
175
|
}
|
|
145
176
|
|
|
146
177
|
RCT_EXPORT_METHOD(recordChargedEvent:(NSDictionary*)details andItems:(NSArray*)items) {
|
|
147
178
|
RCTLogInfo(@"[CleverTap recordChargedEventWithDetails:andItems:]");
|
|
148
|
-
[[
|
|
179
|
+
[[self cleverTapInstance] recordChargedEventWithDetails:details andItems:items];
|
|
149
180
|
}
|
|
150
181
|
|
|
151
182
|
RCT_EXPORT_METHOD(eventGetFirstTime:(NSString*)eventName callback:(RCTResponseSenderBlock)callback) {
|
|
152
183
|
RCTLogInfo(@"[CleverTap eventGetFirstTime: %@]", eventName);
|
|
153
|
-
NSTimeInterval result = [[
|
|
184
|
+
NSTimeInterval result = [[self cleverTapInstance] eventGetFirstTime:eventName];
|
|
154
185
|
[self returnResult:@(result) withCallback:callback andError:nil];
|
|
155
186
|
}
|
|
156
187
|
|
|
157
188
|
RCT_EXPORT_METHOD(eventGetLastTime:(NSString*)eventName callback:(RCTResponseSenderBlock)callback) {
|
|
158
189
|
RCTLogInfo(@"[CleverTap eventGetLastTime: %@]", eventName);
|
|
159
|
-
NSTimeInterval result = [[
|
|
190
|
+
NSTimeInterval result = [[self cleverTapInstance] eventGetLastTime:eventName];
|
|
160
191
|
[self returnResult:@(result) withCallback:callback andError:nil];
|
|
161
192
|
}
|
|
162
193
|
|
|
163
194
|
RCT_EXPORT_METHOD(eventGetOccurrences:(NSString*)eventName callback:(RCTResponseSenderBlock)callback) {
|
|
164
195
|
RCTLogInfo(@"[CleverTap eventGetOccurrences: %@]", eventName);
|
|
165
|
-
int result = [[
|
|
196
|
+
int result = [[self cleverTapInstance] eventGetOccurrences:eventName];
|
|
166
197
|
[self returnResult:@(result) withCallback:callback andError:nil];
|
|
167
198
|
}
|
|
168
199
|
|
|
169
200
|
RCT_EXPORT_METHOD(eventGetDetail:(NSString*)eventName callback:(RCTResponseSenderBlock)callback) {
|
|
170
201
|
RCTLogInfo(@"[CleverTap eventGetDetail: %@]", eventName);
|
|
171
|
-
CleverTapEventDetail *detail = [[
|
|
202
|
+
CleverTapEventDetail *detail = [[self cleverTapInstance] eventGetDetail:eventName];
|
|
172
203
|
NSDictionary *result = [self _eventDetailToDict:detail];
|
|
173
204
|
[self returnResult:result withCallback:callback andError:nil];
|
|
174
205
|
}
|
|
175
206
|
|
|
176
207
|
RCT_EXPORT_METHOD(getEventHistory:(RCTResponseSenderBlock)callback) {
|
|
177
208
|
RCTLogInfo(@"[CleverTap getEventHistory]");
|
|
178
|
-
NSDictionary *history = [[
|
|
209
|
+
NSDictionary *history = [[self cleverTapInstance] userGetEventHistory];
|
|
179
210
|
NSMutableDictionary *result = [NSMutableDictionary new];
|
|
180
211
|
|
|
181
212
|
for (NSString *eventName in [history keyEnumerator]) {
|
|
@@ -197,114 +228,114 @@ RCT_EXPORT_METHOD(setLocation:(double)latitude longitude:(double)longitude) {
|
|
|
197
228
|
|
|
198
229
|
RCT_EXPORT_METHOD(profileGetCleverTapAttributionIdentifier:(RCTResponseSenderBlock)callback) {
|
|
199
230
|
RCTLogInfo(@"[CleverTap profileGetCleverTapAttributionIdentifier]");
|
|
200
|
-
NSString *result = [[
|
|
231
|
+
NSString *result = [[self cleverTapInstance] profileGetCleverTapAttributionIdentifier];
|
|
201
232
|
[self returnResult:result withCallback:callback andError:nil];
|
|
202
233
|
}
|
|
203
234
|
|
|
204
235
|
RCT_EXPORT_METHOD(profileGetCleverTapID:(RCTResponseSenderBlock)callback) {
|
|
205
236
|
RCTLogInfo(@"[CleverTap profileGetCleverTapID]");
|
|
206
|
-
NSString *result = [[
|
|
237
|
+
NSString *result = [[self cleverTapInstance] profileGetCleverTapID];
|
|
207
238
|
[self returnResult:result withCallback:callback andError:nil];
|
|
208
239
|
}
|
|
209
240
|
|
|
210
241
|
RCT_EXPORT_METHOD(getCleverTapID:(RCTResponseSenderBlock)callback) {
|
|
211
242
|
RCTLogInfo(@"[CleverTap getCleverTapID]");
|
|
212
|
-
NSString *result = [[
|
|
243
|
+
NSString *result = [[self cleverTapInstance] profileGetCleverTapID];
|
|
213
244
|
[self returnResult:result withCallback:callback andError:nil];
|
|
214
245
|
}
|
|
215
246
|
|
|
216
247
|
RCT_EXPORT_METHOD(onUserLogin:(NSDictionary*)profile) {
|
|
217
248
|
RCTLogInfo(@"[CleverTap onUserLogin: %@]", profile);
|
|
218
249
|
NSDictionary *_profile = [self formatProfile:profile];
|
|
219
|
-
[[
|
|
250
|
+
[[self cleverTapInstance] onUserLogin:_profile];
|
|
220
251
|
}
|
|
221
252
|
|
|
222
253
|
RCT_EXPORT_METHOD(profileSet:(NSDictionary*)profile) {
|
|
223
254
|
RCTLogInfo(@"[CleverTap profileSet: %@]", profile);
|
|
224
255
|
NSDictionary *_profile = [self formatProfile:profile];
|
|
225
|
-
[[
|
|
256
|
+
[[self cleverTapInstance] profilePush:_profile];
|
|
226
257
|
}
|
|
227
258
|
|
|
228
259
|
RCT_EXPORT_METHOD(profileGetProperty:(NSString*)propertyName callback:(RCTResponseSenderBlock)callback) {
|
|
229
260
|
RCTLogInfo(@"[CleverTap profileGetProperty: %@]", propertyName);
|
|
230
|
-
id result = [[
|
|
261
|
+
id result = [[self cleverTapInstance] profileGet:propertyName];
|
|
231
262
|
[self returnResult:result withCallback:callback andError:nil];
|
|
232
263
|
}
|
|
233
264
|
|
|
234
265
|
RCT_EXPORT_METHOD(profileRemoveValueForKey:(NSString*)key) {
|
|
235
266
|
RCTLogInfo(@"[CleverTap profileRemoveValueForKey: %@]", key);
|
|
236
|
-
[[
|
|
267
|
+
[[self cleverTapInstance] profileRemoveValueForKey:key];
|
|
237
268
|
}
|
|
238
269
|
|
|
239
270
|
RCT_EXPORT_METHOD(profileSetMultiValues:(NSArray<NSString*>*)values forKey:(NSString*)key) {
|
|
240
271
|
RCTLogInfo(@"[CleverTap profileSetMultiValues: %@ forKey: %@]", values, key);
|
|
241
|
-
[[
|
|
272
|
+
[[self cleverTapInstance] profileSetMultiValues:values forKey:key];
|
|
242
273
|
}
|
|
243
274
|
|
|
244
275
|
RCT_EXPORT_METHOD(profileAddMultiValue:(NSString*)value forKey:(NSString*)key) {
|
|
245
276
|
RCTLogInfo(@"[CleverTap profileAddMultiValue: %@ forKey: %@]", value, key);
|
|
246
|
-
[[
|
|
277
|
+
[[self cleverTapInstance] profileAddMultiValue:value forKey:key];
|
|
247
278
|
}
|
|
248
279
|
|
|
249
280
|
RCT_EXPORT_METHOD(profileAddMultiValues:(NSArray<NSString*>*)values forKey:(NSString*)key) {
|
|
250
281
|
RCTLogInfo(@"[CleverTap profileAddMultiValues: %@ forKey: %@]", values, key);
|
|
251
|
-
[[
|
|
282
|
+
[[self cleverTapInstance] profileAddMultiValues:values forKey:key];
|
|
252
283
|
}
|
|
253
284
|
|
|
254
285
|
RCT_EXPORT_METHOD(profileRemoveMultiValue:(NSString*)value forKey:(NSString*)key) {
|
|
255
286
|
RCTLogInfo(@"[CleverTap profileRemoveMultiValue: %@ forKey: %@]", value, key);
|
|
256
|
-
[[
|
|
287
|
+
[[self cleverTapInstance] profileRemoveMultiValue:value forKey:key];
|
|
257
288
|
}
|
|
258
289
|
|
|
259
290
|
RCT_EXPORT_METHOD(profileRemoveMultiValues:(NSArray<NSString*>*)values forKey:(NSString*)key) {
|
|
260
291
|
RCTLogInfo(@"[CleverTap profileRemoveMultiValues: %@ forKey: %@]", values, key);
|
|
261
|
-
[[
|
|
292
|
+
[[self cleverTapInstance] profileRemoveMultiValues:values forKey:key];
|
|
262
293
|
}
|
|
263
294
|
|
|
264
295
|
RCT_EXPORT_METHOD(profileIncrementValueForKey:(NSNumber* _Nonnull)value forKey:(NSString* _Nonnull)key) {
|
|
265
296
|
RCTLogInfo(@"[CleverTap profileIncrementValueBy: %@ forKey: %@]", value, key);
|
|
266
|
-
[[
|
|
297
|
+
[[self cleverTapInstance] profileIncrementValueBy:value forKey:key];
|
|
267
298
|
}
|
|
268
299
|
|
|
269
300
|
RCT_EXPORT_METHOD(profileDecrementValueForKey:(NSNumber* _Nonnull)value forKey:(NSString* _Nonnull)key) {
|
|
270
301
|
RCTLogInfo(@"[CleverTap profileDecrementValueBy: %@ forKey: %@]", value, key);
|
|
271
|
-
[[
|
|
302
|
+
[[self cleverTapInstance] profileDecrementValueBy:value forKey:key];
|
|
272
303
|
}
|
|
273
304
|
|
|
274
305
|
#pragma mark - Session API
|
|
275
306
|
|
|
276
307
|
RCT_EXPORT_METHOD(pushInstallReferrer:(NSString*)source medium:(NSString*)medium campaign:(NSString*)campaign) {
|
|
277
308
|
RCTLogInfo(@"[CleverTap pushInstallReferrer source: %@ medium: %@ campaign: %@]", source, medium, campaign);
|
|
278
|
-
[[
|
|
309
|
+
[[self cleverTapInstance] pushInstallReferrerSource:source medium:medium campaign:campaign];
|
|
279
310
|
}
|
|
280
311
|
|
|
281
312
|
RCT_EXPORT_METHOD(sessionGetTimeElapsed:(RCTResponseSenderBlock)callback) {
|
|
282
313
|
RCTLogInfo(@"[CleverTap sessionGetTimeElapsed]");
|
|
283
|
-
NSTimeInterval result = [[
|
|
314
|
+
NSTimeInterval result = [[self cleverTapInstance] sessionGetTimeElapsed];
|
|
284
315
|
[self returnResult:@(result) withCallback:callback andError:nil];
|
|
285
316
|
}
|
|
286
317
|
|
|
287
318
|
RCT_EXPORT_METHOD(sessionGetTotalVisits:(RCTResponseSenderBlock)callback) {
|
|
288
319
|
RCTLogInfo(@"[CleverTap sessionGetTotalVisits]");
|
|
289
|
-
int result = [[
|
|
320
|
+
int result = [[self cleverTapInstance] userGetTotalVisits];
|
|
290
321
|
[self returnResult:@(result) withCallback:callback andError:nil];
|
|
291
322
|
}
|
|
292
323
|
|
|
293
324
|
RCT_EXPORT_METHOD(sessionGetScreenCount:(RCTResponseSenderBlock)callback) {
|
|
294
325
|
RCTLogInfo(@"[CleverTap sessionGetScreenCount]");
|
|
295
|
-
int result = [[
|
|
326
|
+
int result = [[self cleverTapInstance] userGetScreenCount];
|
|
296
327
|
[self returnResult:@(result) withCallback:callback andError:nil];
|
|
297
328
|
}
|
|
298
329
|
|
|
299
330
|
RCT_EXPORT_METHOD(sessionGetPreviousVisitTime:(RCTResponseSenderBlock)callback) {
|
|
300
331
|
RCTLogInfo(@"[CleverTap sessionGetPreviousVisitTime]");
|
|
301
|
-
NSTimeInterval result = [[
|
|
332
|
+
NSTimeInterval result = [[self cleverTapInstance] userGetPreviousVisitTime];
|
|
302
333
|
[self returnResult:@(result) withCallback:callback andError:nil];
|
|
303
334
|
}
|
|
304
335
|
|
|
305
336
|
RCT_EXPORT_METHOD(sessionGetUTMDetails:(RCTResponseSenderBlock)callback) {
|
|
306
337
|
RCTLogInfo(@"[CleverTap sessionGetUTMDetails]");
|
|
307
|
-
CleverTapUTMDetail *detail = [[
|
|
338
|
+
CleverTapUTMDetail *detail = [[self cleverTapInstance] sessionGetUTMDetails];
|
|
308
339
|
NSDictionary *result = [self _utmDetailToDict:detail];
|
|
309
340
|
[self returnResult:result withCallback:callback andError:nil];
|
|
310
341
|
}
|
|
@@ -449,19 +480,19 @@ RCT_EXPORT_METHOD(setDebugLevel:(int)level) {
|
|
|
449
480
|
|
|
450
481
|
RCT_EXPORT_METHOD(getInboxMessageCount:(RCTResponseSenderBlock)callback) {
|
|
451
482
|
RCTLogInfo(@"[CleverTap inboxMessageCount]");
|
|
452
|
-
int result = (int)[[
|
|
483
|
+
int result = (int)[[self cleverTapInstance] getInboxMessageCount];
|
|
453
484
|
[self returnResult:@(result) withCallback:callback andError:nil];
|
|
454
485
|
}
|
|
455
486
|
|
|
456
487
|
RCT_EXPORT_METHOD(getInboxMessageUnreadCount:(RCTResponseSenderBlock)callback) {
|
|
457
488
|
RCTLogInfo(@"[CleverTap inboxMessageUnreadCount]");
|
|
458
|
-
int result = (int)[[
|
|
489
|
+
int result = (int)[[self cleverTapInstance] getInboxMessageUnreadCount];
|
|
459
490
|
[self returnResult:@(result) withCallback:callback andError:nil];
|
|
460
491
|
}
|
|
461
492
|
|
|
462
493
|
RCT_EXPORT_METHOD(getAllInboxMessages:(RCTResponseSenderBlock)callback) {
|
|
463
494
|
RCTLogInfo(@"[CleverTap getAllInboxMessages]");
|
|
464
|
-
NSArray<CleverTapInboxMessage *> *messageList = [[
|
|
495
|
+
NSArray<CleverTapInboxMessage *> *messageList = [[self cleverTapInstance] getAllInboxMessages];
|
|
465
496
|
NSMutableArray *allMessages = [NSMutableArray new];
|
|
466
497
|
for (CleverTapInboxMessage *message in messageList) {
|
|
467
498
|
[allMessages addObject:message.json];
|
|
@@ -472,7 +503,7 @@ RCT_EXPORT_METHOD(getAllInboxMessages:(RCTResponseSenderBlock)callback) {
|
|
|
472
503
|
|
|
473
504
|
RCT_EXPORT_METHOD(getUnreadInboxMessages:(RCTResponseSenderBlock)callback) {
|
|
474
505
|
RCTLogInfo(@"[CleverTap getUnreadInboxMessages]");
|
|
475
|
-
NSArray<CleverTapInboxMessage *> *messageList = [[
|
|
506
|
+
NSArray<CleverTapInboxMessage *> *messageList = [[self cleverTapInstance] getUnreadInboxMessages];
|
|
476
507
|
NSMutableArray *unreadMessages = [NSMutableArray new];
|
|
477
508
|
for (CleverTapInboxMessage *message in messageList) {
|
|
478
509
|
[unreadMessages addObject:message.json];
|
|
@@ -483,38 +514,43 @@ RCT_EXPORT_METHOD(getUnreadInboxMessages:(RCTResponseSenderBlock)callback) {
|
|
|
483
514
|
|
|
484
515
|
RCT_EXPORT_METHOD(getInboxMessageForId:(NSString*)messageId callback:(RCTResponseSenderBlock)callback) {
|
|
485
516
|
RCTLogInfo(@"[CleverTap getInboxMessageForId]");
|
|
486
|
-
CleverTapInboxMessage * message = [[
|
|
517
|
+
CleverTapInboxMessage * message = [[self cleverTapInstance] getInboxMessageForId:messageId];
|
|
487
518
|
NSDictionary *result = message.json;
|
|
488
519
|
[self returnResult:result withCallback:callback andError:nil];
|
|
489
520
|
}
|
|
490
521
|
|
|
491
522
|
RCT_EXPORT_METHOD(pushInboxNotificationViewedEventForId:(NSString*)messageId) {
|
|
492
523
|
RCTLogInfo(@"[CleverTap pushInboxNotificationViewedEventForId]");
|
|
493
|
-
[[
|
|
524
|
+
[[self cleverTapInstance] recordInboxNotificationViewedEventForID:messageId];
|
|
494
525
|
}
|
|
495
526
|
|
|
496
527
|
RCT_EXPORT_METHOD(pushInboxNotificationClickedEventForId:(NSString*)messageId) {
|
|
497
528
|
RCTLogInfo(@"[CleverTap pushInboxNotificationClickedEventForId]");
|
|
498
|
-
[[
|
|
529
|
+
[[self cleverTapInstance] recordInboxNotificationClickedEventForID:messageId];
|
|
499
530
|
}
|
|
500
531
|
|
|
501
532
|
RCT_EXPORT_METHOD(markReadInboxMessageForId:(NSString*)messageId) {
|
|
502
533
|
RCTLogInfo(@"[CleverTap markReadInboxMessageForId]");
|
|
503
|
-
[[
|
|
534
|
+
[[self cleverTapInstance] markReadInboxMessageForID:messageId];
|
|
504
535
|
}
|
|
505
536
|
|
|
506
537
|
RCT_EXPORT_METHOD(deleteInboxMessageForId:(NSString*)messageId) {
|
|
507
538
|
RCTLogInfo(@"[CleverTap deleteInboxMessageForId]");
|
|
508
|
-
[[
|
|
539
|
+
[[self cleverTapInstance] deleteInboxMessageForID:messageId];
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
RCT_EXPORT_METHOD(dismissInbox) {
|
|
543
|
+
RCTLogInfo(@"[CleverTap dismissAppInbox]");
|
|
544
|
+
[[self cleverTapInstance] dismissAppInbox];
|
|
509
545
|
}
|
|
510
546
|
|
|
511
547
|
RCT_EXPORT_METHOD(initializeInbox) {
|
|
512
548
|
RCTLogInfo(@"[CleverTap Inbox Initialize]");
|
|
513
|
-
[[
|
|
549
|
+
[[self cleverTapInstance] initializeInboxWithCallback:^(BOOL success) {
|
|
514
550
|
if (success) {
|
|
515
551
|
RCTLogInfo(@"[Inbox initialized]");
|
|
516
552
|
[[NSNotificationCenter defaultCenter] postNotificationName:kCleverTapInboxDidInitialize object:nil userInfo:nil];
|
|
517
|
-
[[
|
|
553
|
+
[[self cleverTapInstance] registerInboxUpdatedBlock:^{
|
|
518
554
|
RCTLogInfo(@"[Inbox updated]");
|
|
519
555
|
[[NSNotificationCenter defaultCenter] postNotificationName:kCleverTapInboxMessagesDidUpdate object:nil userInfo:nil];
|
|
520
556
|
}];
|
|
@@ -524,7 +560,7 @@ RCT_EXPORT_METHOD(initializeInbox) {
|
|
|
524
560
|
|
|
525
561
|
RCT_EXPORT_METHOD(showInbox:(NSDictionary*)styleConfig) {
|
|
526
562
|
RCTLogInfo(@"[CleverTap Show Inbox]");
|
|
527
|
-
CleverTapInboxViewController *inboxController = [[
|
|
563
|
+
CleverTapInboxViewController *inboxController = [[self cleverTapInstance] newInboxViewControllerWithConfig:[self _dictToInboxStyleConfig:styleConfig? styleConfig : nil] andDelegate:(id <CleverTapInboxViewControllerDelegate>)self];
|
|
528
564
|
if (inboxController) {
|
|
529
565
|
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:inboxController];
|
|
530
566
|
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
|
|
@@ -609,13 +645,11 @@ RCT_EXPORT_METHOD(showInbox:(NSDictionary*)styleConfig) {
|
|
|
609
645
|
- (void)messageDidSelect:(CleverTapInboxMessage *_Nonnull)message atIndex:(int)index withButtonIndex:(int)buttonIndex {
|
|
610
646
|
NSMutableDictionary *body = [NSMutableDictionary new];
|
|
611
647
|
if ([message json] != nil) {
|
|
612
|
-
|
|
613
|
-
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:[message json]
|
|
614
|
-
options:0
|
|
615
|
-
error:&error];
|
|
616
|
-
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
617
|
-
body[@"data"] = jsonString;
|
|
648
|
+
body[@"data"] = [NSMutableDictionary dictionaryWithDictionary:[message json]];
|
|
618
649
|
}
|
|
650
|
+
body[@"itemIndex"] = @(index);
|
|
651
|
+
body[@"buttonIndex"] = @(buttonIndex);
|
|
652
|
+
|
|
619
653
|
[[NSNotificationCenter defaultCenter] postNotificationName:kCleverTapInboxMessageTapped object:nil userInfo:body];
|
|
620
654
|
}
|
|
621
655
|
|
|
@@ -624,7 +658,7 @@ RCT_EXPORT_METHOD(showInbox:(NSDictionary*)styleConfig) {
|
|
|
624
658
|
|
|
625
659
|
RCT_EXPORT_METHOD(getAllDisplayUnits:(RCTResponseSenderBlock)callback) {
|
|
626
660
|
RCTLogInfo(@"[CleverTap getAllDisplayUnits]");
|
|
627
|
-
NSArray <CleverTapDisplayUnit*> *units = [[
|
|
661
|
+
NSArray <CleverTapDisplayUnit*> *units = [[self cleverTapInstance] getAllDisplayUnits];
|
|
628
662
|
NSMutableArray *displayUnits = [NSMutableArray new];
|
|
629
663
|
for (CleverTapDisplayUnit *unit in units) {
|
|
630
664
|
[displayUnits addObject:unit.json];
|
|
@@ -635,19 +669,19 @@ RCT_EXPORT_METHOD(getAllDisplayUnits:(RCTResponseSenderBlock)callback) {
|
|
|
635
669
|
|
|
636
670
|
RCT_EXPORT_METHOD(getDisplayUnitForId:(NSString*)unitId callback:(RCTResponseSenderBlock)callback) {
|
|
637
671
|
RCTLogInfo(@"[CleverTap getDisplayUnitForId]");
|
|
638
|
-
CleverTapDisplayUnit * displayUnit = [[
|
|
672
|
+
CleverTapDisplayUnit * displayUnit = [[self cleverTapInstance] getDisplayUnitForID:unitId];
|
|
639
673
|
NSDictionary *result = displayUnit.json;
|
|
640
674
|
[self returnResult:result withCallback:callback andError:nil];
|
|
641
675
|
}
|
|
642
676
|
|
|
643
677
|
RCT_EXPORT_METHOD(pushDisplayUnitViewedEventForID:(NSString*)unitId) {
|
|
644
678
|
RCTLogInfo(@"[CleverTap pushDisplayUnitViewedEventForID]");
|
|
645
|
-
[[
|
|
679
|
+
[[self cleverTapInstance] recordDisplayUnitViewedEventForID:unitId];
|
|
646
680
|
}
|
|
647
681
|
|
|
648
682
|
RCT_EXPORT_METHOD(pushDisplayUnitClickedEventForID:(NSString*)unitId) {
|
|
649
683
|
RCTLogInfo(@"[CleverTap pushDisplayUnitClickedEventForID]");
|
|
650
|
-
[[
|
|
684
|
+
[[self cleverTapInstance] recordDisplayUnitClickedEventForID:unitId];
|
|
651
685
|
}
|
|
652
686
|
|
|
653
687
|
|
|
@@ -655,7 +689,7 @@ RCT_EXPORT_METHOD(pushDisplayUnitClickedEventForID:(NSString*)unitId) {
|
|
|
655
689
|
|
|
656
690
|
RCT_EXPORT_METHOD(getFeatureFlag:(NSString*)flag withdefaultValue:(BOOL)defaultValue callback:(RCTResponseSenderBlock)callback) {
|
|
657
691
|
RCTLogInfo(@"[CleverTap getFeatureFlag]");
|
|
658
|
-
BOOL result = [[[
|
|
692
|
+
BOOL result = [[[self cleverTapInstance] featureFlags] get:flag withDefaultValue:defaultValue];
|
|
659
693
|
[self returnResult:@(result) withCallback:callback andError:nil];
|
|
660
694
|
}
|
|
661
695
|
|
|
@@ -664,78 +698,78 @@ RCT_EXPORT_METHOD(getFeatureFlag:(NSString*)flag withdefaultValue:(BOOL)defaultV
|
|
|
664
698
|
|
|
665
699
|
RCT_EXPORT_METHOD(setDefaultsMap:(NSDictionary*)jsonDict) {
|
|
666
700
|
RCTLogInfo(@"[CleverTap setDefaultsMap]");
|
|
667
|
-
[[[
|
|
701
|
+
[[[self cleverTapInstance] productConfig] setDefaults:jsonDict];
|
|
668
702
|
}
|
|
669
703
|
|
|
670
704
|
RCT_EXPORT_METHOD(fetch) {
|
|
671
705
|
RCTLogInfo(@"[CleverTap ProductConfig Fetch]");
|
|
672
|
-
[[[
|
|
706
|
+
[[[self cleverTapInstance] productConfig] fetch];
|
|
673
707
|
}
|
|
674
708
|
|
|
675
709
|
RCT_EXPORT_METHOD(fetchWithMinimumFetchIntervalInSeconds:(double)time) {
|
|
676
710
|
RCTLogInfo(@"[CleverTap ProductConfig Fetch with minimum Interval]");
|
|
677
|
-
[[[
|
|
711
|
+
[[[self cleverTapInstance] productConfig] fetchWithMinimumInterval: time];
|
|
678
712
|
}
|
|
679
713
|
|
|
680
714
|
RCT_EXPORT_METHOD(activate) {
|
|
681
715
|
RCTLogInfo(@"[CleverTap ProductConfig Activate]");
|
|
682
|
-
[[[
|
|
716
|
+
[[[self cleverTapInstance] productConfig] activate];
|
|
683
717
|
}
|
|
684
718
|
|
|
685
719
|
RCT_EXPORT_METHOD(fetchAndActivate) {
|
|
686
720
|
RCTLogInfo(@"[CleverTap ProductConfig Fetch and Activate]");
|
|
687
|
-
[[[
|
|
721
|
+
[[[self cleverTapInstance] productConfig] fetchAndActivate];
|
|
688
722
|
}
|
|
689
723
|
|
|
690
724
|
RCT_EXPORT_METHOD(setMinimumFetchIntervalInSeconds:(double)time) {
|
|
691
725
|
RCTLogInfo(@"[CleverTap ProductConfig Minimum Time Interval Setup]");
|
|
692
|
-
[[[
|
|
726
|
+
[[[self cleverTapInstance] productConfig] setMinimumFetchInterval: time];
|
|
693
727
|
}
|
|
694
728
|
|
|
695
729
|
RCT_EXPORT_METHOD(getLastFetchTimeStampInMillis:(RCTResponseSenderBlock)callback) {
|
|
696
730
|
RCTLogInfo(@"[CleverTap Last Fetch Config time]");
|
|
697
|
-
NSTimeInterval result = [[[[
|
|
731
|
+
NSTimeInterval result = [[[[self cleverTapInstance] productConfig] getLastFetchTimeStamp] timeIntervalSince1970] * 1000;
|
|
698
732
|
[self returnResult: @(result) withCallback: callback andError:nil];
|
|
699
733
|
}
|
|
700
734
|
|
|
701
735
|
RCT_EXPORT_METHOD(getString:(NSString*)key callback:(RCTResponseSenderBlock)callback) {
|
|
702
736
|
RCTLogInfo(@"[CleverTap fetch String value for Key]");
|
|
703
|
-
NSString *result = [[[
|
|
737
|
+
NSString *result = [[[self cleverTapInstance] productConfig] get:key].stringValue;
|
|
704
738
|
[self returnResult: result withCallback: callback andError:nil];
|
|
705
739
|
}
|
|
706
740
|
|
|
707
741
|
RCT_EXPORT_METHOD(getBoolean:(NSString*)key callback:(RCTResponseSenderBlock)callback) {
|
|
708
742
|
RCTLogInfo(@"[CleverTap fetch Bool value for Key]");
|
|
709
|
-
BOOL result = [[[
|
|
743
|
+
BOOL result = [[[self cleverTapInstance] productConfig] get:key].boolValue;
|
|
710
744
|
[self returnResult: @(result) withCallback: callback andError:nil];
|
|
711
745
|
}
|
|
712
746
|
|
|
713
747
|
RCT_EXPORT_METHOD(getDouble:(NSString*)key callback:(RCTResponseSenderBlock)callback) {
|
|
714
748
|
RCTLogInfo(@"[CleverTap fetch Double value for Key]");
|
|
715
|
-
long result = [[[
|
|
749
|
+
long result = [[[self cleverTapInstance] productConfig] get:key].numberValue.doubleValue;
|
|
716
750
|
[self returnResult: @(result) withCallback: callback andError:nil];
|
|
717
751
|
}
|
|
718
752
|
|
|
719
753
|
RCT_EXPORT_METHOD(reset) {
|
|
720
754
|
RCTLogInfo(@"[CleverTap ProductConfig Reset]");
|
|
721
|
-
[[[
|
|
755
|
+
[[[self cleverTapInstance] productConfig] reset];
|
|
722
756
|
}
|
|
723
757
|
|
|
724
758
|
#pragma mark - InApp Notification Controls
|
|
725
759
|
|
|
726
760
|
RCT_EXPORT_METHOD(suspendInAppNotifications) {
|
|
727
761
|
RCTLogInfo(@"[CleverTap suspendInAppNotifications");
|
|
728
|
-
[[
|
|
762
|
+
[[self cleverTapInstance] suspendInAppNotifications];
|
|
729
763
|
}
|
|
730
764
|
|
|
731
765
|
RCT_EXPORT_METHOD(discardInAppNotifications) {
|
|
732
766
|
RCTLogInfo(@"[CleverTap discardInAppNotifications");
|
|
733
|
-
[[
|
|
767
|
+
[[self cleverTapInstance] discardInAppNotifications];
|
|
734
768
|
}
|
|
735
769
|
|
|
736
770
|
RCT_EXPORT_METHOD(resumeInAppNotifications) {
|
|
737
771
|
RCTLogInfo(@"[CleverTap resumeInAppNotifications");
|
|
738
|
-
[[
|
|
772
|
+
[[self cleverTapInstance] resumeInAppNotifications];
|
|
739
773
|
}
|
|
740
774
|
|
|
741
775
|
@end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#import <Foundation/Foundation.h>
|
|
2
|
+
#import "CleverTap.h"
|
|
2
3
|
|
|
3
4
|
@interface CleverTapReactManager : NSObject
|
|
4
5
|
|
|
@@ -6,6 +7,8 @@
|
|
|
6
7
|
|
|
7
8
|
- (void)applicationDidLaunchWithOptions:(NSDictionary *)options;
|
|
8
9
|
|
|
10
|
+
- (void)setDelegates:(CleverTap *)cleverTapInstance;
|
|
11
|
+
|
|
9
12
|
@property NSString *launchDeepLink;
|
|
10
13
|
|
|
11
14
|
@end
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
1
|
#import "CleverTapReactManager.h"
|
|
3
2
|
#import "CleverTapReact.h"
|
|
4
3
|
|
|
5
4
|
#import <UIKit/UIKit.h>
|
|
6
5
|
#import <React/RCTLog.h>
|
|
7
6
|
|
|
8
|
-
#import "CleverTap.h"
|
|
9
7
|
#import "CleverTap+Inbox.h"
|
|
10
8
|
#import "CleverTapUTMDetail.h"
|
|
11
9
|
#import "CleverTapEventDetail.h"
|
|
@@ -36,17 +34,21 @@
|
|
|
36
34
|
self = [super init];
|
|
37
35
|
if (self) {
|
|
38
36
|
CleverTap *clevertap = [CleverTap sharedInstance];
|
|
39
|
-
[
|
|
40
|
-
[clevertap setInAppNotificationDelegate:self];
|
|
41
|
-
[clevertap setDisplayUnitDelegate:self];
|
|
42
|
-
[clevertap setPushNotificationDelegate:self];
|
|
43
|
-
[[clevertap featureFlags] setDelegate:self];
|
|
44
|
-
[[clevertap productConfig] setDelegate:self];
|
|
45
|
-
[clevertap setLibrary:@"React-Native"];
|
|
37
|
+
[self setDelegates:clevertap];
|
|
46
38
|
}
|
|
47
39
|
return self;
|
|
48
40
|
}
|
|
49
41
|
|
|
42
|
+
- (void)setDelegates:(CleverTap *)cleverTapInstance {
|
|
43
|
+
[cleverTapInstance setSyncDelegate:self];
|
|
44
|
+
[cleverTapInstance setInAppNotificationDelegate:self];
|
|
45
|
+
[cleverTapInstance setDisplayUnitDelegate:self];
|
|
46
|
+
[cleverTapInstance setPushNotificationDelegate:self];
|
|
47
|
+
[[cleverTapInstance featureFlags] setDelegate:self];
|
|
48
|
+
[[cleverTapInstance productConfig] setDelegate:self];
|
|
49
|
+
[cleverTapInstance setLibrary:@"React-Native"];
|
|
50
|
+
}
|
|
51
|
+
|
|
50
52
|
- (void)applicationDidLaunchWithOptions:(NSDictionary *)options {
|
|
51
53
|
NSDictionary *notification = [options valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
|
|
52
54
|
if (notification && notification[@"wzrk_dl"]) {
|
|
@@ -55,7 +57,6 @@
|
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
|
|
59
60
|
#pragma mark - Private
|
|
60
61
|
|
|
61
62
|
- (void)postNotificationWithName:(NSString *)name andBody:(NSDictionary *)body {
|