clevertap-react-native 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,31 @@
1
1
  Change Log
2
2
  ==========
3
3
 
4
+ Version 1.2.1 *(25 October 2023)*
5
+ -------------------------------------------
6
+ **What's new**
7
+ * **[Android Platform]**
8
+ * Supports [CleverTap Android SDK v5.2.1](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md#version-521-october-12-2023).
9
+ * 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.
10
+
11
+ * **[iOS Platform]**
12
+ * Supports [CleverTap iOS SDK v5.2.1](https://github.com/CleverTap/clevertap-ios-sdk/releases/tag/5.2.1).
13
+ * Adds support to enable `NSFileProtectionComplete` to secure App’s document directory.
14
+
15
+ * **[Android and iOS Platform]**
16
+ * 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.
17
+ * Adds support for Integration Debugger to view errors and events on the dashboard when the debugLevel is set to 3 using `CleverTapPlugin.setDebugLevel(3)`.
18
+ * Adds support to configure first tab title in App Inbox.
19
+
20
+ **Changes**
21
+ * **[iOS Platform]**
22
+ * 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).
23
+ * Updated logic to not send carrier name above iOS 16 in CTCarrier field.
24
+
25
+ **Bug Fixes**
26
+ * **[iOS Platform]**
27
+ * Fixes a crash in iOS 17/Xcode 15 related to alert inapps.
28
+
4
29
  Version 1.2.0 *(18th August 2023)*
5
30
  -------------------------------------------
6
31
 
@@ -21,8 +21,8 @@ android {
21
21
  defaultConfig {
22
22
  minSdkVersion 19
23
23
  targetSdkVersion 33
24
- versionCode 120
25
- versionName "1.2.0"
24
+ versionCode 121
25
+ versionName "1.2.1"
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:5.2.0'
42
+ api 'com.clevertap.android:clevertap-android-sdk:5.2.1'
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:+'
@@ -177,6 +177,16 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
177
177
  cleverTap.setCustomSdkVersion(libName,libVersion);
178
178
  }
179
179
  }
180
+
181
+ @ReactMethod
182
+ private void setLocale(String locale) {
183
+ CleverTapAPI cleverTap = getCleverTapAPI();
184
+ if (cleverTap != null) {
185
+ cleverTap.setLocale(locale);
186
+ } else {
187
+ Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage());
188
+ }
189
+ }
180
190
 
181
191
  @ReactMethod
182
192
  public void activate() {
@@ -1998,6 +2008,10 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
1998
2008
  String noMessageTitleColor = styleConfig.getString(styleConfigKey);
1999
2009
  ctInboxStyleConfig.setNoMessageViewTextColor(noMessageTitleColor);
2000
2010
  }
2011
+ if ("firstTabTitle".equals(styleConfigKey) && readableType == ReadableType.String) {
2012
+ String firstTabTitle = styleConfig.getString(styleConfigKey);
2013
+ ctInboxStyleConfig.setFirstTabTitle(firstTabTitle);
2014
+ }
2001
2015
 
2002
2016
  } catch (Throwable t) {
2003
2017
  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', '5.2.0'
21
+ s.dependency 'CleverTap-iOS-SDK', '5.2.1'
22
22
  s.dependency 'React-Core'
23
23
  end
@@ -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
- - [Installation](#installation)
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
- # Installation
13
+ # Notification Service
13
14
 
14
15
  [(Back to top)](#table-of-contents)
15
- - Add Notification Content Extension (Push Templates) in a React Native iOS Project
16
+ ## Installation
17
+ - Go to File -> New -> Target -> Notification Service Extension and select Objective-C language
18
+
19
+ ![NotificationServiceTarget](https://github.com/CleverTap/clevertap-react-native/blob/master/static/NotificationServiceTarget.png)
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
- Open Example.xcodeproj (or your app’s .xcodeproj file) in the ios folder of React Native project. Go to File > New > Target… and search with the name “Notification Content Extension“
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
  ![NotificationContentTarget](https://github.com/CleverTap/clevertap-react-native/blob/task/SDK-2395-RN-pushtemplates-support/static/NotificationContentTarget.png)
21
139
 
22
- Add “Notification Content“ as target name.
140
+ - Add “Notification Content“ as target name.
23
141
 
24
142
  ![NotificationContent](https://github.com/CleverTap/clevertap-react-native/blob/task/SDK-2395-RN-pushtemplates-support/static/NotificationContent.png)
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
  ![Finder](https://github.com/CleverTap/clevertap-react-native/blob/task/SDK-2395-RN-pushtemplates-support/static/Finder.png)
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
+ ![NotificationContentStoryboard](https://github.com/CleverTap/clevertap-react-native/blob/master/static/NotificationContentStoryboard.png)
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
  ******************/
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 = 10200;
12
+ const libVersion = 10201;
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.
@@ -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) {
@@ -683,6 +689,10 @@ RCT_EXPORT_METHOD(showInbox:(NSDictionary*)styleConfig) {
683
689
  if (noMessageText) {
684
690
  _config.noMessageViewText = noMessageText;
685
691
  }
692
+ NSString *firstTabTitle = [dict valueForKey:@"firstTabTitle"];
693
+ if (firstTabTitle) {
694
+ _config.firstTabTitle = firstTabTitle;
695
+ }
686
696
  return _config;
687
697
  }
688
698
  - (UIColor *)ct_colorWithHexString:(NSString *)string alpha:(CGFloat)alpha{
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "self:">
6
+ </FileRef>
7
+ </Workspace>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>IDEDidComputeMac32BitWarning</key>
6
+ <true/>
7
+ </dict>
8
+ </plist>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>SchemeUserState</key>
6
+ <dict>
7
+ <key>CleverTapReact.xcscheme_^#shared#^_</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>0</integer>
11
+ </dict>
12
+ </dict>
13
+ </dict>
14
+ </plist>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clevertap-react-native",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "CleverTap React Native SDK.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
File without changes
@@ -1,2 +0,0 @@
1
- #Wed May 24 10:54:09 IST 2023
2
- gradle.version=6.1.1
File without changes