clevertap-react-native 0.9.3 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +5 -0
  3. package/android/.gradle/6.1.1/executionHistory/executionHistory.lock +0 -0
  4. package/android/.gradle/6.1.1/fileChanges/last-build.bin +0 -0
  5. package/android/.gradle/6.1.1/fileHashes/fileHashes.lock +0 -0
  6. package/android/.gradle/6.1.1/gc.properties +0 -0
  7. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  8. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  9. package/android/.gradle/checksums/checksums.lock +0 -0
  10. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  11. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  12. package/android/.gradle/vcs-1/gc.properties +0 -0
  13. package/android/src/main/java/com/clevertap/react/CleverTapModule.java +27 -11
  14. package/clevertap-react-native.podspec +1 -1
  15. package/docs/iospushtemplates.md +449 -0
  16. package/index.d.ts +12 -0
  17. package/index.js +10 -0
  18. package/ios/CleverTapReact/CleverTapReact.m +94 -63
  19. package/ios/CleverTapReact/CleverTapReactEventEmitter.h +0 -1
  20. package/ios/CleverTapReact/CleverTapReactEventEmitter.m +0 -2
  21. package/ios/CleverTapReact/CleverTapReactManager.h +3 -0
  22. package/ios/CleverTapReact/CleverTapReactManager.m +11 -10
  23. package/ios/CleverTapReact.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  24. package/ios/CleverTapReact.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  25. package/ios/CleverTapReact.xcodeproj/project.xcworkspace/xcuserdata/akash.malhotra.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  26. package/ios/CleverTapReact.xcodeproj/xcuserdata/akash.malhotra.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  27. package/package.json +1 -1
  28. package/static/Finder.png +0 -0
  29. package/static/GenerateSpecs.png +0 -0
  30. package/static/NotificationContent.png +0 -0
  31. package/static/NotificationContentTarget.png +0 -0
  32. package/android/local.properties +0 -8
package/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  Change Log
2
2
  ==========
3
3
 
