Skip to content

Commit 6bb91b5

Browse files
kushCTAnush-Shandakashvercettivasctnzagorchev
authored
SDK-3736 - React Native new architecture + iOS SDK 7.0.1 + Android SDK 7.0.1 (#396)
* Added Turbo Module architecture support in iOS * Updated to TurboModule architecture for CleverTapSDK * Updated to latest RN architecture * Added event emitter support with new architecture * fixed new arch bugs * removed comments * Added NativeModule fixes * Rename .java to .kt * task(SDK-3792) - Adds changes to the library to support new architecture * task(SDK-3792) - Adds support for RN new architecture in android - Changes version to 3.0.0 - Adds separate implementations for oldArch and newArch * task(SDK-3792) - Cleanup * refactored example app to work with both new and old architectures. * task(SDK-3792) - Fixes non-implemented member for new arch * task(SDK-3792) - Adds support for both old and new arch for the sample app * changed showFallbackSettings to boolean from number * changed expiredOnly to boolean * task(SDK-3792) - Adds support for both old and new arch for the sample app * changed the podspec to use CT ios sdk 7.0.0 * task(SDK-3792) - Adds support for RN 0.74.5 * task(SDK-3968) - Adds support for core v7.0.0 * task(SDK-3968) - Updates sample app with core v7.0.0 * task(SDK-3968) - Fixes app inbox issue for sample app * updated ios sdk version to 7.0.1 * task(SDK-3968) - Adds comments * task(SDK-3968) - Adds specific version for androidx-ktx to support multiple compileSDK versions * task(SDK-3968) - Adds package-lock.json to Example app and updates .gitignore * updates podspec * Update version support in README.md * task(SDK-3792) - Extracts constants to a common file for old and new arch * task(SDK-3736) - Updates cord android deps to 701 * Add CT events buffering for Android and iOS (#416) * Add CT events buffering for android Changes for Android: - Add buffering for some CT events that are triggered before the react module has loaded. Buffered events are sent as soon as a listener is regitered for them and buffering for that event is disabled. All bufferring is disabled 5 seconds after the module has loaded. - Move all CT listeners to a common class - Rearrange constants * iOS observe and queue pending events * Formatting * Create CleverTapRnAPI with util initialization method Fix double registering of PushPermissionNotificationResponseListener * task(SDK-3968) - replaces enum getEntries() with .values() * Add backwards compatible setInitialUri method * Add Deprecated annotation to CleverTapModule.setInitialUri --------- Co-authored-by: Nikola Zagorchev <[email protected]> Co-authored-by: anush <[email protected]> * docs(SDK-3968) - Changes path for ct deps in example app * Docs/sdk 3968/new arch docs (#418) * docs(SDK-3968) - Updates new arch and 701 related docs - AndroidX Media3 related migration - Changelog - Updates old deps - Adds a step for somewhat breaking change * docs(SDK-3968) - Updates new arch and 701 related docs - Adds code snippet for integration * docs(SDK-3968) - Cleanup * task(SDK-3792) - Grammar * docs(SDK-3968) - Changes related to abstracted code * docs(SDK-3968) - Changes related to more abstract integration * Update CHANGELOG.md * docs(SDK-3968) - Note regarding new arch * docs(SDK-3968) - Updates date * docs(SDK-3968) - Adds clarity in changelog * Update CHANGELOG.md * docs(SDK-3968) - Fixes docs --------- Co-authored-by: Akash Malhotra <[email protected]> * task(SDK-3968) - Fixes comment * Update CleverTapReactManager.mm --------- Co-authored-by: Akash Malhotra <> Co-authored-by: anush <[email protected]> Co-authored-by: Akash Malhotra <[email protected]> Co-authored-by: Vassil Angelov <[email protected]> Co-authored-by: Nikola Zagorchev <[email protected]> Co-authored-by: Anush-Shand <[email protected]>
1 parent 7876dc2 commit 6bb91b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+16145
-1012
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ build/
2020
.gradle
2121
local.properties
2222
Example/android/app/google-services.json
23+
Example/android/app/.cxx
2324
*.iml
2425
.project
2526
.settings

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
11
Change Log
22
==========
3+
4+
Version 3.0.0 *(8 October 2024)*
5+
-------------------------------------------
6+
**What's new**
7+
8+
* **[Android Platform]**
9+
* Supports [CleverTap Android SDK v7.0.1](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md#version-701-september-2-2024).
10+
* Removes character limit of maximum 3 lines from `AppInbox` messages.
11+
* Deprecates `CleverTapModule.setInitialUri()` in favour of `CleverTapRnAPI.setInitialUri()`. Refer to [step 4](docs/integration.md#step4)
12+
13+
* **[iOS Platform]**
14+
* Supports [CleverTap iOS SDK v7.0.1](https://github.com/CleverTap/clevertap-ios-sdk/blob/master/CHANGELOG.md#version-701-august-22-2024).
15+
16+
* **[Android and iOS Platform]**
17+
* Adds support for triggering InApps based on user attribute changes.
18+
* Migrates the bridge to a backwards-compatible [New Architecture Turbo Module](docs/integration.md).
19+
* The CleverTap ReactNative SDK continues to be compatible with both the Old and the New Architecture.
20+
21+
**Breaking Changes**
22+
* **[Android Platform]**
23+
* Ensure that your custom `Application` class, extends the `CleverTapApplication` or calls `CleverTapRnAPI.initReactNativeIntegration(this);` to enable the functionality of `ClevertapPushNotificationClicked` and few other callbacks linked to killed state. Refer to [step 3](docs/integration.md#step3a)
24+
25+
**Bug Fixes**
26+
* **[Android Platform]**
27+
* Fixes an ANR caused by extremely old InApp campaigns.
28+
* Fixes an issue where incorrect callbacks were sent for InApps when the phone was rotated.
29+
* Fixes an issue where an InApp was displayed even after all the campaigns were stopped.
30+
* Fixes an issue where the InApp image was not shown when the phone was rotated to landscape.
31+
* Fixes an issue where certain URLs loaded incorrectly in custom HTML InApp templates.
32+
333
Version 2.2.1 *(12 April 2024)*
434
-------------------------------------------
535
**What's new**

Example/App.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ export default class App extends Component {
547547
// for iOS only: register for push notifications
548548
CleverTap.registerForPush();
549549
addCleverTapAPIListeners(false);
550+
550551
CleverTap.initializeInbox();
551552

552553
// Listener to handle incoming deep links
@@ -565,6 +566,8 @@ export default class App extends Component {
565566
// check to see if CleverTap has a launch deep link
566567
// handles the case where the app is launched from a push notification containing a deep link
567568
CleverTap.getInitialUrl((err, url) => {
569+
const archUsed = global?.nativeFabricUIManager ? 'new' : 'old';
570+
console.log(`Using RN ${archUsed} architecture`);
568571
if (url) {
569572
console.log('CleverTap launch url', url);
570573
_handleOpenUrl({url}, 'CleverTap');

Example/android/app/build.gradle

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def jscFlavor = 'org.webkit:android-jsc:+'
121121
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
122122
* and the benefits of using Hermes will therefore be sharply reduced.
123123
*/
124-
def enableHermes = project.ext.react.get("enableHermes", false);
124+
def enableHermes = project.ext.react.get("enableHermes", false)
125125

126126
android {
127127
ndkVersion rootProject.ext.ndkVersion
@@ -192,7 +192,12 @@ dependencies {
192192
implementation fileTree(dir: "libs", include: ["*.aar"])
193193

194194
//androidx
195-
implementation 'androidx.core:core:1.9.0'
195+
implementation('androidx.core:core') {
196+
version {
197+
strictly '1.9.0'
198+
}
199+
}
200+
196201
implementation 'androidx.fragment:fragment:1.3.6' // InApp
197202
implementation 'androidx.recyclerview:recyclerview:1.2.1' //Mandatory for App Inbox
198203
implementation 'androidx.viewpager:viewpager:1.0.0' //Mandatory for App Inbox
@@ -211,15 +216,15 @@ dependencies {
211216
implementation 'com.google.android.gms:play-services-base:18.2.0'
212217
implementation 'com.google.firebase:firebase-messaging:23.0.6'
213218
implementation 'com.google.android.material:material:1.4.0' //Mandatory for App Inbox
214-
implementation 'com.google.android.exoplayer:exoplayer:2.19.1' //Optional for Audio/Video
215-
implementation 'com.google.android.exoplayer:exoplayer-hls:2.19.1' //Optional for Audio/Video
216-
implementation 'com.google.android.exoplayer:exoplayer-ui:2.19.1' //Optional for Audio/Video
219+
implementation("androidx.media3:media3-exoplayer:1.1.1") //Optional for Audio/Video
220+
implementation("androidx.media3:media3-exoplayer-hls:1.1.1") //Optional for Audio/Video
221+
implementation("androidx.media3:media3-ui:1.1.1") //Optional for Audio/Video
217222
//implementation 'com.google.android.gms:play-services-ads:19.0.1'
218223

219224

220225
//clevertap
221-
implementation 'com.clevertap.android:clevertap-android-sdk:6.2.1'
222-
implementation "com.clevertap.android:push-templates:1.2.3"
226+
implementation 'com.clevertap.android:clevertap-android-sdk:7.0.1'
227+
implementation "com.clevertap.android:push-templates:1.2.4"
223228
implementation project(':clevertap-react-native')
224229

225230

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package com.reactnct;
22

3-
import android.os.Bundle;
3+
import android.content.Intent;
4+
import android.os.Build;
5+
import com.clevertap.android.sdk.CleverTapAPI;
46
import com.facebook.react.ReactActivity;
7+
import com.facebook.react.ReactActivityDelegate;
8+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
9+
import com.facebook.react.defaults.DefaultReactActivityDelegate;
510

6-
7-
public class MainActivity<packages> extends ReactActivity {
11+
public class MainActivity extends ReactActivity {
812

913
/**
1014
* Returns the name of the main component registered from JavaScript. This is used to schedule
@@ -15,9 +19,30 @@ protected String getMainComponentName() {
1519
return "Example";
1620
}
1721

18-
protected void onCreate(Bundle savedInstanceState) {
19-
super.onCreate(savedInstanceState);
22+
/**
23+
* Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link
24+
* DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React
25+
* (aka React 18) with two boolean flags.
26+
*/
27+
@Override
28+
protected ReactActivityDelegate createReactActivityDelegate() {
29+
return new DefaultReactActivityDelegate(
30+
this,
31+
getMainComponentName(),
32+
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
33+
DefaultNewArchitectureEntryPoint.getFabricEnabled(), // fabricEnabled
34+
// If you opted-in for the New Architecture, we enable Concurrent React (i.e. React 18).
35+
DefaultNewArchitectureEntryPoint.getConcurrentReactEnabled() // concurrentRootEnabled
36+
);
2037
}
2138

22-
39+
@Override
40+
public void onNewIntent(Intent intent) {
41+
super.onNewIntent(intent);
42+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
43+
if (intent != null && intent.getExtras() != null) {
44+
CleverTapAPI.getDefaultInstance(getApplicationContext()).pushNotificationClickedEvent(intent.getExtras());
45+
}
46+
}
47+
}
2348
}

Example/android/app/src/main/java/com/reactnct/MainApplication.java

Lines changed: 29 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,30 @@
55
import android.app.NotificationManager;
66
import android.content.Context;
77
import android.os.Bundle;
8-
import android.os.Handler;
9-
import android.os.Looper;
10-
import android.util.Log;
8+
119
import androidx.annotation.NonNull;
1210
import androidx.annotation.Nullable;
11+
1312
import com.clevertap.android.pushtemplates.PushTemplateNotificationHandler;
14-
import com.clevertap.android.sdk.ActivityLifecycleCallback;
1513
import com.clevertap.android.sdk.CleverTapAPI;
1614
import com.clevertap.android.sdk.CleverTapAPI.LogLevel;
17-
import com.clevertap.android.sdk.interfaces.NotificationHandler;
18-
import com.clevertap.android.sdk.pushnotification.CTPushNotificationListener;
1915
import com.clevertap.react.CleverTapApplication;
2016
import com.facebook.react.PackageList;
2117
import com.facebook.react.ReactApplication;
22-
import com.facebook.react.ReactInstanceManager;
18+
import com.facebook.react.ReactHost;
2319
import com.facebook.react.ReactNativeHost;
2420
import com.facebook.react.ReactPackage;
25-
import com.facebook.react.bridge.Arguments;
26-
import com.facebook.react.bridge.ReactContext;
27-
import com.facebook.react.bridge.WritableMap;
28-
import com.facebook.react.modules.core.DeviceEventManagerModule;
21+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
22+
import com.facebook.react.defaults.DefaultReactHost;
23+
import com.facebook.react.defaults.DefaultReactNativeHost;
2924
import com.facebook.soloader.SoLoader;
30-
import java.lang.reflect.InvocationTargetException;
31-
import java.util.HashMap;
32-
import java.util.Iterator;
33-
import java.util.List;
34-
import java.util.Map;
35-
import org.json.JSONObject;
3625

37-
public class MainApplication extends CleverTapApplication
38-
implements ActivityLifecycleCallbacks, ReactApplication{
26+
import java.util.List;
3927

40-
private static final String TAG = "MainApplication";
28+
public class MainApplication extends CleverTapApplication implements ActivityLifecycleCallbacks, ReactApplication {
4129

4230
private final ReactNativeHost mReactNativeHost =
43-
new ReactNativeHost(this) {
31+
new DefaultReactNativeHost(this) {
4432
@Override
4533
public boolean getUseDeveloperSupport() {
4634
return BuildConfig.DEBUG;
@@ -52,16 +40,31 @@ protected List<ReactPackage> getPackages() {
5240
List<ReactPackage> packages = new PackageList(this).getPackages();
5341
// Packages that cannot be autolinked yet can be added manually here, for example:
5442
// packages.add(new MyReactNativePackage());
55-
// packages.add(new CleverTapPackage()); // not to add if done by autolinking
43+
// packages.add(new CleverTapPackage()); // not to add if done by autolinking
5644
return packages;
5745
}
5846

5947
@Override
6048
protected String getJSMainModuleName() {
6149
return "index";
6250
}
51+
52+
@Override
53+
protected boolean isNewArchEnabled() {
54+
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
55+
}
56+
57+
@Override
58+
protected Boolean isHermesEnabled() {
59+
return BuildConfig.IS_HERMES_ENABLED;
60+
}
6361
};
6462

63+
@Override
64+
public ReactHost getReactHost() {
65+
return DefaultReactHost.getDefaultReactHost(getApplicationContext(), mReactNativeHost);
66+
}
67+
6568
@Override
6669
public ReactNativeHost getReactNativeHost() {
6770
return mReactNativeHost;
@@ -70,39 +73,13 @@ public ReactNativeHost getReactNativeHost() {
7073
@Override
7174
public void onCreate() {
7275
CleverTapAPI.setDebugLevel(LogLevel.VERBOSE);
73-
CleverTapAPI.setNotificationHandler((NotificationHandler) new PushTemplateNotificationHandler());
76+
CleverTapAPI.setNotificationHandler(new PushTemplateNotificationHandler());
7477
CleverTapAPI.getDefaultInstance(getApplicationContext()).enableDeviceNetworkInfoReporting(true);
75-
registerActivityLifecycleCallbacks(this);
7678
super.onCreate();
7779
SoLoader.init(this, /* native exopackage */ false);
78-
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
79-
}
80-
81-
/**
82-
* Loads Flipper in React Native templates. Call this in the onCreate method with something like
83-
* initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
84-
*/
85-
private static void initializeFlipper(
86-
Context context, ReactInstanceManager reactInstanceManager) {
87-
if (BuildConfig.DEBUG) {
88-
try {
89-
/*
90-
We use reflection here to pick up the class that initializes Flipper,
91-
since Flipper library is not available in release mode
92-
*/
93-
Class<?> aClass = Class.forName("com.reactnct.ReactNativeFlipper");
94-
aClass
95-
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
96-
.invoke(null, context, reactInstanceManager);
97-
} catch (ClassNotFoundException e) {
98-
e.printStackTrace();
99-
} catch (NoSuchMethodException e) {
100-
e.printStackTrace();
101-
} catch (IllegalAccessException e) {
102-
e.printStackTrace();
103-
} catch (InvocationTargetException e) {
104-
e.printStackTrace();
105-
}
80+
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
81+
// If you opted-in for the New Architecture, we load the native entry point for this app.
82+
DefaultNewArchitectureEntryPoint.load();
10683
}
10784
}
10885

Example/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
buildscript {
44
ext {
55
buildToolsVersion = "34.0.0"
6-
minSdkVersion = 21
6+
minSdkVersion = 23
77
compileSdkVersion = 34
88
targetSdkVersion = 34
99
ndkVersion = "26.2.11394342"

Example/android/gradle.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ FLIPPER_VERSION=0.125.0
3030
hermesEnabled=true
3131
android.defaults.buildfeatures.buildconfig=true
3232
android.nonTransitiveRClass=false
33-
android.nonFinalResIds=false
33+
android.nonFinalResIds=false
34+
newArchEnabled=true
35+
android.enableDexingArtifactTransform=false

Example/babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
presets: ['module:metro-react-native-babel-preset'],
2+
presets: ['module:@react-native/babel-preset'],
33
};

0 commit comments

Comments
 (0)