clevertap-react-native 1.2.0 → 2.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 +52 -0
- package/android/.gradle/6.1.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/6.1.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/build.gradle +3 -3
- package/android/src/main/java/com/clevertap/react/CleverTapModule.java +39 -0
- package/clevertap-react-native.podspec +1 -1
- package/docs/iospushtemplates.md +141 -8
- package/docs/usage.md +36 -1
- package/index.d.ts +21 -0
- package/index.js +27 -1
- package/ios/CleverTapReact/CleverTapReact.m +31 -2
- package/package.json +1 -5
- package/static/NotificationContentStoryboard.png +0 -0
- package/static/NotificationServiceTarget.png +0 -0
- package/install.js +0 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
Change Log
|
|
2
2
|
==========
|
|
3
3
|
|
|
4
|
+
Version 2.0.0 *(15 February 2024)*
|
|
5
|
+
-------------------------------------------
|
|
6
|
+
**What's new**
|
|
7
|
+
* **[Android Platform]**
|
|
8
|
+
* Supports [CleverTap Android SDK v6.0.0](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md#version-600-january-15-2024).
|
|
9
|
+
|
|
10
|
+
* **[iOS Platform]**
|
|
11
|
+
* Supports [CleverTap iOS SDK v6.0.0](https://github.com/CleverTap/clevertap-ios-sdk/releases/tag/6.0.0).
|
|
12
|
+
|
|
13
|
+
* **[Android and iOS Platform]**
|
|
14
|
+
* Adds support for client-side in-apps.
|
|
15
|
+
* Adds new API `clearInAppResources(boolean)` to delete images and gifs which are preloaded for inapps in cs mode
|
|
16
|
+
* Adds new API `fetchInApps()` to explicitly fetch InApps from the server
|
|
17
|
+
|
|
18
|
+
**Bug Fixes**
|
|
19
|
+
* **[Android Platform]**
|
|
20
|
+
* Fixes a bug where JavaScript was not working for custom-html InApp header/footer templates.
|
|
21
|
+
* Fixes an NPE related to AppInbox APIs.
|
|
22
|
+
* Fixes a ClassCastException in defineVariable API of Product Experiences.
|
|
23
|
+
* Fixes a resource name conflict with the firebase library in fcm_fallback_notification_channel_label
|
|
24
|
+
* Fixes a StrictMode Violation spawning from ctVariables.init().
|
|
25
|
+
* Removes use of lossy conversions leading to an issue in PushTemplates.
|
|
26
|
+
* Handles an edge case related to migration of encryption level when local db is out of memory
|
|
27
|
+
|
|
28
|
+
* **[iOS Platform]**
|
|
29
|
+
* Fixes a bug where some in-apps were not being dismissed.
|
|
30
|
+
|
|
31
|
+
Version 1.2.1 *(25 October 2023)*
|
|
32
|
+
-------------------------------------------
|
|
33
|
+
**What's new**
|
|
34
|
+
* **[Android Platform]**
|
|
35
|
+
* Supports [CleverTap Android SDK v5.2.1](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md#version-521-october-12-2023).
|
|
36
|
+
* Adds Custom Proxy Domain functionality for Push Impressions and Events raised from CleverTap Android SDK. Please refer to [Usage.md](docs/Usage.md#integrate-custom-proxy-domain) file to read more on how to configure custom proxy domains in Android.
|
|
37
|
+
|
|
38
|
+
* **[iOS Platform]**
|
|
39
|
+
* Supports [CleverTap iOS SDK v5.2.1](https://github.com/CleverTap/clevertap-ios-sdk/releases/tag/5.2.1).
|
|
40
|
+
* Adds support to enable `NSFileProtectionComplete` to secure App’s document directory.
|
|
41
|
+
|
|
42
|
+
* **[Android and iOS Platform]**
|
|
43
|
+
* Adds in-built support to send the default locale(i.e.language and country) data to the dashboard and exposed public API `CleverTapPlugin.setLocale(Locale locale)` to set the custom locale, for LP Parity.
|
|
44
|
+
* Adds support for Integration Debugger to view errors and events on the dashboard when the debugLevel is set to 3 using `CleverTapPlugin.setDebugLevel(3)`.
|
|
45
|
+
* Adds support to configure first tab title in App Inbox.
|
|
46
|
+
|
|
47
|
+
**Changes**
|
|
48
|
+
* **[iOS Platform]**
|
|
49
|
+
* Updated logic to retrieve country code using NSLocale above iOS 16 as `CTCarrier` is deprecated above iOS 16 with no replacements, see [Apple Doc](https://developer.apple.com/documentation/coretelephony/ctcarrier).
|
|
50
|
+
* Updated logic to not send carrier name above iOS 16 in CTCarrier field.
|
|
51
|
+
|
|
52
|
+
**Bug Fixes**
|
|
53
|
+
* **[iOS Platform]**
|
|
54
|
+
* Fixes a crash in iOS 17/Xcode 15 related to alert inapps.
|
|
55
|
+
|
|
4
56
|
Version 1.2.0 *(18th August 2023)*
|
|
5
57
|
-------------------------------------------
|
|
6
58
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#
|
|
1
|
+
#Fri Feb 02 17:10:58 IST 2024
|
|
2
2
|
gradle.version=6.1.1
|
|
Binary file
|
package/android/build.gradle
CHANGED
|
@@ -21,8 +21,8 @@ android {
|
|
|
21
21
|
defaultConfig {
|
|
22
22
|
minSdkVersion 19
|
|
23
23
|
targetSdkVersion 33
|
|
24
|
-
versionCode
|
|
25
|
-
versionName "
|
|
24
|
+
versionCode 200
|
|
25
|
+
versionName "2.0.0"
|
|
26
26
|
}
|
|
27
27
|
buildTypes {
|
|
28
28
|
release {
|
|
@@ -39,7 +39,7 @@ dependencies {
|
|
|
39
39
|
maven { url "$rootDir/../node_modules/react-native/android" }
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
api 'com.clevertap.android:clevertap-android-sdk:
|
|
42
|
+
api 'com.clevertap.android:clevertap-android-sdk:6.0.0'
|
|
43
43
|
implementation 'com.android.installreferrer:installreferrer:2.2'
|
|
44
44
|
//compile 'com.android.support:appcompat-v7:28.0.0'
|
|
45
45
|
implementation 'com.facebook.react:react-native:+'
|
|
@@ -41,6 +41,7 @@ import com.clevertap.android.sdk.variables.Var;
|
|
|
41
41
|
import com.clevertap.android.sdk.variables.callbacks.FetchVariablesCallback;
|
|
42
42
|
import com.clevertap.android.sdk.variables.callbacks.VariableCallback;
|
|
43
43
|
import com.clevertap.android.sdk.variables.callbacks.VariablesChangedCallback;
|
|
44
|
+
import com.clevertap.android.sdk.inapp.callbacks.FetchInAppsCallback;
|
|
44
45
|
import com.facebook.react.bridge.Arguments;
|
|
45
46
|
import com.facebook.react.bridge.Callback;
|
|
46
47
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
@@ -177,6 +178,16 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
|
|
|
177
178
|
cleverTap.setCustomSdkVersion(libName,libVersion);
|
|
178
179
|
}
|
|
179
180
|
}
|
|
181
|
+
|
|
182
|
+
@ReactMethod
|
|
183
|
+
private void setLocale(String locale) {
|
|
184
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
185
|
+
if (cleverTap != null) {
|
|
186
|
+
cleverTap.setLocale(locale);
|
|
187
|
+
} else {
|
|
188
|
+
Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage());
|
|
189
|
+
}
|
|
190
|
+
}
|
|
180
191
|
|
|
181
192
|
@ReactMethod
|
|
182
193
|
public void activate() {
|
|
@@ -1537,6 +1548,30 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
|
|
|
1537
1548
|
}
|
|
1538
1549
|
}
|
|
1539
1550
|
|
|
1551
|
+
@ReactMethod
|
|
1552
|
+
public void clearInAppResources(final boolean expiredOnly) {
|
|
1553
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1554
|
+
if (cleverTap != null) {
|
|
1555
|
+
cleverTap.clearInAppResources(expiredOnly);
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
@ReactMethod
|
|
1560
|
+
public void fetchInApps(final Callback callback) {
|
|
1561
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1562
|
+
if (cleverTap != null) {
|
|
1563
|
+
cleverTap.fetchInApps(new FetchInAppsCallback() {
|
|
1564
|
+
@Override
|
|
1565
|
+
public void onInAppsFetched(final boolean isSuccess) {
|
|
1566
|
+
callbackWithErrorAndResult(callback, null, isSuccess);
|
|
1567
|
+
}
|
|
1568
|
+
});
|
|
1569
|
+
} else {
|
|
1570
|
+
String error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage();
|
|
1571
|
+
callbackWithErrorAndResult(callback, error, null);
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1540
1575
|
/************************************************
|
|
1541
1576
|
* Product Experience Remote Config methods ends
|
|
1542
1577
|
************************************************/
|
|
@@ -1998,6 +2033,10 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
|
|
|
1998
2033
|
String noMessageTitleColor = styleConfig.getString(styleConfigKey);
|
|
1999
2034
|
ctInboxStyleConfig.setNoMessageViewTextColor(noMessageTitleColor);
|
|
2000
2035
|
}
|
|
2036
|
+
if ("firstTabTitle".equals(styleConfigKey) && readableType == ReadableType.String) {
|
|
2037
|
+
String firstTabTitle = styleConfig.getString(styleConfigKey);
|
|
2038
|
+
ctInboxStyleConfig.setFirstTabTitle(firstTabTitle);
|
|
2039
|
+
}
|
|
2001
2040
|
|
|
2002
2041
|
} catch (Throwable t) {
|
|
2003
2042
|
Log.e(TAG, t.getLocalizedMessage());
|
|
@@ -18,6 +18,6 @@ Pod::Spec.new do |s|
|
|
|
18
18
|
s.preserve_paths = 'LICENSE.md', 'README.md', 'package.json', 'index.js'
|
|
19
19
|
s.source_files = 'ios/CleverTapReact/*.{h,m}'
|
|
20
20
|
|
|
21
|
-
s.dependency 'CleverTap-iOS-SDK', '
|
|
21
|
+
s.dependency 'CleverTap-iOS-SDK', '6.0.0'
|
|
22
22
|
s.dependency 'React-Core'
|
|
23
23
|
end
|
package/docs/iospushtemplates.md
CHANGED
|
@@ -4,34 +4,151 @@ CleverTap Push Templates SDK helps you engage with your users using fancy push n
|
|
|
4
4
|
|
|
5
5
|
# Table of contents
|
|
6
6
|
|
|
7
|
-
- [
|
|
7
|
+
- [Notification Service](#notification-service)
|
|
8
|
+
- [Notification Content](#notification-content)
|
|
8
9
|
- [Dashboard Usage](#dashboard-usage)
|
|
9
10
|
- [Template Types](#template-types)
|
|
10
11
|
- [Template Keys](#template-keys)
|
|
11
12
|
|
|
12
|
-
#
|
|
13
|
+
# Notification Service
|
|
13
14
|
|
|
14
15
|
[(Back to top)](#table-of-contents)
|
|
15
|
-
|
|
16
|
+
## Installation
|
|
17
|
+
- Go to File -> New -> Target -> Notification Service Extension and select Objective-C language
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
- Update Podfile as below and do `pod install`, refer [example](https://github.com/CleverTap/clevertap-react-native/blob/master/Example/ios/Podfile) for detailed Podfile.
|
|
21
|
+
```
|
|
22
|
+
target 'NotificationService' do
|
|
23
|
+
pod "CTNotificationService", :modular_headers => true
|
|
24
|
+
end
|
|
25
|
+
```
|
|
26
|
+
- Update your `NotificationService.h` as:
|
|
27
|
+
```
|
|
28
|
+
#import <CTNotificationService/CTNotificationService.h>
|
|
29
|
+
|
|
30
|
+
@interface NotificationService : CTNotificationServiceExtension
|
|
31
|
+
@end
|
|
32
|
+
```
|
|
33
|
+
- Update your `NotificationService.m` file as:
|
|
34
|
+
```
|
|
35
|
+
#import "NotificationService.h"
|
|
36
|
+
|
|
37
|
+
@implementation NotificationService
|
|
38
|
+
|
|
39
|
+
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
|
|
40
|
+
[super didReceiveNotificationRequest:request withContentHandler:contentHandler];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@end
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Push Impression
|
|
47
|
+
- Add `pod "CleverTap-iOS-SDK" ` in podfile for notification service target as do `pod install`:
|
|
48
|
+
```
|
|
49
|
+
target 'NotificationService' do
|
|
50
|
+
pod "CleverTap-iOS-SDK", :modular_headers => true
|
|
51
|
+
pod "CTNotificationService", :modular_headers => true
|
|
52
|
+
end
|
|
53
|
+
```
|
|
54
|
+
- Add CleverTap Account Id and Token in target `Info.plist` file as updated [here](https://github.com/CleverTap/clevertap-react-native/tree/master/Example/ios/Example/NotificationService/Info.plist)
|
|
55
|
+
- Update your `NotificationService.m` file as:
|
|
56
|
+
```
|
|
57
|
+
#import "NotificationService.h"
|
|
58
|
+
#import <CleverTap-iOS-SDK/CleverTap.h>
|
|
59
|
+
|
|
60
|
+
@implementation NotificationService
|
|
61
|
+
|
|
62
|
+
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
|
|
63
|
+
// Add CleverTap Account ID and Account token in your target .plist file
|
|
64
|
+
[CleverTap setDebugLevel:2];
|
|
65
|
+
NSDictionary *profile = @{
|
|
66
|
+
@"Name": @"testUserA1",
|
|
67
|
+
@"Identity": @123456,
|
|
68
|
+
@"Email": @"test@test.com"
|
|
69
|
+
};
|
|
70
|
+
[[CleverTap sharedInstance] profilePush:profile];
|
|
71
|
+
[[CleverTap sharedInstance] recordNotificationViewedEventWithData: request.content.userInfo];
|
|
72
|
+
|
|
73
|
+
[super didReceiveNotificationRequest:request withContentHandler:contentHandler];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@end
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
- Refer [example](https://github.com/CleverTap/clevertap-react-native/tree/master/Example/ios/Example/NotificationService) for more details if you are using Objective-C language for the target.
|
|
80
|
+
|
|
81
|
+
## Add Notification Service target using Swift language
|
|
82
|
+
- Go to File -> New -> Target -> Notification Service Extension and select Swift language
|
|
83
|
+
- Update Podfile as below and `pod install`:
|
|
84
|
+
```
|
|
85
|
+
target 'NotificationService' do
|
|
86
|
+
pod "CTNotificationService", :modular_headers => true
|
|
87
|
+
end
|
|
88
|
+
```
|
|
89
|
+
- Update your `NotificationService.swift` as
|
|
90
|
+
```
|
|
91
|
+
import CTNotificationService
|
|
92
|
+
|
|
93
|
+
class NotificationService: CTNotificationServiceExtension {
|
|
94
|
+
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
|
|
95
|
+
super.didReceive(request, withContentHandler: contentHandler)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Push Impression using Swift language target
|
|
101
|
+
- Add `pod "CleverTap-iOS-SDK" ` in podfile for notification service target and do `pod install` as
|
|
102
|
+
```
|
|
103
|
+
target 'NotificationService' do
|
|
104
|
+
pod "CleverTap-iOS-SDK", :modular_headers => true
|
|
105
|
+
pod "CTNotificationService", :modular_headers => true
|
|
106
|
+
end
|
|
107
|
+
```
|
|
108
|
+
- Add CleverTap Account Id and Token in target `Info.plist` file as updated [here](https://github.com/CleverTap/clevertap-react-native/tree/master/Example/ios/Example/NotificationService/Info.plist)
|
|
109
|
+
- Update your `NotificationService.swift` file as:
|
|
110
|
+
```
|
|
111
|
+
import CTNotificationService
|
|
112
|
+
import CleverTapSDK
|
|
113
|
+
|
|
114
|
+
class NotificationService: CTNotificationServiceExtension {
|
|
115
|
+
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
|
|
116
|
+
let profile: Dictionary<String, AnyObject> = [
|
|
117
|
+
"Name": "testUserA1" as AnyObject,
|
|
118
|
+
"Identity": 123456 as AnyObject,
|
|
119
|
+
"Email": "test@test.com" as AnyObject ]
|
|
120
|
+
CleverTap.sharedInstance()?.profilePush(profile)
|
|
121
|
+
CleverTap.sharedInstance()?.recordNotificationViewedEvent(withData: request.content.userInfo)
|
|
122
|
+
super.didReceive(request, withContentHandler: contentHandler)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
# Notification Content
|
|
128
|
+
|
|
129
|
+
[(Back to top)](#table-of-contents)
|
|
130
|
+
|
|
131
|
+
Add Notification Content Extension (Push Templates) in a React Native iOS Project
|
|
16
132
|
Notification Content Extension is an app extension that provides a custom interface when a user previews your notification in the notification center. To enable the functionality of CleverTap iOS Push templates, we need this extension in the project which act as subclass to our CTNotificationContent framework.
|
|
17
133
|
|
|
18
|
-
|
|
134
|
+
## Installation
|
|
135
|
+
- Open Example.xcodeproj (or your app’s .xcodeproj file) in the ios folder of React Native project.
|
|
136
|
+
- Go to File > New > Target… and search with the name “Notification Content Extension“
|
|
19
137
|
|
|
20
138
|

|
|
21
139
|
|
|
22
|
-
Add “Notification Content“ as target name.
|
|
140
|
+
- Add “Notification Content“ as target name.
|
|
23
141
|
|
|
24
142
|

|
|
25
143
|
|
|
26
|
-
Refer to https://github.com/CleverTap/CTNotificationContent#-setup for setting up Notification Content target so that it imports CTNotificationContent framework in the code. Make sure to add the necessary key-values in the Info.plist file of NotificationContent target so that it recognises the identifier of the incoming notification.
|
|
144
|
+
- Refer to https://github.com/CleverTap/CTNotificationContent#-setup for setting up Notification Content target so that it imports CTNotificationContent framework in the code. Make sure to add the necessary key-values in the Info.plist file of NotificationContent target so that it recognises the identifier of the incoming notification.
|
|
27
145
|
|
|
28
146
|
Alternatively, go to finder and replace newly created NotificationContent (or your content extension) folder with the NotificationContent folder in CTNotificationContent Example project repository.
|
|
29
147
|
|
|
30
148
|

|
|
31
149
|
|
|
32
|
-
Add the following to a file named Podfile in the ios directory of your project.
|
|
150
|
+
- Add the following to a file named Podfile in the ios directory of your project.
|
|
33
151
|
```
|
|
34
|
-
use_frameworks!
|
|
35
152
|
target 'NotificationContent' do
|
|
36
153
|
pod 'CTNotificationContent'
|
|
37
154
|
end
|
|
@@ -139,6 +256,22 @@ target 'reactnativedemo' do
|
|
|
139
256
|
end
|
|
140
257
|
```
|
|
141
258
|
|
|
259
|
+
- Edit the Maininterface.storyboard in your NotificationContent target to a plain UIView. Steps:
|
|
260
|
+
MainInterface.storyboard -> Expand View -> Click Label -> Delete
|
|
261
|
+
|
|
262
|
+

|
|
263
|
+
|
|
264
|
+
- Update NotificationViewController.h, NotificationViewController.m and Info.plist as updated in [example app](https://github.com/CleverTap/clevertap-react-native/tree/master/Example/ios/Example/NotificationContent)
|
|
265
|
+
- Set Notification categories from AppDelegate if you want to add category buttons in `didFinishLaunchingWithOptions:` method and add import `#import <UserNotifications/UserNotifications.h>`:
|
|
266
|
+
```
|
|
267
|
+
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
|
268
|
+
UNNotificationAction *action1 = [UNNotificationAction actionWithIdentifier:@"action_1" title:@"Back" options:UNNotificationActionOptionNone];
|
|
269
|
+
UNNotificationAction *action2 = [UNNotificationAction actionWithIdentifier:@"action_2" title:@"Next" options:UNNotificationActionOptionNone];
|
|
270
|
+
UNNotificationAction *action3 = [UNNotificationAction actionWithIdentifier:@"action_3" title:@"View In App" options:UNNotificationActionOptionNone];
|
|
271
|
+
UNNotificationCategory *cat = [UNNotificationCategory categoryWithIdentifier:@"CTNotification" actions:@[action1, action2, action3] intentIdentifiers:@[] options:UNNotificationCategoryOptionNone];
|
|
272
|
+
[center setNotificationCategories:[NSSet setWithObjects:cat, nil]];
|
|
273
|
+
```
|
|
274
|
+
|
|
142
275
|
### Out of the box
|
|
143
276
|
|
|
144
277
|
|
package/docs/usage.md
CHANGED
|
@@ -66,6 +66,41 @@ CleverTap.profileDecrementValueForKey(1, "score");
|
|
|
66
66
|
|
|
67
67
|
-----------
|
|
68
68
|
|
|
69
|
+
## Integrate Custom Proxy Domain
|
|
70
|
+
The custom proxy domain feature allows to proxy all events raised from the CleverTap SDK through your required domain,
|
|
71
|
+
ideal for handling or relaying CleverTap events and Push Impression events with your application server.
|
|
72
|
+
Refer following steps to configure the custom proxy domain(s) in the manifest file:
|
|
73
|
+
|
|
74
|
+
#### [Android Platform] Configure Custom Proxy Domain(s) using Manifest file
|
|
75
|
+
1. Add your CleverTap Account credentials in the Manifest file against the `CLEVERTAP_ACCOUNT_ID` and `CLEVERTAP_TOKEN` keys.
|
|
76
|
+
2. Add the **CLEVERTAP_PROXY_DOMAIN** key with the proxy domain value for handling events through the custom proxy domain.
|
|
77
|
+
3. Add the **CLEVERTAP_SPIKY_PROXY_DOMAIN** key with proxy domain value for handling push impression events.
|
|
78
|
+
|
|
79
|
+
```xml
|
|
80
|
+
<meta-data
|
|
81
|
+
android:name="CLEVERTAP_ACCOUNT_ID"
|
|
82
|
+
android:value="YOUR ACCOUNT ID" />
|
|
83
|
+
<meta-data
|
|
84
|
+
android:name="CLEVERTAP_TOKEN"
|
|
85
|
+
android:value="YOUR ACCOUNT TOKEN" />
|
|
86
|
+
<meta-data
|
|
87
|
+
android:name="CLEVERTAP_PROXY_DOMAIN"
|
|
88
|
+
android:value="YOUR PROXY DOMAIN"/> <!-- e.g., analytics.sdktesting.xyz -->
|
|
89
|
+
<meta-data
|
|
90
|
+
android:name="CLEVERTAP_SPIKY_PROXY_DOMAIN"
|
|
91
|
+
android:value="YOUR SPIKY PROXY DOMAIN"/> <!-- e.g., spiky-analytics.sdktesting.xyz -->
|
|
92
|
+
```
|
|
93
|
+
#### [iOS Platform] Configure Custom Proxy Domain(s) using `CleverTap.autoIntegrate()` API
|
|
94
|
+
1. Add your CleverTap Account credentials in the *Info.plist* file against the `CleverTapAccountID` and `CleverTapToken` keys.
|
|
95
|
+
2. Add the `CleverTapProxyDomain` key with the proxy domain value for handling events through the custom proxy domain e.g., *analytics.sdktesting.xyz*.
|
|
96
|
+
3. Add the `CleverTapSpikyProxyDomain` key with proxy domain value for handling push impression events e.g., *spiky-analytics.sdktesting.xyz*.
|
|
97
|
+
4. Import the CleverTap SDK in your *AppDelegate* file and call the following method in the `didFinishLaunchingWithOptions:` method.
|
|
98
|
+
``` swift
|
|
99
|
+
CleverTap.autoIntegrate()
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
-----------
|
|
103
|
+
|
|
69
104
|
## User Events
|
|
70
105
|
|
|
71
106
|
#### Record an event
|
|
@@ -120,7 +155,7 @@ CleverTap.initializeInbox();
|
|
|
120
155
|
```javascript
|
|
121
156
|
CleverTap.showInbox({'tabs':['Offers','Promotions'],'navBarTitle':'My App Inbox','navBarTitleColor':'#FF0000','navBarColor':'#FFFFFF','inboxBackgroundColor':'#AED6F1','backButtonColor':'#00FF00'
|
|
122
157
|
,'unselectedTabColor':'#0000FF','selectedTabColor':'#FF0000','selectedTabIndicatorColor':'#000000',
|
|
123
|
-
'noMessageText':'No message(s)','noMessageTextColor':'#FF0000'});
|
|
158
|
+
'noMessageText':'No message(s)','noMessageTextColor':'#FF0000','firstTabTitle':'First Tab' });
|
|
124
159
|
```
|
|
125
160
|
|
|
126
161
|
#### App Inbox Item Click Callback
|
package/index.d.ts
CHANGED
|
@@ -32,6 +32,12 @@
|
|
|
32
32
|
*/
|
|
33
33
|
export function getInitialUrl(callback: Callback): void;
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Call this method to set Locale. If Language is english and country is US the locale format which you can set is en_US
|
|
37
|
+
* @param locale {string}
|
|
38
|
+
*/
|
|
39
|
+
export function setLocale(locale: string): void;
|
|
40
|
+
|
|
35
41
|
/*******************
|
|
36
42
|
* Personalization
|
|
37
43
|
******************/
|
|
@@ -750,6 +756,21 @@ export function isPushPermissionGranted(callback: CallbackString): void;
|
|
|
750
756
|
*/
|
|
751
757
|
export function onValueChanged(name: string, handler: Function): void;
|
|
752
758
|
|
|
759
|
+
|
|
760
|
+
/**
|
|
761
|
+
* Fetches In Apps from server.
|
|
762
|
+
*
|
|
763
|
+
* @param {function(err, res)} callback a callback with a boolean flag whether the fetching was successful
|
|
764
|
+
*/
|
|
765
|
+
export function fetchInApps(callback: Callback): void;
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* Deletes all images and gifs which are preloaded for inapps in cs mode
|
|
769
|
+
*
|
|
770
|
+
* @param {boolean} expiredOnly to clear only assets which will not be needed further for inapps
|
|
771
|
+
*/
|
|
772
|
+
export function clearInAppResources(expiredOnly: boolean): void;
|
|
773
|
+
|
|
753
774
|
/*******************
|
|
754
775
|
* Developer Options
|
|
755
776
|
******************/
|
package/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const EventEmitter = NativeModules.CleverTapReactEventEmitter ? new NativeEventE
|
|
|
9
9
|
* @param {int} libVersion - The updated library version. If current version is 1.1.0 then pass as 10100
|
|
10
10
|
*/
|
|
11
11
|
const libName = 'React-Native';
|
|
12
|
-
const libVersion =
|
|
12
|
+
const libVersion = 20000;
|
|
13
13
|
CleverTapReact.setLibrary(libName,libVersion);
|
|
14
14
|
|
|
15
15
|
function defaultCallback(method, err, res) {
|
|
@@ -109,6 +109,14 @@ var CleverTap = {
|
|
|
109
109
|
callWithCallback('getInitialUrl', null, callback);
|
|
110
110
|
},
|
|
111
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Call this method to set Locale. If Language is english and country is US the locale format which you can set is en_US
|
|
114
|
+
* @param {string} locale - the locale string
|
|
115
|
+
*/
|
|
116
|
+
setLocale: function (locale) {
|
|
117
|
+
CleverTapReact.setLocale(locale);
|
|
118
|
+
},
|
|
119
|
+
|
|
112
120
|
/**
|
|
113
121
|
* Registers the application to receive push notifications
|
|
114
122
|
* only necessary for iOS.
|
|
@@ -941,6 +949,24 @@ var CleverTap = {
|
|
|
941
949
|
onValueChanged: function (name, handler) {
|
|
942
950
|
CleverTapReact.onValueChanged(name);
|
|
943
951
|
this.addListener(CleverTapReact.CleverTapOnValueChanged, handler);
|
|
952
|
+
},
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* Fetches In Apps from server.
|
|
956
|
+
*
|
|
957
|
+
* @param callback {function(err, res)} a callback with a boolean flag whether the update was successful
|
|
958
|
+
*/
|
|
959
|
+
fetchInApps: function (callback) {
|
|
960
|
+
callWithCallback('fetchInApps', null, callback);
|
|
961
|
+
},
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* Deletes all images and gifs which are preloaded for inapps in cs mode
|
|
965
|
+
*
|
|
966
|
+
* @param {boolean} expiredOnly to clear only assets which will not be needed further for inapps
|
|
967
|
+
*/
|
|
968
|
+
clearInAppResources: function(expiredOnly) {
|
|
969
|
+
CleverTapReact.clearInAppResources(expiredOnly);
|
|
944
970
|
}
|
|
945
971
|
};
|
|
946
972
|
|
|
@@ -119,6 +119,12 @@ RCT_EXPORT_METHOD(setLibrary:(NSString*)name andVersion:(int)version) {
|
|
|
119
119
|
[[self cleverTapInstance] setCustomSdkVersion:name version:version];
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
RCT_EXPORT_METHOD(setLocale:(NSString*)locale) {
|
|
123
|
+
RCTLogInfo(@"[CleverTap setLocale:%@]", locale);
|
|
124
|
+
NSLocale *userLocale = [NSLocale localeWithLocaleIdentifier:locale];
|
|
125
|
+
[[self cleverTapInstance] setLocale:userLocale];
|
|
126
|
+
}
|
|
127
|
+
|
|
122
128
|
#pragma mark - Push Notifications
|
|
123
129
|
|
|
124
130
|
RCT_EXPORT_METHOD(registerForPush) {
|
|
@@ -628,11 +634,16 @@ RCT_EXPORT_METHOD(initializeInbox) {
|
|
|
628
634
|
|
|
629
635
|
RCT_EXPORT_METHOD(showInbox:(NSDictionary*)styleConfig) {
|
|
630
636
|
RCTLogInfo(@"[CleverTap Show Inbox]");
|
|
637
|
+
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
|
|
638
|
+
UIViewController *mainViewController = keyWindow.rootViewController;
|
|
639
|
+
if (mainViewController.presentedViewController) {
|
|
640
|
+
RCTLogInfo(@"CleverTap : Could not present App Inbox because a view controller is already being presented.");
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
|
|
631
644
|
CleverTapInboxViewController *inboxController = [[self cleverTapInstance] newInboxViewControllerWithConfig:[self _dictToInboxStyleConfig:styleConfig? styleConfig : nil] andDelegate:(id <CleverTapInboxViewControllerDelegate>)self];
|
|
632
645
|
if (inboxController) {
|
|
633
646
|
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:inboxController];
|
|
634
|
-
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
|
|
635
|
-
UIViewController *mainViewController = keyWindow.rootViewController;
|
|
636
647
|
[mainViewController presentViewController:navigationController animated:YES completion:nil];
|
|
637
648
|
}
|
|
638
649
|
}
|
|
@@ -683,6 +694,10 @@ RCT_EXPORT_METHOD(showInbox:(NSDictionary*)styleConfig) {
|
|
|
683
694
|
if (noMessageText) {
|
|
684
695
|
_config.noMessageViewText = noMessageText;
|
|
685
696
|
}
|
|
697
|
+
NSString *firstTabTitle = [dict valueForKey:@"firstTabTitle"];
|
|
698
|
+
if (firstTabTitle) {
|
|
699
|
+
_config.firstTabTitle = firstTabTitle;
|
|
700
|
+
}
|
|
686
701
|
return _config;
|
|
687
702
|
}
|
|
688
703
|
- (UIColor *)ct_colorWithHexString:(NSString *)string alpha:(CGFloat)alpha{
|
|
@@ -842,6 +857,20 @@ RCT_EXPORT_METHOD(resumeInAppNotifications) {
|
|
|
842
857
|
[[self cleverTapInstance] resumeInAppNotifications];
|
|
843
858
|
}
|
|
844
859
|
|
|
860
|
+
#pragma mark - InApp Controls
|
|
861
|
+
|
|
862
|
+
RCT_EXPORT_METHOD(fetchInApps:(RCTResponseSenderBlock)callback) {
|
|
863
|
+
RCTLogInfo(@"[CleverTap fetchInApps]");
|
|
864
|
+
[[self cleverTapInstance]fetchInApps:^(BOOL success) {
|
|
865
|
+
[self returnResult:@(success) withCallback:callback andError:nil];
|
|
866
|
+
}];
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
RCT_EXPORT_METHOD(clearInAppResources:(BOOL)expiredOnly) {
|
|
870
|
+
RCTLogInfo(@"[CleverTap clearInAppResources");
|
|
871
|
+
[[self cleverTapInstance] clearInAppResources: expiredOnly];
|
|
872
|
+
}
|
|
873
|
+
|
|
845
874
|
#pragma mark - Push Permission
|
|
846
875
|
|
|
847
876
|
- (CTLocalInApp*)_localInAppConfigFromReadableMap: (NSDictionary *)json {
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clevertap-react-native",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "CleverTap React Native SDK.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
|
-
"postinstall": "node install.js",
|
|
10
9
|
"lint": "./node_modules/.bin/eslint index.js */**.js",
|
|
11
10
|
"lint-fix": "./node_modules/.bin/eslint --fix index.js */**.js"
|
|
12
11
|
},
|
|
@@ -32,9 +31,6 @@
|
|
|
32
31
|
"react-native",
|
|
33
32
|
"segmentation"
|
|
34
33
|
],
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"extract-zip": "^1.6.6"
|
|
37
|
-
},
|
|
38
34
|
"peerDependencies": {
|
|
39
35
|
"react-native": ">=0.63.3"
|
|
40
36
|
},
|
|
Binary file
|
|
Binary file
|
package/install.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const fs = require('fs')
|
|
4
|
-
const path = require('path')
|
|
5
|
-
const extract = require('extract-zip')
|
|
6
|
-
|
|
7
|
-
const sdkPath = path.join(__dirname, 'ios/CleverTapReact/');
|
|
8
|
-
const zipFile = sdkPath+'CleverTapSDK.framework.zip';
|
|
9
|
-
const errMsg = "error unzipping CleverTapSDK.framework.zip in " + sdkPath + " please unzip manually";
|
|
10
|
-
|
|
11
|
-
fs.access(zipFile, (err) => {
|
|
12
|
-
if (!err) {
|
|
13
|
-
extract(zipFile, {dir: sdkPath}, function (err) {
|
|
14
|
-
if (!err) {
|
|
15
|
-
fs.unlinkSync(zipFile);
|
|
16
|
-
} else {
|
|
17
|
-
console.log(err);
|
|
18
|
-
console.error(errMsg);
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
} else {
|
|
22
|
-
console.error(err);
|
|
23
|
-
}
|
|
24
|
-
});
|