4
+ Version 0.9.4 *(28 November 2022)*
5
+ -------------------------------------------
6
+ - Supports [CleverTap iOS SDK v4.1.5](https://github.com/CleverTap/clevertap-ios-sdk/blob/master/CHANGELOG.md#version-415-november-15-2022)
7
+ - Supports `setInstanceWithAccountId` method
8
+ - Supports using specific CleverTap instance
9
+
10
+
4
11
  Version 0.9.3 *(1 November 2022)*
5
12
  -------------------------------------------
6
13
  - Supports CleverTap Android Core SDK [v4.6.6](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md) and associated enhancements
package/README.md CHANGED
@@ -25,6 +25,11 @@ To get started, sign up [here](https://clevertap.com/live-product-demo/).
25
25
  - [CleverTap iOS SDK Integration guide](https://support.clevertap.com/docs/ios/getting-started.html)
26
26
  - [CleverTap Android SDK Integration guide](https://support.clevertap.com/docs/android/getting-started.html)
27
27
 
28
+ ## 📲 CleverTap iOS Push Templates SDK
29
+
30
+ CleverTap Push Templates SDK helps you engage with your users using fancy push notification templates built specifically to work with [CleverTap Push Templates SDK](https://github.com/CleverTap/CTNotificationContent).
31
+ Find the integration steps for the CleverTap Push Templates SDK [here](./docs/iospushtemplates.md)
32
+
28
33
  ## 📑 Documentation & Example
29
34
 
30
35
  - [See the CleverTap React Native Usage Documentation](/docs/usage.md)
File without changes
@@ -0,0 +1,2 @@
1
+ #Wed Sep 28 11:39:15 IST 2022
2
+ gradle.version=6.1.1
File without changes
@@ -1373,21 +1373,25 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
1373
1373
  return props;
1374
1374
  }
1375
1375
 
1376
+ private void registerListeners(CleverTapAPI clevertap) {
1377
+ clevertap.setCTPushNotificationListener(this);
1378
+ clevertap.setInAppNotificationListener(this);
1379
+ clevertap.setSyncListener(this);
1380
+ clevertap.setCTNotificationInboxListener(this);
1381
+ clevertap.setInboxMessageButtonListener(this);
1382
+ clevertap.setCTInboxMessageListener(this);
1383
+ clevertap.setInAppNotificationButtonListener(this);
1384
+ clevertap.setDisplayUnitListener(this);
1385
+ clevertap.setCTProductConfigListener(this);
1386
+ clevertap.setCTFeatureFlagsListener(this);
1387
+ clevertap.setLibrary("React-Native");
1388
+ }
1389
+
1376
1390
  private CleverTapAPI getCleverTapAPI() {
1377
1391
  if (mCleverTap == null) {
1378
1392
  CleverTapAPI clevertap = CleverTapAPI.getDefaultInstance(this.context);
1379
1393
  if (clevertap != null) {
1380
- clevertap.setCTPushNotificationListener(this);
1381
- clevertap.setInAppNotificationListener(this);
1382
- clevertap.setSyncListener(this);
1383
- clevertap.setCTNotificationInboxListener(this);
1384
- clevertap.setInboxMessageButtonListener(this);
1385
- clevertap.setCTInboxMessageListener(this);
1386
- clevertap.setInAppNotificationButtonListener(this);
1387
- clevertap.setDisplayUnitListener(this);
1388
- clevertap.setCTProductConfigListener(this);
1389
- clevertap.setCTFeatureFlagsListener(this);
1390
- clevertap.setLibrary("React-Native");
1394
+ registerListeners(clevertap);
1391
1395
  }
1392
1396
  mCleverTap = clevertap;
1393
1397
  }
@@ -1395,6 +1399,18 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
1395
1399
  return mCleverTap;
1396
1400
  }
1397
1401
 
1402
+ @ReactMethod
1403
+ public void setInstanceWithAccountId(String accountId) {
1404
+ if (mCleverTap == null || !accountId.equals(mCleverTap.getAccountId())) {
1405
+ CleverTapAPI cleverTap = CleverTapAPI.getGlobalInstance(this.context, accountId);
1406
+ if (cleverTap != null) {
1407
+ registerListeners(cleverTap);
1408
+ mCleverTap = cleverTap;
1409
+ Log.i(TAG, "CleverTap instance changed for accountId " + accountId);
1410
+ }
1411
+ }
1412
+ }
1413
+
1398
1414
  private CTProductConfigController getCtProductConfigController() {
1399
1415
  CleverTapAPI clevertap = getCleverTapAPI();
1400
1416
  if (clevertap == null) {
@@ -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', '4.1.2'
21
+ s.dependency 'CleverTap-iOS-SDK', '4.1.5'
22
22
  s.dependency 'React-Core'
23
23
  end
@@ -0,0 +1,449 @@
1
+ # iOS Push Templates integration with React Native
2
+
3
+ CleverTap Push Templates SDK helps you engage with your users using fancy push notification templates built specifically to work with [CleverTap](https://eu1.dashboard.clevertap.com/login.html).
4
+
5
+ # Table of contents
6
+
7
+ - [Installation](#installation)
8
+ - [Dashboard Usage](#dashboard-usage)
9
+ - [Template Types](#template-types)
10
+ - [Template Keys](#template-keys)
11
+
12
+ # Installation
13
+
14
+ [(Back to top)](#table-of-contents)
15
+ - Add Notification Content Extension (Push Templates) in a React Native iOS Project
16
+ 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
+
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“
19
+
20
+ ![NotificationContentTarget](https://github.com/CleverTap/clevertap-react-native/blob/task/SDK-2395-RN-pushtemplates-support/static/NotificationContentTarget.png)
21
+
22
+ Add “Notification Content“ as target name.
23
+
24
+ ![NotificationContent](https://github.com/CleverTap/clevertap-react-native/blob/task/SDK-2395-RN-pushtemplates-support/static/NotificationContent.png)
25
+
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.
27
+
28
+ Alternatively, go to finder and replace newly created NotificationContent (or your content extension) folder with the NotificationContent folder in CTNotificationContent Example project repository.
29
+
30
+ ![Finder](https://github.com/CleverTap/clevertap-react-native/blob/task/SDK-2395-RN-pushtemplates-support/static/Finder.png)
31
+
32
+ Add the following to a file named Podfile in the ios directory of your project.
33
+ ```
34
+ use_frameworks!
35
+ target 'NotificationContent' do
36
+ pod 'CTNotificationContent'
37
+ end
38
+ ```
39
+
40
+ The final Podfile should look something like this:
41
+ ```
42
+ require_relative '../node_modules/react-native/scripts/react_native_pods'
43
+ require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
44
+
45
+ platform :ios, '10.0'
46
+
47
+ use_frameworks!
48
+ target 'NotificationContent' do
49
+ pod 'CTNotificationContent'
50
+ end
51
+
52
+ target 'Example' do
53
+
54
+ config = use_native_modules!
55
+
56
+ use_react_native!(:path => config["reactNativePath"])
57
+
58
+ pod 'RNReanimated', :path => '../node_modules/react-native-reanimated'
59
+ pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'
60
+
61
+ post_install do |installer|
62
+ react_native_post_install(installer)
63
+ # Apple Silicon builds require a library path tweak for Swift library discovery or "symbol not found" for swift things
64
+ installer.aggregate_targets.each do |aggregate_target|
65
+ aggregate_target.user_project.native_targets.each do |target|
66
+ target.build_configurations.each do |config|
67
+ config.build_settings['LIBRARY_SEARCH_PATHS'] = ['$(SDKROOT)/usr/lib/swift', '$(inherited)']
68
+ end
69
+ end
70
+ aggregate_target.user_project.save
71
+ end
72
+ end
73
+ end
74
+ ```
75
+ Now run the command pod install again. This will download and configure CTNotificationContent(iOS push templates) in your project.
76
+ ```
77
+ For React Native 0.69 or below you need to change the build phase order so that React Native can use the iOS framework added with the help of podfile
78
+ Please check your React-Native version of the project before proceeding further. Go to package.json file in your project and check react-native key and check for the version.
79
+
80
+ If the react native version of your project is below 0.69 you need to drag the Generate Specs above Headers as explained below.
81
+ ```
82
+ ## For React Native version 0.69 or below:
83
+
84
+ Open Example.xcworkspace (or your app’s .xcworkspace file). Go to the Pods section in Xcode -> select FBReactNativeSpec -> Build Phases -> drag Generate Specs above Headers .
85
+ ![GenerateSpecs](https://github.com/CleverTap/clevertap-react-native/blob/task/SDK-2395-RN-pushtemplates-support/static/GenerateSpecs.png)
86
+
87
+ ## For React Native version 0.70 or above:
88
+
89
+ We must disable "hermes" and "flipper" from the Podfile since we are using use_frameworks and this causes build issues if both of them are enabled.
90
+
91
+ Please observe that hermes_enabled is set from its default true state to false by adding :hermes_enabled => false inside use_react_native! snippet.
92
+ The podfile mentions this in comments:
93
+ ```
94
+ Note that if you have use_frameworks! enabled, Flipper will not work and
95
+ # you should disable the next line.
96
+ ```
97
+ so we have added a # to comment the line
98
+ ```
99
+ :flipper_configuration => FlipperConfiguration.enabled
100
+ ```
101
+ The new Podfile should look like this:
102
+ ```
103
+ require_relative '../node_modules/react-native/scripts/react_native_pods'
104
+ require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
105
+ platform :ios, '12.4'
106
+ install! 'cocoapods', :deterministic_uuids => false
107
+ use_frameworks!
108
+ target 'NotificationContent' do
109
+ pod 'CTNotificationContent'
110
+ end
111
+ target 'reactnativedemo' do
112
+ config = use_native_modules!
113
+ # Flags change depending on the env values.
114
+ flags = get_default_flags()
115
+ use_react_native!(
116
+ :path => config[:reactNativePath],
117
+ # Hermes is now enabled by default. Disable by setting this flag to false.
118
+ # Upcoming versions of React Native may rely on get_default_flags(), but
119
+ # we make it explicit here to aid in the React Native upgrade process.
120
+ :hermes_enabled => false,
121
+ :fabric_enabled => flags[:fabric_enabled],
122
+ # Enables Flipper.
123
+ #
124
+ # Note that if you have use_frameworks! enabled, Flipper will not work and
125
+ # you should disable the next line.
126
+ # :flipper_configuration => FlipperConfiguration.enabled,
127
+ # An absolute path to your application root.
128
+ :app_path => "#{Pod::Config.instance.installation_root}/.."
129
+ )
130
+ post_install do |installer|
131
+ react_native_post_install(
132
+ installer,
133
+ # Set `mac_catalyst_enabled` to `true` in order to apply patches
134
+ # necessary for Mac Catalyst builds
135
+ :mac_catalyst_enabled => false
136
+ )
137
+ __apply_Xcode_12_5_M1_post_install_workaround(installer)
138
+ end
139
+ end
140
+ ```
141
+
142
+ ### Out of the box
143
+
144
+
145
+ # Dashboard Usage
146
+
147
+ [(Back to top)](#table-of-contents)
148
+ While creating a Push Notification campaign on CleverTap, just follow the steps below -
149
+
150
+ 1. On the "WHAT" section pass the desired required values in the "title" and "message" fields (NOTE: These are iOS alert title and body).
151
+ ![Dashboard alert](https://github.com/CleverTap/CTNotificationContent/blob/master/images/dashboard_alert.png)
152
+ 2. Click on "Advanced" and then click on "Rich Media" and select Single or Carousel template.
153
+ ![Dashboard Rich Media](https://github.com/CleverTap/CTNotificationContent/blob/master/images/dashboard_richMedia.png)
154
+ 3. For adding custom key-value pair, add the [template Keys](#template-keys) individually or into one JSON object and use the `pt_json` key to fill in the values.
155
+ ![Dashboard Custom Key individual](https://github.com/CleverTap/CTNotificationContent/blob/master/images/dashboard_customKeysIndividual.png)
156
+ ![Dashboard Custom Key JSON](https://github.com/CleverTap/CTNotificationContent/blob/master/images/dashboard_customKeyValue.png)
157
+ 4. Send a test push and schedule!
158
+
159
+ # Template Types
160
+
161
+ [(Back to top)](#table-of-contents)
162
+
163
+ ## Rich Media
164
+ ### Single Media
165
+ Single media is for basic view with single image.
166
+ ![Single Media](https://github.com/CleverTap/CTNotificationContent/blob/master/images/SingleMedia.png)
167
+
168
+ ### Content Slider
169
+ Content Slider is for image slideshow view where user can add multiple images with different captions, sub-captions, and actions.
170
+
171
+ <img src="https://github.com/CleverTap/CTNotificationContent/blob/master/images/ContentSlider.gif" alt="Content slider" width="450" height="800"/>
172
+
173
+ ## Custom key-value pair
174
+
175
+ ### Basic Template
176
+ Basic Template is the basic push notification received on apps where user can also update text colour, background colour.
177
+
178
+ ![Custom Basic template](https://github.com/CleverTap/CTNotificationContent/blob/master/images/CustomBasicTemplate.png)
179
+
180
+ ### Auto Carousel Template
181
+ Auto carousel is an automatic revolving carousel push notification where user can also update text colour, background colour.
182
+
183
+ <img src="https://github.com/CleverTap/CTNotificationContent/blob/master/images/CustomAutoCarousel.gif" alt="Auto carousel" width="450" height="800"/>
184
+
185
+ ### Manual Carousel Template
186
+ This is the manual version of the carousel. The user can navigate to the next/previous image by clicking on the Next/Back buttons.
187
+ ---
188
+ **NOTE:**
189
+
190
+ For iOS 12 and above, you need to configure your Notification Content target Info.plist to reflect the category identifier you registered: `NSExtension -> NSExtensionAttributes -> UNNotificationExtensionCategory`. In addition, set the `UNNotificationExtensionInitialContentSizeRatio -> 0.1` , `UNNotificationExtensionDefaultContentHidden -> true` and `UNNotificationExtensionUserInteractionEnabled -> 1`.
191
+
192
+ For iOS 11 and below, the previous/next buttons will not work. Please use notification actions with identifiers `action_1` and `action_2` for this purpose.
193
+
194
+ ---
195
+
196
+ <img src="https://github.com/CleverTap/CTNotificationContent/blob/master/images/CustomManualCarousel.gif" alt="Manual carousel" width="450" height="800"/>
197
+
198
+ ### Timer Template
199
+ This template features a live countdown timer. You can even choose to show different title, message, and background image after the timer expires.
200
+
201
+ <img src="https://github.com/CleverTap/CTNotificationContent/blob/master/images/CustomTimerTemplate.gif" alt="Timer template" width="450" height="800"/>
202
+
203
+ ### Zero Bezel Template
204
+
205
+ The Zero Bezel template ensures that the background image covers the entire available surface area of the push notification. All the text is overlayed on the image.
206
+
207
+ ![Zero Bezel template](https://github.com/CleverTap/CTNotificationContent/blob/master/images/ZeroBezel.png)
208
+
209
+ ### Rating Template
210
+
211
+ Rating template lets your users give you feedback.
212
+
213
+ **NOTE:**
214
+
215
+ For iOS 12 and above, you need to configure your Notification Content target Info.plist to reflect the category identifier you registered: `NSExtension -> NSExtensionAttributes -> UNNotificationExtensionCategory`. In addition, set the `UNNotificationExtensionInitialContentSizeRatio -> 0.1` , `UNNotificationExtensionDefaultContentHidden -> true` and `UNNotificationExtensionUserInteractionEnabled -> 1`.
216
+ For iOS 11 and below, it will fallback to a basic template.
217
+
218
+ ---
219
+
220
+ ![Rating](https://github.com/CleverTap/CTNotificationContent/blob/master/images/Rating.gif)
221
+
222
+ ### Product Catalog Template
223
+
224
+ Product catalog template lets you show case different images of a product (or a product catalog) before the user can decide to click on the "BUY NOW" option which can take them directly to the product via deep links. This template has two variants.
225
+
226
+ **NOTE:**
227
+
228
+ For iOS 12 and above, you need to configure your Notification Content target Info.plist to reflect the category identifier you registered: `NSExtension -> NSExtensionAttributes -> UNNotificationExtensionCategory`. In addition, set the `UNNotificationExtensionInitialContentSizeRatio -> 0.1` , `UNNotificationExtensionDefaultContentHidden -> true` and `UNNotificationExtensionUserInteractionEnabled -> 1`.
229
+ For iOS 11 and below, it will fallback to a basic template.
230
+
231
+ ---
232
+
233
+ ### Vertical View
234
+
235
+ ![Product Display](https://github.com/CleverTap/CTNotificationContent/blob/master/images/ProductDisplayVertical.gif)
236
+
237
+ ### Linear View
238
+
239
+ Use the following keys to enable linear view variant of this template.
240
+
241
+ Template Key | Required | Value
242
+ ---:|:---:|:---
243
+ pt_product_display_linear | Optional | `true`
244
+
245
+ ![Product Display](https://github.com/CleverTap/CTNotificationContent/blob/master/images/ProductDisplayLinear.gif)
246
+
247
+ ### WebView Template
248
+
249
+ WebView template lets you load a remote https URL.
250
+
251
+ ![WebView Template](https://github.com/CleverTap/CTNotificationContent/blob/master/images/WebView.gif)
252
+
253
+ **Note:** If any image can't be downloaded, the template falls back to basic template with caption and sub caption only.
254
+
255
+ # Template Keys
256
+
257
+ [(Back to top)](#table-of-contents)
258
+
259
+ ## Rich Media
260
+ ### Content Slider
261
+ Configure your APNS payload:
262
+
263
+ Then, when sending notifications via [APNS](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/APNSOverview.html):
264
+ - include the mutable-content flag in your payload aps entry (this key must be present in the aps payload or the system will not call your app extension)
265
+ - for the Image Slideshow view, add the `ct_ContentSlider` key with a json object value, see example below, to the payload, outside of the aps entry.
266
+
267
+
268
+
269
+ ```
270
+ {
271
+
272
+ "aps": {
273
+ "alert": {
274
+ "body": "test message",
275
+ "title": "test title",
276
+ },
277
+ "category": "CTNotification",
278
+ "mutable-content": true,
279
+ },
280
+ "ct_ContentSlider": {
281
+ "orientation": "landscape", // landscape assumes 16:9 images, remove to display default square/portrait images
282
+ "showsPaging": true, // optional to display UIPageControl
283
+ "autoPlay": true, // optional to auto play the slideshow
284
+ "autoDismiss": true, // optional to auto dismiss the notification on item actionUrl launch
285
+ "items":[
286
+ {
287
+ "caption": "caption one",
288
+ "subcaption": "subcaption one",
289
+ "imageUrl": "https://s3.amazonaws.com/ct-demo-images/landscape-1.jpg",
290
+ "actionUrl": "com.clevertap.ctcontent.example://item/one"
291
+ },
292
+ {
293
+ "caption": "caption two",
294
+ "subcaption": "subcaption two",
295
+ "imageUrl": "https://s3.amazonaws.com/ct-demo-images/landscape-2.jpg",
296
+ "actionUrl": "com.clevertap.ctcontent.example://item/two"
297
+ }
298
+ ]
299
+ }
300
+ }
301
+ ```
302
+ ## Custom key-value pair
303
+
304
+ ### Basic Template
305
+ Basic Template Keys | Required | Description
306
+ ---:|:---:|:---|
307
+ pt_id | Required | Value - `pt_basic`
308
+ pt_title | Required | Title
309
+ pt_msg | Required | Message
310
+ pt_msg_summary | Required | Message line when Notification is expanded
311
+ pt_bg | Required | Background Color in HEX
312
+ pt_big_img | Optional | Image
313
+ pt_dl1 | Optional | One Deep Link
314
+ pt_title_clr | Optional | Title Color in HEX
315
+ pt_msg_clr | Optional | Message Color in HEX
316
+ pt_json | Optional | Above keys in JSON format
317
+
318
+ ### Auto Carousel Template
319
+
320
+ Auto Carousel Template Keys | Required | Description
321
+ ---:|:---:|:---
322
+ pt_id | Required | Value - `pt_carousel`
323
+ pt_title | Required | Title
324
+ pt_msg | Required | Message
325
+ pt_msg_summary | Optional | Message line when Notification is expanded
326
+ pt_dl1 | Required | Deep Link
327
+ pt_img1 | Required | Image One
328
+ pt_img2 | Required | Image Two
329
+ pt_img3 | Required | Image Three
330
+ pt_bg | Required | Background Color in HEX
331
+ pt_title_clr | Optional | Title Color in HEX
332
+ pt_msg_clr | Optional | Message Color in HEX
333
+ pt_json | Optional | Above keys in JSON format
334
+
335
+ ### Manual Carousel Template
336
+
337
+ Manual Carousel Template Keys | Required | Description
338
+ ---:|:---:|:---
339
+ pt_id | Required | Value - `pt_manual_carousel`
340
+ pt_title | Required | Title
341
+ pt_msg | Required | Message
342
+ pt_msg_summary | Optional | Message line when Notification is expanded
343
+ pt_dl1 | Required | Deep Link One
344
+ pt_img1 | Required | Image One
345
+ pt_img2 | Required | Image Two
346
+ pt_img3 | Required | Image Three
347
+ pt_bg | Required | Background Color in HEX
348
+ pt_title_clr | Optional | Title Color in HEX
349
+ pt_msg_clr | Optional | Message Color in HEX
350
+ pt_json | Optional | Above keys in JSON format
351
+
352
+ ### Timer Template
353
+
354
+ Timer Template Keys | Required | Description
355
+ ---:|:---:|:---
356
+ pt_id | Required | Value - `pt_timer`
357
+ pt_title | Required | Title
358
+ pt_title_alt | Optional | Title to show after timer expires
359
+ pt_msg | Required | Message
360
+ pt_msg_alt | Optional | Message to show after timer expires
361
+ pt_msg_summary | Optional | Message line when Notification is expanded
362
+ pt_dl1 | Required | Deep Link
363
+ pt_big_img | Optional | Image
364
+ pt_big_img_alt | Optional | Image to show when timer expires
365
+ pt_bg | Required | Background Color in HEX
366
+ pt_chrono_title_clr | Optional | Color for timer text in HEX
367
+ pt_timer_threshold | Required | Timer duration in seconds. Will be given higher priority.
368
+ pt_timer_end | Optional | Epoch Timestamp to countdown to (for example, $D_1595871380 or 1595871380). Not needed if pt_timer_threshold is specified.
369
+ pt_title_clr | Optional | Title Color in HEX
370
+ pt_msg_clr | Optional | Message Color in HEX
371
+ pt_json | Optional | Above keys in JSON format
372
+
373
+ ### Zero Bezel Template
374
+
375
+ Zero Bezel Template Keys | Required | Description
376
+ ---:|:---:|:---
377
+ pt_id | Required | Value - `pt_zero_bezel`
378
+ pt_title | Required | Title
379
+ pt_msg | Required | Message
380
+ pt_msg_summary | Optional | Message line when Notification is expanded
381
+ pt_subtitle | Optional | Subtitle
382
+ pt_big_img | Required | Image
383
+ pt_dl1 | Required | Deep Link
384
+ pt_title_clr | Optional | Title Color in HEX
385
+ pt_msg_clr | Optional | Message Color in HEX
386
+ pt_json | Optional | Above keys in JSON format
387
+
388
+ ### Rating Template
389
+
390
+ Rating Template Keys | Required | Description
391
+ ---:|:---:|:---
392
+ pt_id | Required | Value - `pt_rating`
393
+ pt_title | Required | Title
394
+ pt_msg | Required | Message
395
+ pt_big_img | Optional | Image
396
+ pt_msg_summary | Optional | Message line when Notification is expanded
397
+ pt_subtitle | Optional | Subtitle
398
+ pt_default_dl | Required | Default Deep Link for Push Notification
399
+ pt_dl1 | Required | Deep Link for first/all star(s)
400
+ pt_dl2 | Optional | Deep Link for second star
401
+ pt_dl3 | Optional | Deep Link for third star
402
+ pt_dl4 | Optional | Deep Link for fourth star
403
+ pt_dl5 | Optional | Deep Link for fifth star
404
+ pt_bg | Required | Background Color in HEX
405
+ pt_ico | Optional | Large Icon
406
+ pt_title_clr | Optional | Title Color in HEX
407
+ pt_msg_clr | Optional | Message Color in HEX
408
+ pt_json | Optional | Above keys in JSON format
409
+
410
+ ### Product Catalog Template
411
+
412
+ Product Catalog Template Keys | Required | Description
413
+ ---:|:---:|:---
414
+ pt_id | Required | Value - `pt_product_display`
415
+ pt_title | Required | Title
416
+ pt_msg | Required | Message
417
+ pt_subtitle | Optional | Subtitle
418
+ pt_img1 | Required | Image One
419
+ pt_img2 | Required | Image Two
420
+ pt_img3 | Optional | Image Three
421
+ pt_bt1 | Required | Big text for first image
422
+ pt_bt2 | Required | Big text for second image
423
+ pt_bt3 | Required | Big text for third image
424
+ pt_st1 | Required | Small text for first image
425
+ pt_st2 | Required | Small text for second image
426
+ pt_st3 | Required | Small text for third image
427
+ pt_dl1 | Required | Deep Link for first image
428
+ pt_dl2 | Required | Deep Link for second image
429
+ pt_dl3 | Required | Deep Link for third image
430
+ pt_price1 | Required | Price for first image
431
+ pt_price2 | Required | Price for second image
432
+ pt_price3 | Required | Price for third image
433
+ pt_bg | Required | Background Color in HEX
434
+ pt_product_display_action | Required | Action Button Label Text
435
+ pt_product_display_linear | Optional | Linear Layout Template ("true"/"false")
436
+ pt_product_display_action_clr | Required | Action Button Background Color in HEX
437
+ pt_title_clr | Optional | Title Color in HEX
438
+ pt_msg_clr | Optional | Message Color in HEX
439
+ pt_json | Optional | Above keys in JSON format
440
+
441
+ ### WebView Template
442
+
443
+ WebView Template Keys | Required | Description
444
+ ---:|:---:|:---
445
+ pt_id | Required | Value - `pt_web_view`
446
+ pt_dl1 | Required | Deep Link
447
+ pt_url | Required | URL to load
448
+ pt_orientation | Optional | Value - `landscape` or `portrait`
449
+ pt_json | Optional | Above keys in JSON format
package/index.d.ts CHANGED
@@ -610,6 +610,18 @@
610
610
  */
611
611
  export function resumeInAppNotifications(): void;
612
612
 
613
+ /*******************
614
+ * Instances
615
+ ******************/
616
+
617
+ /**
618
+ * Change the native instance of CleverTapAPI by using the instance for
619
+ * specific account. Used by Leanplum RN SDK.
620
+ *
621
+ * @param accountId {string} - The ID of the account to use when switching instance.
622
+ */
623
+ export function setInstanceWithAccountId(accountId: string): void;
624
+
613
625
  /*******************
614
626
  * Developer Options
615
627
  ******************/
package/index.js CHANGED
@@ -775,6 +775,16 @@ var CleverTap = {
775
775
  */
776
776
  setDebugLevel: function (level) {
777
777
  CleverTapReact.setDebugLevel(level);
778
+ },
779
+
780
+ /**
781
+ * Change the native instance of CleverTapAPI by using the instance for
782
+ * specific account. Used by Leanplum RN SDK.
783
+ *
784
+ * @param accountId The ID of the account to use when switching instance.
785
+ */
786
+ setInstanceWithAccountId: function(accountId) {
787
+ CleverTapReact.setInstanceWithAccountId(accountId);
778
788
  }
779
789
  };
780
790
 
@@ -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
- [[CleverTap sharedInstance] setPushTokenAsString:token];
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
- [[CleverTap sharedInstance] setOffline:enabled];
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
- [[CleverTap sharedInstance] setOptOut:enabled];
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
- [[CleverTap sharedInstance] enableDeviceNetworkInfoReporting:enabled];
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
- [[CleverTap sharedInstance] recordScreenView:screenName];
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
- [[CleverTap sharedInstance] recordEvent:eventName withProps:props];
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
- [[CleverTap sharedInstance] recordChargedEventWithDetails:details andItems:items];
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 = [[CleverTap sharedInstance] eventGetFirstTime:eventName];
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 = [[CleverTap sharedInstance] eventGetLastTime:eventName];
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 = [[CleverTap sharedInstance] eventGetOccurrences:eventName];
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 = [[CleverTap sharedInstance] eventGetDetail:eventName];
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 = [[CleverTap sharedInstance] userGetEventHistory];
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 = [[CleverTap sharedInstance] profileGetCleverTapAttributionIdentifier];
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 = [[CleverTap sharedInstance] profileGetCleverTapID];
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 = [[CleverTap sharedInstance] profileGetCleverTapID];
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
- [[CleverTap sharedInstance] onUserLogin:_profile];
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
- [[CleverTap sharedInstance] profilePush:_profile];
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 = [[CleverTap sharedInstance] profileGet:propertyName];
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
- [[CleverTap sharedInstance] profileRemoveValueForKey:key];
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
- [[CleverTap sharedInstance] profileSetMultiValues:values forKey:key];
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
- [[CleverTap sharedInstance] profileAddMultiValue:value forKey:key];
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
- [[CleverTap sharedInstance] profileAddMultiValues:values forKey:key];
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
- [[CleverTap sharedInstance] profileRemoveMultiValue:value forKey:key];
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
- [[CleverTap sharedInstance] profileRemoveMultiValues:values forKey:key];
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
- [[CleverTap sharedInstance] profileIncrementValueBy:value forKey:key];
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
- [[CleverTap sharedInstance] profileDecrementValueBy:value forKey:key];
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
- [[CleverTap sharedInstance] pushInstallReferrerSource:source medium:medium campaign:campaign];
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 = [[CleverTap sharedInstance] sessionGetTimeElapsed];
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 = [[CleverTap sharedInstance] userGetTotalVisits];
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 = [[CleverTap sharedInstance] userGetScreenCount];
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 = [[CleverTap sharedInstance] userGetPreviousVisitTime];
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 = [[CleverTap sharedInstance] sessionGetUTMDetails];
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)[[CleverTap sharedInstance] getInboxMessageCount];
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)[[CleverTap sharedInstance] getInboxMessageUnreadCount];
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 = [[CleverTap sharedInstance] getAllInboxMessages];
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 = [[CleverTap sharedInstance] getUnreadInboxMessages];
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,38 @@ 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 = [[CleverTap sharedInstance] getInboxMessageForId:messageId];
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
- [[CleverTap sharedInstance] recordInboxNotificationViewedEventForID:messageId];
524
+ [[self cleverTapInstance] recordInboxNotificationViewedEventForID:messageId];
494
525
  }
495
526
 
496
527
  RCT_EXPORT_METHOD(pushInboxNotificationClickedEventForId:(NSString*)messageId) {
497
528
  RCTLogInfo(@"[CleverTap pushInboxNotificationClickedEventForId]");
498
- [[CleverTap sharedInstance] recordInboxNotificationClickedEventForID:messageId];
529
+ [[self cleverTapInstance] recordInboxNotificationClickedEventForID:messageId];
499
530
  }
500
531
 
501
532
  RCT_EXPORT_METHOD(markReadInboxMessageForId:(NSString*)messageId) {
502
533
  RCTLogInfo(@"[CleverTap markReadInboxMessageForId]");
503
- [[CleverTap sharedInstance] markReadInboxMessageForID:messageId];
534
+ [[self cleverTapInstance] markReadInboxMessageForID:messageId];
504
535
  }
505
536
 
506
537
  RCT_EXPORT_METHOD(deleteInboxMessageForId:(NSString*)messageId) {
507
538
  RCTLogInfo(@"[CleverTap deleteInboxMessageForId]");
508
- [[CleverTap sharedInstance] deleteInboxMessageForID:messageId];
539
+ [[self cleverTapInstance] deleteInboxMessageForID:messageId];
509
540
  }
510
541
 
511
542
  RCT_EXPORT_METHOD(initializeInbox) {
512
543
  RCTLogInfo(@"[CleverTap Inbox Initialize]");
513
- [[CleverTap sharedInstance] initializeInboxWithCallback:^(BOOL success) {
544
+ [[self cleverTapInstance] initializeInboxWithCallback:^(BOOL success) {
514
545
  if (success) {
515
546
  RCTLogInfo(@"[Inbox initialized]");
516
547
  [[NSNotificationCenter defaultCenter] postNotificationName:kCleverTapInboxDidInitialize object:nil userInfo:nil];
517
- [[CleverTap sharedInstance] registerInboxUpdatedBlock:^{
548
+ [[self cleverTapInstance] registerInboxUpdatedBlock:^{
518
549
  RCTLogInfo(@"[Inbox updated]");
519
550
  [[NSNotificationCenter defaultCenter] postNotificationName:kCleverTapInboxMessagesDidUpdate object:nil userInfo:nil];
520
551
  }];
@@ -524,7 +555,7 @@ RCT_EXPORT_METHOD(initializeInbox) {
524
555
 
525
556
  RCT_EXPORT_METHOD(showInbox:(NSDictionary*)styleConfig) {
526
557
  RCTLogInfo(@"[CleverTap Show Inbox]");
527
- CleverTapInboxViewController *inboxController = [[CleverTap sharedInstance] newInboxViewControllerWithConfig:[self _dictToInboxStyleConfig:styleConfig? styleConfig : nil] andDelegate:(id <CleverTapInboxViewControllerDelegate>)self];
558
+ CleverTapInboxViewController *inboxController = [[self cleverTapInstance] newInboxViewControllerWithConfig:[self _dictToInboxStyleConfig:styleConfig? styleConfig : nil] andDelegate:(id <CleverTapInboxViewControllerDelegate>)self];
528
559
  if (inboxController) {
529
560
  UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:inboxController];
530
561
  UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
@@ -624,7 +655,7 @@ RCT_EXPORT_METHOD(showInbox:(NSDictionary*)styleConfig) {
624
655
 
625
656
  RCT_EXPORT_METHOD(getAllDisplayUnits:(RCTResponseSenderBlock)callback) {
626
657
  RCTLogInfo(@"[CleverTap getAllDisplayUnits]");
627
- NSArray <CleverTapDisplayUnit*> *units = [[CleverTap sharedInstance] getAllDisplayUnits];
658
+ NSArray <CleverTapDisplayUnit*> *units = [[self cleverTapInstance] getAllDisplayUnits];
628
659
  NSMutableArray *displayUnits = [NSMutableArray new];
629
660
  for (CleverTapDisplayUnit *unit in units) {
630
661
  [displayUnits addObject:unit.json];
@@ -635,19 +666,19 @@ RCT_EXPORT_METHOD(getAllDisplayUnits:(RCTResponseSenderBlock)callback) {
635
666
 
636
667
  RCT_EXPORT_METHOD(getDisplayUnitForId:(NSString*)unitId callback:(RCTResponseSenderBlock)callback) {
637
668
  RCTLogInfo(@"[CleverTap getDisplayUnitForId]");
638
- CleverTapDisplayUnit * displayUnit = [[CleverTap sharedInstance] getDisplayUnitForID:unitId];
669
+ CleverTapDisplayUnit * displayUnit = [[self cleverTapInstance] getDisplayUnitForID:unitId];
639
670
  NSDictionary *result = displayUnit.json;
640
671
  [self returnResult:result withCallback:callback andError:nil];
641
672
  }
642
673
 
643
674
  RCT_EXPORT_METHOD(pushDisplayUnitViewedEventForID:(NSString*)unitId) {
644
675
  RCTLogInfo(@"[CleverTap pushDisplayUnitViewedEventForID]");
645
- [[CleverTap sharedInstance] recordDisplayUnitViewedEventForID:unitId];
676
+ [[self cleverTapInstance] recordDisplayUnitViewedEventForID:unitId];
646
677
  }
647
678
 
648
679
  RCT_EXPORT_METHOD(pushDisplayUnitClickedEventForID:(NSString*)unitId) {
649
680
  RCTLogInfo(@"[CleverTap pushDisplayUnitClickedEventForID]");
650
- [[CleverTap sharedInstance] recordDisplayUnitClickedEventForID:unitId];
681
+ [[self cleverTapInstance] recordDisplayUnitClickedEventForID:unitId];
651
682
  }
652
683
 
653
684
 
@@ -655,7 +686,7 @@ RCT_EXPORT_METHOD(pushDisplayUnitClickedEventForID:(NSString*)unitId) {
655
686
 
656
687
  RCT_EXPORT_METHOD(getFeatureFlag:(NSString*)flag withdefaultValue:(BOOL)defaultValue callback:(RCTResponseSenderBlock)callback) {
657
688
  RCTLogInfo(@"[CleverTap getFeatureFlag]");
658
- BOOL result = [[[CleverTap sharedInstance] featureFlags] get:flag withDefaultValue:defaultValue];
689
+ BOOL result = [[[self cleverTapInstance] featureFlags] get:flag withDefaultValue:defaultValue];
659
690
  [self returnResult:@(result) withCallback:callback andError:nil];
660
691
  }
661
692
 
@@ -664,78 +695,78 @@ RCT_EXPORT_METHOD(getFeatureFlag:(NSString*)flag withdefaultValue:(BOOL)defaultV
664
695
 
665
696
  RCT_EXPORT_METHOD(setDefaultsMap:(NSDictionary*)jsonDict) {
666
697
  RCTLogInfo(@"[CleverTap setDefaultsMap]");
667
- [[[CleverTap sharedInstance] productConfig] setDefaults:jsonDict];
698
+ [[[self cleverTapInstance] productConfig] setDefaults:jsonDict];
668
699
  }
669
700
 
670
701
  RCT_EXPORT_METHOD(fetch) {
671
702
  RCTLogInfo(@"[CleverTap ProductConfig Fetch]");
672
- [[[CleverTap sharedInstance] productConfig] fetch];
703
+ [[[self cleverTapInstance] productConfig] fetch];
673
704
  }
674
705
 
675
706
  RCT_EXPORT_METHOD(fetchWithMinimumFetchIntervalInSeconds:(double)time) {
676
707
  RCTLogInfo(@"[CleverTap ProductConfig Fetch with minimum Interval]");
677
- [[[CleverTap sharedInstance] productConfig] fetchWithMinimumInterval: time];
708
+ [[[self cleverTapInstance] productConfig] fetchWithMinimumInterval: time];
678
709
  }
679
710
 
680
711
  RCT_EXPORT_METHOD(activate) {
681
712
  RCTLogInfo(@"[CleverTap ProductConfig Activate]");
682
- [[[CleverTap sharedInstance] productConfig] activate];
713
+ [[[self cleverTapInstance] productConfig] activate];
683
714
  }
684
715
 
685
716
  RCT_EXPORT_METHOD(fetchAndActivate) {
686
717
  RCTLogInfo(@"[CleverTap ProductConfig Fetch and Activate]");
687
- [[[CleverTap sharedInstance] productConfig] fetchAndActivate];
718
+ [[[self cleverTapInstance] productConfig] fetchAndActivate];
688
719
  }
689
720
 
690
721
  RCT_EXPORT_METHOD(setMinimumFetchIntervalInSeconds:(double)time) {
691
722
  RCTLogInfo(@"[CleverTap ProductConfig Minimum Time Interval Setup]");
692
- [[[CleverTap sharedInstance] productConfig] setMinimumFetchInterval: time];
723
+ [[[self cleverTapInstance] productConfig] setMinimumFetchInterval: time];
693
724
  }
694
725
 
695
726
  RCT_EXPORT_METHOD(getLastFetchTimeStampInMillis:(RCTResponseSenderBlock)callback) {
696
727
  RCTLogInfo(@"[CleverTap Last Fetch Config time]");
697
- NSTimeInterval result = [[[[CleverTap sharedInstance] productConfig] getLastFetchTimeStamp] timeIntervalSince1970] * 1000;
728
+ NSTimeInterval result = [[[[self cleverTapInstance] productConfig] getLastFetchTimeStamp] timeIntervalSince1970] * 1000;
698
729
  [self returnResult: @(result) withCallback: callback andError:nil];
699
730
  }
700
731
 
701
732
  RCT_EXPORT_METHOD(getString:(NSString*)key callback:(RCTResponseSenderBlock)callback) {
702
733
  RCTLogInfo(@"[CleverTap fetch String value for Key]");
703
- NSString *result = [[[CleverTap sharedInstance] productConfig] get:key].stringValue;
734
+ NSString *result = [[[self cleverTapInstance] productConfig] get:key].stringValue;
704
735
  [self returnResult: result withCallback: callback andError:nil];
705
736
  }
706
737
 
707
738
  RCT_EXPORT_METHOD(getBoolean:(NSString*)key callback:(RCTResponseSenderBlock)callback) {
708
739
  RCTLogInfo(@"[CleverTap fetch Bool value for Key]");
709
- BOOL result = [[[CleverTap sharedInstance] productConfig] get:key].boolValue;
740
+ BOOL result = [[[self cleverTapInstance] productConfig] get:key].boolValue;
710
741
  [self returnResult: @(result) withCallback: callback andError:nil];
711
742
  }
712
743
 
713
744
  RCT_EXPORT_METHOD(getDouble:(NSString*)key callback:(RCTResponseSenderBlock)callback) {
714
745
  RCTLogInfo(@"[CleverTap fetch Double value for Key]");
715
- long result = [[[CleverTap sharedInstance] productConfig] get:key].numberValue.doubleValue;
746
+ long result = [[[self cleverTapInstance] productConfig] get:key].numberValue.doubleValue;
716
747
  [self returnResult: @(result) withCallback: callback andError:nil];
717
748
  }
718
749
 
719
750
  RCT_EXPORT_METHOD(reset) {
720
751
  RCTLogInfo(@"[CleverTap ProductConfig Reset]");
721
- [[[CleverTap sharedInstance] productConfig] reset];
752
+ [[[self cleverTapInstance] productConfig] reset];
722
753
  }
723
754
 
724
755
  #pragma mark - InApp Notification Controls
725
756
 
726
757
  RCT_EXPORT_METHOD(suspendInAppNotifications) {
727
758
  RCTLogInfo(@"[CleverTap suspendInAppNotifications");
728
- [[CleverTap sharedInstance] suspendInAppNotifications];
759
+ [[self cleverTapInstance] suspendInAppNotifications];
729
760
  }
730
761
 
731
762
  RCT_EXPORT_METHOD(discardInAppNotifications) {
732
763
  RCTLogInfo(@"[CleverTap discardInAppNotifications");
733
- [[CleverTap sharedInstance] discardInAppNotifications];
764
+ [[self cleverTapInstance] discardInAppNotifications];
734
765
  }
735
766
 
736
767
  RCT_EXPORT_METHOD(resumeInAppNotifications) {
737
768
  RCTLogInfo(@"[CleverTap resumeInAppNotifications");
738
- [[CleverTap sharedInstance] resumeInAppNotifications];
769
+ [[self cleverTapInstance] resumeInAppNotifications];
739
770
  }
740
771
 
741
772
  @end
@@ -1,4 +1,3 @@
1
-
2
1
  #import <React/RCTEventEmitter.h>
3
2
 
4
3
  @interface CleverTapReactEventEmitter : RCTEventEmitter
@@ -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>
@@ -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
- [clevertap setSyncDelegate:self];
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 {
@@ -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": "0.9.3",
3
+ "version": "0.9.4",
4
4
  "description": "CleverTap React Native SDK.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
Binary file
Binary file
Binary file
@@ -1,8 +0,0 @@
1
- ## This file must *NOT* be checked into Version Control Systems,
2
- # as it contains information specific to your local configuration.
3
- #
4
- # Location of the SDK. This is only used by Gradle.
5
- # For customization when using a Version Control System, please read the
6
- # header note.
7
- #Wed Sep 07 13:41:26 IST 2022
8
- sdk.dir=/Users/ansh/Library/Android/sdk