clevertap-react-native 0.9.3 → 1.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.
- package/CHANGELOG.md +15 -0
- package/README.md +5 -0
- package/android/.gradle/6.1.1/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/6.1.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/6.1.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/6.1.1/fileContent/fileContent.lock +0 -0
- package/android/.gradle/6.1.1/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/6.1.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/6.1.1/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/6.1.1/gc.properties +0 -0
- package/android/.gradle/6.1.1/javaCompile/classAnalysis.bin +0 -0
- package/android/.gradle/6.1.1/javaCompile/jarAnalysis.bin +0 -0
- package/android/.gradle/6.1.1/javaCompile/javaCompile.lock +0 -0
- package/android/.gradle/6.1.1/javaCompile/taskHistory.bin +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build/generated/source/buildConfig/debug/com/clevertap/react/BuildConfig.java +12 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +14 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output.json +27 -0
- package/android/build/intermediates/aar_main_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +1 -0
- package/android/build/intermediates/annotations_typedef_file/debug/typedefs.txt +0 -0
- package/android/build/intermediates/compile_only_not_namespaced_r_class_jar/debug/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/R.txt +5732 -0
- package/android/build/intermediates/incremental/debug-mergeJavaRes/merge-state +0 -0
- package/android/build/intermediates/incremental/debug-mergeNativeLibs/merge-state +0 -0
- package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +2 -0
- package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +2 -0
- package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +2 -0
- package/android/build/intermediates/incremental/packageDebugResources/compile-file-map.properties +1 -0
- package/android/build/intermediates/incremental/packageDebugResources/merger.xml +2 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/BuildConfig.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapApplication$1$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapApplication$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapApplication.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModule$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModule$2.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModule$ErrorMessages.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModule$InBoxMessages.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModule.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapPackage.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapUtils.class +0 -0
- package/android/build/intermediates/library_manifest/debug/AndroidManifest.xml +14 -0
- package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +2 -0
- package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +17 -0
- package/android/build/intermediates/merged_java_res/debug/out.jar +0 -0
- package/android/build/intermediates/merged_manifests/debug/output.json +27 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +3965 -0
- package/android/build/outputs/aar/android-debug.aar +0 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +39 -0
- package/android/build.gradle +7 -7
- package/android/local.properties +2 -2
- package/android/src/main/java/com/clevertap/react/CleverTapModule.java +240 -12
- package/clevertap-react-native.podspec +1 -1
- package/docs/iospushtemplates.md +449 -0
- package/docs/pushprimer.md +97 -0
- package/docs/usage.md +4 -0
- package/index.d.ts +51 -4
- package/index.js +41 -4
- package/ios/CleverTapReact/CleverTapReact.h +2 -0
- package/ios/CleverTapReact/CleverTapReact.m +204 -63
- package/ios/CleverTapReact/CleverTapReactEventEmitter.h +0 -1
- package/ios/CleverTapReact/CleverTapReactEventEmitter.m +6 -3
- package/ios/CleverTapReact/CleverTapReactManager.h +3 -0
- package/ios/CleverTapReact/CleverTapReactManager.m +23 -11
- 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
|
@@ -14,11 +14,20 @@
|
|
|
14
14
|
#import "CleverTap+FeatureFlags.h"
|
|
15
15
|
#import "CleverTap+ProductConfig.h"
|
|
16
16
|
#import "CleverTap+InAppNotifications.h"
|
|
17
|
+
#import "CleverTapInstanceConfig.h"
|
|
18
|
+
#import "CTLocalInApp.h"
|
|
19
|
+
#import "Clevertap+PushPermission.h"
|
|
17
20
|
|
|
18
21
|
static NSDateFormatter *dateFormatter;
|
|
19
22
|
|
|
23
|
+
@interface CleverTapReact()
|
|
24
|
+
@property CleverTap *cleverTapInstance;
|
|
25
|
+
@end
|
|
26
|
+
|
|
20
27
|
@implementation CleverTapReact
|
|
21
28
|
|
|
29
|
+
@synthesize cleverTapInstance = _cleverTapInstance;
|
|
30
|
+
|
|
22
31
|
RCT_EXPORT_MODULE();
|
|
23
32
|
|
|
24
33
|
+ (BOOL)requiresMainQueueSetup {
|
|
@@ -41,6 +50,8 @@ RCT_EXPORT_MODULE();
|
|
|
41
50
|
kCleverTapProductConfigDidActivate: kCleverTapProductConfigDidActivate,
|
|
42
51
|
kCleverTapProductConfigDidInitialize: kCleverTapProductConfigDidInitialize,
|
|
43
52
|
kCleverTapPushNotificationClicked: kCleverTapPushNotificationClicked,
|
|
53
|
+
kCleverTapPushPermissionResponseReceived: kCleverTapPushPermissionResponseReceived,
|
|
54
|
+
kCleverTapInAppNotificationShowed: kCleverTapInAppNotificationShowed,
|
|
44
55
|
kXPS: kXPS
|
|
45
56
|
};
|
|
46
57
|
}
|
|
@@ -52,6 +63,30 @@ RCT_EXPORT_MODULE();
|
|
|
52
63
|
|
|
53
64
|
# pragma mark - Launch
|
|
54
65
|
|
|
66
|
+
- (CleverTap *)cleverTapInstance {
|
|
67
|
+
if (_cleverTapInstance != nil) {
|
|
68
|
+
return _cleverTapInstance;
|
|
69
|
+
}
|
|
70
|
+
return [CleverTap sharedInstance];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
- (void)setCleverTapInstance:(CleverTap *)instance {
|
|
74
|
+
_cleverTapInstance = instance;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
RCT_EXPORT_METHOD(setInstanceWithAccountId:(NSString*)accountId) {
|
|
78
|
+
RCTLogInfo(@"[CleverTap setInstanceWithAccountId]");
|
|
79
|
+
|
|
80
|
+
CleverTap *instance = [CleverTap getGlobalInstance:accountId];
|
|
81
|
+
if (instance == nil) {
|
|
82
|
+
RCTLogWarn(@"CleverTapInstance not found for accountId: %@", accountId);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
[self setCleverTapInstance:instance];
|
|
87
|
+
[[CleverTapReactManager sharedInstance] setDelegates:instance];
|
|
88
|
+
}
|
|
89
|
+
|
|
55
90
|
RCT_EXPORT_METHOD(getInitialUrl:(RCTResponseSenderBlock)callback) {
|
|
56
91
|
RCTLogInfo(@"[CleverTap getInitialUrl]");
|
|
57
92
|
NSString *launchDeepLink = [CleverTapReactManager sharedInstance].launchDeepLink;
|
|
@@ -89,7 +124,7 @@ RCT_EXPORT_METHOD(registerForPush) {
|
|
|
89
124
|
RCT_EXPORT_METHOD(setPushTokenAsString:(NSString*)token withType:(NSString *)type) {
|
|
90
125
|
// type is a no-op in iOS
|
|
91
126
|
RCTLogInfo(@"[CleverTap setPushTokenAsString: %@]", token);
|
|
92
|
-
[[
|
|
127
|
+
[[self cleverTapInstance] setPushTokenAsString:token];
|
|
93
128
|
}
|
|
94
129
|
|
|
95
130
|
// setPushTokenAsStringWithRegion is a no-op in iOS
|
|
@@ -114,7 +149,7 @@ RCT_EXPORT_METHOD(disablePersonalization) {
|
|
|
114
149
|
|
|
115
150
|
RCT_EXPORT_METHOD(setOffline:(BOOL)enabled) {
|
|
116
151
|
RCTLogInfo(@"[CleverTap setOffline: %i]", enabled);
|
|
117
|
-
[[
|
|
152
|
+
[[self cleverTapInstance] setOffline:enabled];
|
|
118
153
|
}
|
|
119
154
|
|
|
120
155
|
|
|
@@ -122,12 +157,12 @@ RCT_EXPORT_METHOD(setOffline:(BOOL)enabled) {
|
|
|
122
157
|
|
|
123
158
|
RCT_EXPORT_METHOD(setOptOut:(BOOL)enabled) {
|
|
124
159
|
RCTLogInfo(@"[CleverTap setOptOut: %i]", enabled);
|
|
125
|
-
[[
|
|
160
|
+
[[self cleverTapInstance] setOptOut:enabled];
|
|
126
161
|
}
|
|
127
162
|
|
|
128
163
|
RCT_EXPORT_METHOD(enableDeviceNetworkInfoReporting:(BOOL)enabled) {
|
|
129
164
|
RCTLogInfo(@"[CleverTap enableDeviceNetworkInfoReporting: %i]", enabled);
|
|
130
|
-
[[
|
|
165
|
+
[[self cleverTapInstance] enableDeviceNetworkInfoReporting:enabled];
|
|
131
166
|
}
|
|
132
167
|
|
|
133
168
|
|
|
@@ -135,47 +170,47 @@ RCT_EXPORT_METHOD(enableDeviceNetworkInfoReporting:(BOOL)enabled) {
|
|
|
135
170
|
|
|
136
171
|
RCT_EXPORT_METHOD(recordScreenView:(NSString*)screenName) {
|
|
137
172
|
RCTLogInfo(@"[CleverTap recordScreenView]");
|
|
138
|
-
[[
|
|
173
|
+
[[self cleverTapInstance] recordScreenView:screenName];
|
|
139
174
|
}
|
|
140
175
|
|
|
141
176
|
RCT_EXPORT_METHOD(recordEvent:(NSString*)eventName withProps:(NSDictionary*)props) {
|
|
142
177
|
RCTLogInfo(@"[CleverTap recordEvent:withProps]");
|
|
143
|
-
[[
|
|
178
|
+
[[self cleverTapInstance] recordEvent:eventName withProps:props];
|
|
144
179
|
}
|
|
145
180
|
|
|
146
181
|
RCT_EXPORT_METHOD(recordChargedEvent:(NSDictionary*)details andItems:(NSArray*)items) {
|
|
147
182
|
RCTLogInfo(@"[CleverTap recordChargedEventWithDetails:andItems:]");
|
|
148
|
-
[[
|
|
183
|
+
[[self cleverTapInstance] recordChargedEventWithDetails:details andItems:items];
|
|
149
184
|
}
|
|
150
185
|
|
|
151
186
|
RCT_EXPORT_METHOD(eventGetFirstTime:(NSString*)eventName callback:(RCTResponseSenderBlock)callback) {
|
|
152
187
|
RCTLogInfo(@"[CleverTap eventGetFirstTime: %@]", eventName);
|
|
153
|
-
NSTimeInterval result = [[
|
|
188
|
+
NSTimeInterval result = [[self cleverTapInstance] eventGetFirstTime:eventName];
|
|
154
189
|
[self returnResult:@(result) withCallback:callback andError:nil];
|
|
155
190
|
}
|
|
156
191
|
|
|
157
192
|
RCT_EXPORT_METHOD(eventGetLastTime:(NSString*)eventName callback:(RCTResponseSenderBlock)callback) {
|
|
158
193
|
RCTLogInfo(@"[CleverTap eventGetLastTime: %@]", eventName);
|
|
159
|
-
NSTimeInterval result = [[
|
|
194
|
+
NSTimeInterval result = [[self cleverTapInstance] eventGetLastTime:eventName];
|
|
160
195
|
[self returnResult:@(result) withCallback:callback andError:nil];
|
|
161
196
|
}
|
|
162
197
|
|
|
163
198
|
RCT_EXPORT_METHOD(eventGetOccurrences:(NSString*)eventName callback:(RCTResponseSenderBlock)callback) {
|
|
164
199
|
RCTLogInfo(@"[CleverTap eventGetOccurrences: %@]", eventName);
|
|
165
|
-
int result = [[
|
|
200
|
+
int result = [[self cleverTapInstance] eventGetOccurrences:eventName];
|
|
166
201
|
[self returnResult:@(result) withCallback:callback andError:nil];
|
|
167
202
|
}
|
|
168
203
|
|
|
169
204
|
RCT_EXPORT_METHOD(eventGetDetail:(NSString*)eventName callback:(RCTResponseSenderBlock)callback) {
|
|
170
205
|
RCTLogInfo(@"[CleverTap eventGetDetail: %@]", eventName);
|
|
171
|
-
CleverTapEventDetail *detail = [[
|
|
206
|
+
CleverTapEventDetail *detail = [[self cleverTapInstance] eventGetDetail:eventName];
|
|
172
207
|
NSDictionary *result = [self _eventDetailToDict:detail];
|
|
173
208
|
[self returnResult:result withCallback:callback andError:nil];
|
|
174
209
|
}
|
|
175
210
|
|
|
176
211
|
RCT_EXPORT_METHOD(getEventHistory:(RCTResponseSenderBlock)callback) {
|
|
177
212
|
RCTLogInfo(@"[CleverTap getEventHistory]");
|
|
178
|
-
NSDictionary *history = [[
|
|
213
|
+
NSDictionary *history = [[self cleverTapInstance] userGetEventHistory];
|
|
179
214
|
NSMutableDictionary *result = [NSMutableDictionary new];
|
|
180
215
|
|
|
181
216
|
for (NSString *eventName in [history keyEnumerator]) {
|
|
@@ -197,114 +232,114 @@ RCT_EXPORT_METHOD(setLocation:(double)latitude longitude:(double)longitude) {
|
|
|
197
232
|
|
|
198
233
|
RCT_EXPORT_METHOD(profileGetCleverTapAttributionIdentifier:(RCTResponseSenderBlock)callback) {
|
|
199
234
|
RCTLogInfo(@"[CleverTap profileGetCleverTapAttributionIdentifier]");
|
|
200
|
-
NSString *result = [[
|
|
235
|
+
NSString *result = [[self cleverTapInstance] profileGetCleverTapAttributionIdentifier];
|
|
201
236
|
[self returnResult:result withCallback:callback andError:nil];
|
|
202
237
|
}
|
|
203
238
|
|
|
204
239
|
RCT_EXPORT_METHOD(profileGetCleverTapID:(RCTResponseSenderBlock)callback) {
|
|
205
240
|
RCTLogInfo(@"[CleverTap profileGetCleverTapID]");
|
|
206
|
-
NSString *result = [[
|
|
241
|
+
NSString *result = [[self cleverTapInstance] profileGetCleverTapID];
|
|
207
242
|
[self returnResult:result withCallback:callback andError:nil];
|
|
208
243
|
}
|
|
209
244
|
|
|
210
245
|
RCT_EXPORT_METHOD(getCleverTapID:(RCTResponseSenderBlock)callback) {
|
|
211
246
|
RCTLogInfo(@"[CleverTap getCleverTapID]");
|
|
212
|
-
NSString *result = [[
|
|
247
|
+
NSString *result = [[self cleverTapInstance] profileGetCleverTapID];
|
|
213
248
|
[self returnResult:result withCallback:callback andError:nil];
|
|
214
249
|
}
|
|
215
250
|
|
|
216
251
|
RCT_EXPORT_METHOD(onUserLogin:(NSDictionary*)profile) {
|
|
217
252
|
RCTLogInfo(@"[CleverTap onUserLogin: %@]", profile);
|
|
218
253
|
NSDictionary *_profile = [self formatProfile:profile];
|
|
219
|
-
[[
|
|
254
|
+
[[self cleverTapInstance] onUserLogin:_profile];
|
|
220
255
|
}
|
|
221
256
|
|
|
222
257
|
RCT_EXPORT_METHOD(profileSet:(NSDictionary*)profile) {
|
|
223
258
|
RCTLogInfo(@"[CleverTap profileSet: %@]", profile);
|
|
224
259
|
NSDictionary *_profile = [self formatProfile:profile];
|
|
225
|
-
[[
|
|
260
|
+
[[self cleverTapInstance] profilePush:_profile];
|
|
226
261
|
}
|
|
227
262
|
|
|
228
263
|
RCT_EXPORT_METHOD(profileGetProperty:(NSString*)propertyName callback:(RCTResponseSenderBlock)callback) {
|
|
229
264
|
RCTLogInfo(@"[CleverTap profileGetProperty: %@]", propertyName);
|
|
230
|
-
id result = [[
|
|
265
|
+
id result = [[self cleverTapInstance] profileGet:propertyName];
|
|
231
266
|
[self returnResult:result withCallback:callback andError:nil];
|
|
232
267
|
}
|
|
233
268
|
|
|
234
269
|
RCT_EXPORT_METHOD(profileRemoveValueForKey:(NSString*)key) {
|
|
235
270
|
RCTLogInfo(@"[CleverTap profileRemoveValueForKey: %@]", key);
|
|
236
|
-
[[
|
|
271
|
+
[[self cleverTapInstance] profileRemoveValueForKey:key];
|
|
237
272
|
}
|
|
238
273
|
|
|
239
274
|
RCT_EXPORT_METHOD(profileSetMultiValues:(NSArray<NSString*>*)values forKey:(NSString*)key) {
|
|
240
275
|
RCTLogInfo(@"[CleverTap profileSetMultiValues: %@ forKey: %@]", values, key);
|
|
241
|
-
[[
|
|
276
|
+
[[self cleverTapInstance] profileSetMultiValues:values forKey:key];
|
|
242
277
|
}
|
|
243
278
|
|
|
244
279
|
RCT_EXPORT_METHOD(profileAddMultiValue:(NSString*)value forKey:(NSString*)key) {
|
|
245
280
|
RCTLogInfo(@"[CleverTap profileAddMultiValue: %@ forKey: %@]", value, key);
|
|
246
|
-
[[
|
|
281
|
+
[[self cleverTapInstance] profileAddMultiValue:value forKey:key];
|
|
247
282
|
}
|
|
248
283
|
|
|
249
284
|
RCT_EXPORT_METHOD(profileAddMultiValues:(NSArray<NSString*>*)values forKey:(NSString*)key) {
|
|
250
285
|
RCTLogInfo(@"[CleverTap profileAddMultiValues: %@ forKey: %@]", values, key);
|
|
251
|
-
[[
|
|
286
|
+
[[self cleverTapInstance] profileAddMultiValues:values forKey:key];
|
|
252
287
|
}
|
|
253
288
|
|
|
254
289
|
RCT_EXPORT_METHOD(profileRemoveMultiValue:(NSString*)value forKey:(NSString*)key) {
|
|
255
290
|
RCTLogInfo(@"[CleverTap profileRemoveMultiValue: %@ forKey: %@]", value, key);
|
|
256
|
-
[[
|
|
291
|
+
[[self cleverTapInstance] profileRemoveMultiValue:value forKey:key];
|
|
257
292
|
}
|
|
258
293
|
|
|
259
294
|
RCT_EXPORT_METHOD(profileRemoveMultiValues:(NSArray<NSString*>*)values forKey:(NSString*)key) {
|
|
260
295
|
RCTLogInfo(@"[CleverTap profileRemoveMultiValues: %@ forKey: %@]", values, key);
|
|
261
|
-
[[
|
|
296
|
+
[[self cleverTapInstance] profileRemoveMultiValues:values forKey:key];
|
|
262
297
|
}
|
|
263
298
|
|
|
264
299
|
RCT_EXPORT_METHOD(profileIncrementValueForKey:(NSNumber* _Nonnull)value forKey:(NSString* _Nonnull)key) {
|
|
265
300
|
RCTLogInfo(@"[CleverTap profileIncrementValueBy: %@ forKey: %@]", value, key);
|
|
266
|
-
[[
|
|
301
|
+
[[self cleverTapInstance] profileIncrementValueBy:value forKey:key];
|
|
267
302
|
}
|
|
268
303
|
|
|
269
304
|
RCT_EXPORT_METHOD(profileDecrementValueForKey:(NSNumber* _Nonnull)value forKey:(NSString* _Nonnull)key) {
|
|
270
305
|
RCTLogInfo(@"[CleverTap profileDecrementValueBy: %@ forKey: %@]", value, key);
|
|
271
|
-
[[
|
|
306
|
+
[[self cleverTapInstance] profileDecrementValueBy:value forKey:key];
|
|
272
307
|
}
|
|
273
308
|
|
|
274
309
|
#pragma mark - Session API
|
|
275
310
|
|
|
276
311
|
RCT_EXPORT_METHOD(pushInstallReferrer:(NSString*)source medium:(NSString*)medium campaign:(NSString*)campaign) {
|
|
277
312
|
RCTLogInfo(@"[CleverTap pushInstallReferrer source: %@ medium: %@ campaign: %@]", source, medium, campaign);
|
|
278
|
-
[[
|
|
313
|
+
[[self cleverTapInstance] pushInstallReferrerSource:source medium:medium campaign:campaign];
|
|
279
314
|
}
|
|
280
315
|
|
|
281
316
|
RCT_EXPORT_METHOD(sessionGetTimeElapsed:(RCTResponseSenderBlock)callback) {
|
|
282
317
|
RCTLogInfo(@"[CleverTap sessionGetTimeElapsed]");
|
|
283
|
-
NSTimeInterval result = [[
|
|
318
|
+
NSTimeInterval result = [[self cleverTapInstance] sessionGetTimeElapsed];
|
|
284
319
|
[self returnResult:@(result) withCallback:callback andError:nil];
|
|
285
320
|
}
|
|
286
321
|
|
|
287
322
|
RCT_EXPORT_METHOD(sessionGetTotalVisits:(RCTResponseSenderBlock)callback) {
|
|
288
323
|
RCTLogInfo(@"[CleverTap sessionGetTotalVisits]");
|
|
289
|
-
int result = [[
|
|
324
|
+
int result = [[self cleverTapInstance] userGetTotalVisits];
|
|
290
325
|
[self returnResult:@(result) withCallback:callback andError:nil];
|
|
291
326
|
}
|
|
292
327
|
|
|
293
328
|
RCT_EXPORT_METHOD(sessionGetScreenCount:(RCTResponseSenderBlock)callback) {
|
|
294
329
|
RCTLogInfo(@"[CleverTap sessionGetScreenCount]");
|
|
295
|
-
int result = [[
|
|
330
|
+
int result = [[self cleverTapInstance] userGetScreenCount];
|
|
296
331
|
[self returnResult:@(result) withCallback:callback andError:nil];
|
|
297
332
|
}
|
|
298
333
|
|
|
299
334
|
RCT_EXPORT_METHOD(sessionGetPreviousVisitTime:(RCTResponseSenderBlock)callback) {
|
|
300
335
|
RCTLogInfo(@"[CleverTap sessionGetPreviousVisitTime]");
|
|
301
|
-
NSTimeInterval result = [[
|
|
336
|
+
NSTimeInterval result = [[self cleverTapInstance] userGetPreviousVisitTime];
|
|
302
337
|
[self returnResult:@(result) withCallback:callback andError:nil];
|
|
303
338
|
}
|
|
304
339
|
|
|
305
340
|
RCT_EXPORT_METHOD(sessionGetUTMDetails:(RCTResponseSenderBlock)callback) {
|
|
306
341
|
RCTLogInfo(@"[CleverTap sessionGetUTMDetails]");
|
|
307
|
-
CleverTapUTMDetail *detail = [[
|
|
342
|
+
CleverTapUTMDetail *detail = [[self cleverTapInstance] sessionGetUTMDetails];
|
|
308
343
|
NSDictionary *result = [self _utmDetailToDict:detail];
|
|
309
344
|
[self returnResult:result withCallback:callback andError:nil];
|
|
310
345
|
}
|
|
@@ -449,19 +484,19 @@ RCT_EXPORT_METHOD(setDebugLevel:(int)level) {
|
|
|
449
484
|
|
|
450
485
|
RCT_EXPORT_METHOD(getInboxMessageCount:(RCTResponseSenderBlock)callback) {
|
|
451
486
|
RCTLogInfo(@"[CleverTap inboxMessageCount]");
|
|
452
|
-
int result = (int)[[
|
|
487
|
+
int result = (int)[[self cleverTapInstance] getInboxMessageCount];
|
|
453
488
|
[self returnResult:@(result) withCallback:callback andError:nil];
|
|
454
489
|
}
|
|
455
490
|
|
|
456
491
|
RCT_EXPORT_METHOD(getInboxMessageUnreadCount:(RCTResponseSenderBlock)callback) {
|
|
457
492
|
RCTLogInfo(@"[CleverTap inboxMessageUnreadCount]");
|
|
458
|
-
int result = (int)[[
|
|
493
|
+
int result = (int)[[self cleverTapInstance] getInboxMessageUnreadCount];
|
|
459
494
|
[self returnResult:@(result) withCallback:callback andError:nil];
|
|
460
495
|
}
|
|
461
496
|
|
|
462
497
|
RCT_EXPORT_METHOD(getAllInboxMessages:(RCTResponseSenderBlock)callback) {
|
|
463
498
|
RCTLogInfo(@"[CleverTap getAllInboxMessages]");
|
|
464
|
-
NSArray<CleverTapInboxMessage *> *messageList = [[
|
|
499
|
+
NSArray<CleverTapInboxMessage *> *messageList = [[self cleverTapInstance] getAllInboxMessages];
|
|
465
500
|
NSMutableArray *allMessages = [NSMutableArray new];
|
|
466
501
|
for (CleverTapInboxMessage *message in messageList) {
|
|
467
502
|
[allMessages addObject:message.json];
|
|
@@ -472,7 +507,7 @@ RCT_EXPORT_METHOD(getAllInboxMessages:(RCTResponseSenderBlock)callback) {
|
|
|
472
507
|
|
|
473
508
|
RCT_EXPORT_METHOD(getUnreadInboxMessages:(RCTResponseSenderBlock)callback) {
|
|
474
509
|
RCTLogInfo(@"[CleverTap getUnreadInboxMessages]");
|
|
475
|
-
NSArray<CleverTapInboxMessage *> *messageList = [[
|
|
510
|
+
NSArray<CleverTapInboxMessage *> *messageList = [[self cleverTapInstance] getUnreadInboxMessages];
|
|
476
511
|
NSMutableArray *unreadMessages = [NSMutableArray new];
|
|
477
512
|
for (CleverTapInboxMessage *message in messageList) {
|
|
478
513
|
[unreadMessages addObject:message.json];
|
|
@@ -483,38 +518,38 @@ RCT_EXPORT_METHOD(getUnreadInboxMessages:(RCTResponseSenderBlock)callback) {
|
|
|
483
518
|
|
|
484
519
|
RCT_EXPORT_METHOD(getInboxMessageForId:(NSString*)messageId callback:(RCTResponseSenderBlock)callback) {
|
|
485
520
|
RCTLogInfo(@"[CleverTap getInboxMessageForId]");
|
|
486
|
-
CleverTapInboxMessage * message = [[
|
|
521
|
+
CleverTapInboxMessage * message = [[self cleverTapInstance] getInboxMessageForId:messageId];
|
|
487
522
|
NSDictionary *result = message.json;
|
|
488
523
|
[self returnResult:result withCallback:callback andError:nil];
|
|
489
524
|
}
|
|
490
525
|
|
|
491
526
|
RCT_EXPORT_METHOD(pushInboxNotificationViewedEventForId:(NSString*)messageId) {
|
|
492
527
|
RCTLogInfo(@"[CleverTap pushInboxNotificationViewedEventForId]");
|
|
493
|
-
[[
|
|
528
|
+
[[self cleverTapInstance] recordInboxNotificationViewedEventForID:messageId];
|
|
494
529
|
}
|
|
495
530
|
|
|
496
531
|
RCT_EXPORT_METHOD(pushInboxNotificationClickedEventForId:(NSString*)messageId) {
|
|
497
532
|
RCTLogInfo(@"[CleverTap pushInboxNotificationClickedEventForId]");
|
|
498
|
-
[[
|
|
533
|
+
[[self cleverTapInstance] recordInboxNotificationClickedEventForID:messageId];
|
|
499
534
|
}
|
|
500
535
|
|
|
501
536
|
RCT_EXPORT_METHOD(markReadInboxMessageForId:(NSString*)messageId) {
|
|
502
537
|
RCTLogInfo(@"[CleverTap markReadInboxMessageForId]");
|
|
503
|
-
[[
|
|
538
|
+
[[self cleverTapInstance] markReadInboxMessageForID:messageId];
|
|
504
539
|
}
|
|
505
540
|
|
|
506
541
|
RCT_EXPORT_METHOD(deleteInboxMessageForId:(NSString*)messageId) {
|
|
507
542
|
RCTLogInfo(@"[CleverTap deleteInboxMessageForId]");
|
|
508
|
-
[[
|
|
543
|
+
[[self cleverTapInstance] deleteInboxMessageForID:messageId];
|
|
509
544
|
}
|
|
510
545
|
|
|
511
546
|
RCT_EXPORT_METHOD(initializeInbox) {
|
|
512
547
|
RCTLogInfo(@"[CleverTap Inbox Initialize]");
|
|
513
|
-
[[
|
|
548
|
+
[[self cleverTapInstance] initializeInboxWithCallback:^(BOOL success) {
|
|
514
549
|
if (success) {
|
|
515
550
|
RCTLogInfo(@"[Inbox initialized]");
|
|
516
551
|
[[NSNotificationCenter defaultCenter] postNotificationName:kCleverTapInboxDidInitialize object:nil userInfo:nil];
|
|
517
|
-
[[
|
|
552
|
+
[[self cleverTapInstance] registerInboxUpdatedBlock:^{
|
|
518
553
|
RCTLogInfo(@"[Inbox updated]");
|
|
519
554
|
[[NSNotificationCenter defaultCenter] postNotificationName:kCleverTapInboxMessagesDidUpdate object:nil userInfo:nil];
|
|
520
555
|
}];
|
|
@@ -524,7 +559,7 @@ RCT_EXPORT_METHOD(initializeInbox) {
|
|
|
524
559
|
|
|
525
560
|
RCT_EXPORT_METHOD(showInbox:(NSDictionary*)styleConfig) {
|
|
526
561
|
RCTLogInfo(@"[CleverTap Show Inbox]");
|
|
527
|
-
CleverTapInboxViewController *inboxController = [[
|
|
562
|
+
CleverTapInboxViewController *inboxController = [[self cleverTapInstance] newInboxViewControllerWithConfig:[self _dictToInboxStyleConfig:styleConfig? styleConfig : nil] andDelegate:(id <CleverTapInboxViewControllerDelegate>)self];
|
|
528
563
|
if (inboxController) {
|
|
529
564
|
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:inboxController];
|
|
530
565
|
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
|
|
@@ -624,7 +659,7 @@ RCT_EXPORT_METHOD(showInbox:(NSDictionary*)styleConfig) {
|
|
|
624
659
|
|
|
625
660
|
RCT_EXPORT_METHOD(getAllDisplayUnits:(RCTResponseSenderBlock)callback) {
|
|
626
661
|
RCTLogInfo(@"[CleverTap getAllDisplayUnits]");
|
|
627
|
-
NSArray <CleverTapDisplayUnit*> *units = [[
|
|
662
|
+
NSArray <CleverTapDisplayUnit*> *units = [[self cleverTapInstance] getAllDisplayUnits];
|
|
628
663
|
NSMutableArray *displayUnits = [NSMutableArray new];
|
|
629
664
|
for (CleverTapDisplayUnit *unit in units) {
|
|
630
665
|
[displayUnits addObject:unit.json];
|
|
@@ -635,19 +670,19 @@ RCT_EXPORT_METHOD(getAllDisplayUnits:(RCTResponseSenderBlock)callback) {
|
|
|
635
670
|
|
|
636
671
|
RCT_EXPORT_METHOD(getDisplayUnitForId:(NSString*)unitId callback:(RCTResponseSenderBlock)callback) {
|
|
637
672
|
RCTLogInfo(@"[CleverTap getDisplayUnitForId]");
|
|
638
|
-
CleverTapDisplayUnit * displayUnit = [[
|
|
673
|
+
CleverTapDisplayUnit * displayUnit = [[self cleverTapInstance] getDisplayUnitForID:unitId];
|
|
639
674
|
NSDictionary *result = displayUnit.json;
|
|
640
675
|
[self returnResult:result withCallback:callback andError:nil];
|
|
641
676
|
}
|
|
642
677
|
|
|
643
678
|
RCT_EXPORT_METHOD(pushDisplayUnitViewedEventForID:(NSString*)unitId) {
|
|
644
679
|
RCTLogInfo(@"[CleverTap pushDisplayUnitViewedEventForID]");
|
|
645
|
-
[[
|
|
680
|
+
[[self cleverTapInstance] recordDisplayUnitViewedEventForID:unitId];
|
|
646
681
|
}
|
|
647
682
|
|
|
648
683
|
RCT_EXPORT_METHOD(pushDisplayUnitClickedEventForID:(NSString*)unitId) {
|
|
649
684
|
RCTLogInfo(@"[CleverTap pushDisplayUnitClickedEventForID]");
|
|
650
|
-
[[
|
|
685
|
+
[[self cleverTapInstance] recordDisplayUnitClickedEventForID:unitId];
|
|
651
686
|
}
|
|
652
687
|
|
|
653
688
|
|
|
@@ -655,7 +690,7 @@ RCT_EXPORT_METHOD(pushDisplayUnitClickedEventForID:(NSString*)unitId) {
|
|
|
655
690
|
|
|
656
691
|
RCT_EXPORT_METHOD(getFeatureFlag:(NSString*)flag withdefaultValue:(BOOL)defaultValue callback:(RCTResponseSenderBlock)callback) {
|
|
657
692
|
RCTLogInfo(@"[CleverTap getFeatureFlag]");
|
|
658
|
-
BOOL result = [[[
|
|
693
|
+
BOOL result = [[[self cleverTapInstance] featureFlags] get:flag withDefaultValue:defaultValue];
|
|
659
694
|
[self returnResult:@(result) withCallback:callback andError:nil];
|
|
660
695
|
}
|
|
661
696
|
|
|
@@ -664,78 +699,184 @@ RCT_EXPORT_METHOD(getFeatureFlag:(NSString*)flag withdefaultValue:(BOOL)defaultV
|
|
|
664
699
|
|
|
665
700
|
RCT_EXPORT_METHOD(setDefaultsMap:(NSDictionary*)jsonDict) {
|
|
666
701
|
RCTLogInfo(@"[CleverTap setDefaultsMap]");
|
|
667
|
-
[[[
|
|
702
|
+
[[[self cleverTapInstance] productConfig] setDefaults:jsonDict];
|
|
668
703
|
}
|
|
669
704
|
|
|
670
705
|
RCT_EXPORT_METHOD(fetch) {
|
|
671
706
|
RCTLogInfo(@"[CleverTap ProductConfig Fetch]");
|
|
672
|
-
[[[
|
|
707
|
+
[[[self cleverTapInstance] productConfig] fetch];
|
|
673
708
|
}
|
|
674
709
|
|
|
675
710
|
RCT_EXPORT_METHOD(fetchWithMinimumFetchIntervalInSeconds:(double)time) {
|
|
676
711
|
RCTLogInfo(@"[CleverTap ProductConfig Fetch with minimum Interval]");
|
|
677
|
-
[[[
|
|
712
|
+
[[[self cleverTapInstance] productConfig] fetchWithMinimumInterval: time];
|
|
678
713
|
}
|
|
679
714
|
|
|
680
715
|
RCT_EXPORT_METHOD(activate) {
|
|
681
716
|
RCTLogInfo(@"[CleverTap ProductConfig Activate]");
|
|
682
|
-
[[[
|
|
717
|
+
[[[self cleverTapInstance] productConfig] activate];
|
|
683
718
|
}
|
|
684
719
|
|
|
685
720
|
RCT_EXPORT_METHOD(fetchAndActivate) {
|
|
686
721
|
RCTLogInfo(@"[CleverTap ProductConfig Fetch and Activate]");
|
|
687
|
-
[[[
|
|
722
|
+
[[[self cleverTapInstance] productConfig] fetchAndActivate];
|
|
688
723
|
}
|
|
689
724
|
|
|
690
725
|
RCT_EXPORT_METHOD(setMinimumFetchIntervalInSeconds:(double)time) {
|
|
691
726
|
RCTLogInfo(@"[CleverTap ProductConfig Minimum Time Interval Setup]");
|
|
692
|
-
[[[
|
|
727
|
+
[[[self cleverTapInstance] productConfig] setMinimumFetchInterval: time];
|
|
693
728
|
}
|
|
694
729
|
|
|
695
730
|
RCT_EXPORT_METHOD(getLastFetchTimeStampInMillis:(RCTResponseSenderBlock)callback) {
|
|
696
731
|
RCTLogInfo(@"[CleverTap Last Fetch Config time]");
|
|
697
|
-
NSTimeInterval result = [[[[
|
|
732
|
+
NSTimeInterval result = [[[[self cleverTapInstance] productConfig] getLastFetchTimeStamp] timeIntervalSince1970] * 1000;
|
|
698
733
|
[self returnResult: @(result) withCallback: callback andError:nil];
|
|
699
734
|
}
|
|
700
735
|
|
|
701
736
|
RCT_EXPORT_METHOD(getString:(NSString*)key callback:(RCTResponseSenderBlock)callback) {
|
|
702
737
|
RCTLogInfo(@"[CleverTap fetch String value for Key]");
|
|
703
|
-
NSString *result = [[[
|
|
738
|
+
NSString *result = [[[self cleverTapInstance] productConfig] get:key].stringValue;
|
|
704
739
|
[self returnResult: result withCallback: callback andError:nil];
|
|
705
740
|
}
|
|
706
741
|
|
|
707
742
|
RCT_EXPORT_METHOD(getBoolean:(NSString*)key callback:(RCTResponseSenderBlock)callback) {
|
|
708
743
|
RCTLogInfo(@"[CleverTap fetch Bool value for Key]");
|
|
709
|
-
BOOL result = [[[
|
|
744
|
+
BOOL result = [[[self cleverTapInstance] productConfig] get:key].boolValue;
|
|
710
745
|
[self returnResult: @(result) withCallback: callback andError:nil];
|
|
711
746
|
}
|
|
712
747
|
|
|
713
748
|
RCT_EXPORT_METHOD(getDouble:(NSString*)key callback:(RCTResponseSenderBlock)callback) {
|
|
714
749
|
RCTLogInfo(@"[CleverTap fetch Double value for Key]");
|
|
715
|
-
long result = [[[
|
|
750
|
+
long result = [[[self cleverTapInstance] productConfig] get:key].numberValue.doubleValue;
|
|
716
751
|
[self returnResult: @(result) withCallback: callback andError:nil];
|
|
717
752
|
}
|
|
718
753
|
|
|
719
754
|
RCT_EXPORT_METHOD(reset) {
|
|
720
755
|
RCTLogInfo(@"[CleverTap ProductConfig Reset]");
|
|
721
|
-
[[[
|
|
756
|
+
[[[self cleverTapInstance] productConfig] reset];
|
|
722
757
|
}
|
|
723
758
|
|
|
724
759
|
#pragma mark - InApp Notification Controls
|
|
725
760
|
|
|
726
761
|
RCT_EXPORT_METHOD(suspendInAppNotifications) {
|
|
727
762
|
RCTLogInfo(@"[CleverTap suspendInAppNotifications");
|
|
728
|
-
[[
|
|
763
|
+
[[self cleverTapInstance] suspendInAppNotifications];
|
|
729
764
|
}
|
|
730
765
|
|
|
731
766
|
RCT_EXPORT_METHOD(discardInAppNotifications) {
|
|
732
767
|
RCTLogInfo(@"[CleverTap discardInAppNotifications");
|
|
733
|
-
[[
|
|
768
|
+
[[self cleverTapInstance] discardInAppNotifications];
|
|
734
769
|
}
|
|
735
770
|
|
|
736
771
|
RCT_EXPORT_METHOD(resumeInAppNotifications) {
|
|
737
772
|
RCTLogInfo(@"[CleverTap resumeInAppNotifications");
|
|
738
|
-
[[
|
|
773
|
+
[[self cleverTapInstance] resumeInAppNotifications];
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
#pragma mark - Push Permission
|
|
777
|
+
|
|
778
|
+
- (CTLocalInApp*)_localInAppConfigFromReadableMap: (NSDictionary *)json {
|
|
779
|
+
CTLocalInApp *inAppBuilder;
|
|
780
|
+
CTLocalInAppType inAppType = HALF_INTERSTITIAL;
|
|
781
|
+
//Required parameters
|
|
782
|
+
NSString *titleText = nil, *messageText = nil, *followDeviceOrientation = nil, *positiveBtnText = nil, *negativeBtnText = nil;
|
|
783
|
+
//Additional parameters
|
|
784
|
+
NSString *fallbackToSettings = nil, *backgroundColor = nil, *btnBorderColor = nil, *titleTextColor = nil, *messageTextColor = nil, *btnTextColor = nil, *imageUrl = nil, *btnBackgroundColor = nil, *btnBorderRadius = nil;
|
|
785
|
+
|
|
786
|
+
if ([json[@"inAppType"] isEqual: @"half-interstitial"]){
|
|
787
|
+
inAppType = HALF_INTERSTITIAL;
|
|
788
|
+
}
|
|
789
|
+
else {
|
|
790
|
+
inAppType = ALERT;
|
|
791
|
+
}
|
|
792
|
+
if (json[@"titleText"]) {
|
|
793
|
+
titleText = [json valueForKey:@"titleText"];
|
|
794
|
+
}
|
|
795
|
+
if (json[@"messageText"]) {
|
|
796
|
+
messageText = [json valueForKey:@"messageText"];
|
|
797
|
+
}
|
|
798
|
+
if (json[@"followDeviceOrientation"]) {
|
|
799
|
+
followDeviceOrientation = [json valueForKey:@"followDeviceOrientation"];
|
|
800
|
+
}
|
|
801
|
+
if (json[@"positiveBtnText"]) {
|
|
802
|
+
positiveBtnText = [json valueForKey:@"positiveBtnText"];
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
if (json[@"negativeBtnText"]) {
|
|
806
|
+
negativeBtnText = [json valueForKey:@"negativeBtnText"];
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
//creates the builder instance with all the required parameters
|
|
810
|
+
inAppBuilder = [[CTLocalInApp alloc] initWithInAppType:inAppType
|
|
811
|
+
titleText:titleText
|
|
812
|
+
messageText:messageText
|
|
813
|
+
followDeviceOrientation:followDeviceOrientation
|
|
814
|
+
positiveBtnText:positiveBtnText
|
|
815
|
+
negativeBtnText:negativeBtnText];
|
|
816
|
+
|
|
817
|
+
//adds optional parameters to the builder instance
|
|
818
|
+
if (json[@"fallbackToSettings"]) {
|
|
819
|
+
fallbackToSettings = [json valueForKey:@"fallbackToSettings"];
|
|
820
|
+
[inAppBuilder setFallbackToSettings:fallbackToSettings];
|
|
821
|
+
}
|
|
822
|
+
if (json[@"backgroundColor"]) {
|
|
823
|
+
backgroundColor = [json valueForKey:@"backgroundColor"];
|
|
824
|
+
[inAppBuilder setBackgroundColor:backgroundColor];
|
|
825
|
+
}
|
|
826
|
+
if (json[@"btnBorderColor"]) {
|
|
827
|
+
btnBorderColor = [json valueForKey:@"btnBorderColor"];
|
|
828
|
+
[inAppBuilder setBtnBorderColor:btnBorderColor];
|
|
829
|
+
}
|
|
830
|
+
if (json[@"titleTextColor"]) {
|
|
831
|
+
titleTextColor = [json valueForKey:@"titleTextColor"];
|
|
832
|
+
[inAppBuilder setTitleTextColor:titleTextColor];
|
|
833
|
+
}
|
|
834
|
+
if (json[@"messageTextColor"]) {
|
|
835
|
+
messageTextColor = [json valueForKey:@"messageTextColor"];
|
|
836
|
+
[inAppBuilder setMessageTextColor:messageTextColor];
|
|
837
|
+
}
|
|
838
|
+
if (json[@"btnTextColor"]) {
|
|
839
|
+
btnTextColor = [json valueForKey:@"btnTextColor"];
|
|
840
|
+
[inAppBuilder setBtnTextColor:btnTextColor];
|
|
841
|
+
}
|
|
842
|
+
if (json[@"imageUrl"]) {
|
|
843
|
+
imageUrl = [json valueForKey:@"imageUrl"];
|
|
844
|
+
[inAppBuilder setImageUrl:imageUrl];
|
|
845
|
+
}
|
|
846
|
+
if (json[@"btnBackgroundColor"]) {
|
|
847
|
+
btnBackgroundColor = [json valueForKey:@"btnBackgroundColor"];
|
|
848
|
+
[inAppBuilder setBtnBackgroundColor:btnBackgroundColor];
|
|
849
|
+
}
|
|
850
|
+
if (json[@"btnBorderRadius"]) {
|
|
851
|
+
btnBorderRadius = [json valueForKey:@"btnBorderRadius"];
|
|
852
|
+
[inAppBuilder setBtnBorderRadius:btnBorderRadius];
|
|
853
|
+
}
|
|
854
|
+
return inAppBuilder;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
RCT_EXPORT_METHOD(promptForPushPermission:(BOOL)showFallbackSettings){
|
|
858
|
+
RCTLogInfo(@"[CleverTap promptForPushPermission: %i]", showFallbackSettings);
|
|
859
|
+
[[self cleverTapInstance] promptForPushPermission:showFallbackSettings];
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
RCT_EXPORT_METHOD(promptPushPrimer:(NSDictionary *_Nonnull)json){
|
|
863
|
+
RCTLogInfo(@"[CleverTap promptPushPrimer]");
|
|
864
|
+
CTLocalInApp *localInAppBuilder = [self _localInAppConfigFromReadableMap:json];
|
|
865
|
+
[[self cleverTapInstance] promptPushPrimer:localInAppBuilder.getLocalInAppSettings];
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
RCT_EXPORT_METHOD(isPushPermissionGranted:(RCTResponseSenderBlock)callback){
|
|
869
|
+
if (@available(iOS 10.0, *)) {
|
|
870
|
+
[[self cleverTapInstance] getNotificationPermissionStatusWithCompletionHandler:^(UNAuthorizationStatus status) {
|
|
871
|
+
BOOL result = (status == UNAuthorizationStatusAuthorized);
|
|
872
|
+
RCTLogInfo(@"[CleverTap isPushPermissionGranted: %i]", result);
|
|
873
|
+
[self returnResult:@(result) withCallback:callback andError:nil];
|
|
874
|
+
}];
|
|
875
|
+
} else {
|
|
876
|
+
// Fallback on earlier versions
|
|
877
|
+
RCTLogInfo(@"Push Notification is available from iOS v10.0 or later");
|
|
878
|
+
}
|
|
739
879
|
}
|
|
740
880
|
|
|
741
881
|
@end
|
|
882
|
+
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
1
|
#import "CleverTapReactEventEmitter.h"
|
|
3
|
-
#import "CleverTapReactManager.h"
|
|
4
2
|
#import "CleverTapReact.h"
|
|
5
3
|
|
|
6
4
|
#import <React/RCTLog.h>
|
|
@@ -10,7 +8,7 @@
|
|
|
10
8
|
RCT_EXPORT_MODULE();
|
|
11
9
|
|
|
12
10
|
- (NSArray<NSString *> *)supportedEvents {
|
|
13
|
-
return @[kCleverTapProfileDidInitialize, kCleverTapProfileSync, kCleverTapInAppNotificationDismissed, kCleverTapInboxDidInitialize, kCleverTapInboxMessagesDidUpdate, kCleverTapInAppNotificationButtonTapped, kCleverTapInboxMessageButtonTapped, kCleverTapInboxMessageTapped, kCleverTapDisplayUnitsLoaded, kCleverTapFeatureFlagsDidUpdate, kCleverTapProductConfigDidFetch, kCleverTapProductConfigDidActivate, kCleverTapProductConfigDidInitialize, kCleverTapPushNotificationClicked];
|
|
11
|
+
return @[kCleverTapProfileDidInitialize, kCleverTapProfileSync, kCleverTapInAppNotificationDismissed, kCleverTapInboxDidInitialize, kCleverTapInboxMessagesDidUpdate, kCleverTapInAppNotificationButtonTapped, kCleverTapInboxMessageButtonTapped, kCleverTapInboxMessageTapped, kCleverTapDisplayUnitsLoaded, kCleverTapFeatureFlagsDidUpdate, kCleverTapProductConfigDidFetch, kCleverTapProductConfigDidActivate, kCleverTapProductConfigDidInitialize, kCleverTapPushNotificationClicked, kCleverTapPushPermissionResponseReceived, kCleverTapInAppNotificationShowed];
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
|
|
@@ -85,6 +83,11 @@ RCT_EXPORT_MODULE();
|
|
|
85
83
|
name:kCleverTapPushNotificationClicked
|
|
86
84
|
object:nil];
|
|
87
85
|
|
|
86
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
87
|
+
selector:@selector(emitEventInternal:)
|
|
88
|
+
name:kCleverTapPushPermissionResponseReceived
|
|
89
|
+
object:nil];
|
|
90
|
+
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
- (void)stopObserving {
|
|
@@ -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
|