Skip to content

Commit 6491685

Browse files
committed
all: drop support of the old arch
1 parent 40cd147 commit 6491685

File tree

11 files changed

+236
-739
lines changed

11 files changed

+236
-739
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ This is a major release with **important breaking changes**, please see our [mig
77
- Removed Expo support from this repository. You should now use our new dedicated [Batch-Expo-Plugin](https://github.com/BatchLabs/Batch-Expo-Plugin).
88

99
**Core**
10+
- Removed support for the old React Native architecture (Native Module). The plugin is now a pure Turbo Module and requires the new architecture enabled.
1011
- Batch no longer requires a custom React Native CLI configuration. If `react-native.config.js` only exists for Batch, delete it or remove the `@batch.com/react-native-plugin` entry.
1112

1213
**Android**
13-
- The plugin is no longer auto-initialized. You should now call `RNBatchModuleImpl.initialize(application)` from `MainApplication.onCreate()` to complete setup.
14+
- The plugin is no longer auto-initialized. You should now call `RNBatchModule.initialize(application)` from `MainApplication.onCreate()` to complete setup.
1415
- The initial state of the "Do Not Disturb" (DnD) feature is no longer read from the Android resources. You should now add a meta-data tag `batch_do_not_disturb_initial_state` to the <application> section of your `AndroidManifest`.
1516

1617

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ As this plugin is built over Batch's Native SDKs, their respective Android and i
1717

1818
# React Native architecture
1919
Batch ships a TurboModule implementation for the React Native New Architecture.
20-
The legacy bridge is still bundled for compatibility but is now deprecated and will be removed in a future release.
21-
Enable the New Architecture to keep receiving updates.
20+
Starting with v12.0.0, the legacy bridge has been removed and the plugin now requires the New Architecture to be enabled.
2221

2322
You may also find this guide useful to review after integration to make sure you're ready to go live: [How can I test the integration on iOS?](https://help.batch.com/en/articles/2669866-how-can-i-test-the-integration-on-ios) / [How can I test the integration on Android?](https://help.batch.com/en/articles/2672749-how-can-i-test-the-integration-on-android)
2423

android/build.gradle

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ def safeExtGet(prop, fallback) {
88
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
99
}
1010

11-
def isNewArchitectureEnabled() {
12-
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
13-
}
14-
1511
buildscript {
1612
if (project == rootProject) {
1713
repositories {
@@ -26,9 +22,7 @@ buildscript {
2622
}
2723

2824
apply plugin: 'com.android.library'
29-
if (isNewArchitectureEnabled()) {
30-
apply plugin: 'com.facebook.react'
31-
}
25+
apply plugin: 'com.facebook.react'
3226

3327
android {
3428
namespace 'com.batch.batch_rn'
@@ -41,17 +35,6 @@ android {
4135
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
4236
versionCode 1
4337
versionName "1.0"
44-
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
45-
}
46-
47-
sourceSets {
48-
main {
49-
if (isNewArchitectureEnabled()) {
50-
java.srcDirs += ['src/newarch']
51-
} else {
52-
java.srcDirs += ['src/oldarch']
53-
}
54-
}
5538
}
5639

5740
lintOptions {
@@ -73,10 +56,8 @@ dependencies {
7356
api "com.batch.android:batch-sdk:${safeExtGet('batchSdkVersion', DEFAULT_BATCH_SDK_VERSION)}"
7457
}
7558

76-
if (isNewArchitectureEnabled()) {
77-
react {
78-
jsRootDir = file("../src/")
79-
libraryName = "RNBatch"
80-
codegenJavaPackageName = "com.batch.batch_rn"
81-
}
59+
react {
60+
jsRootDir = file("../src/")
61+
libraryName = "RNBatch"
62+
codegenJavaPackageName = "com.batch.batch_rn"
8263
}

android/src/main/java/com/batch/batch_rn/RNBatchEventDispatcher.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class RNBatchEventDispatcher implements BatchEventDispatcher {
3939

4040
/**
4141
* Event Queue
42-
*
42+
* <p>
4343
* We need to queue events because Batch SDK is started before
4444
* we have react context catalyst instance ready.
4545
*/
@@ -57,10 +57,10 @@ public class RNBatchEventDispatcher implements BatchEventDispatcher {
5757
* @param event dispatched event
5858
*/
5959
private void sendEvent(@NonNull RNBatchEvent event) {
60-
if (reactContext == null || !reactContext.hasActiveCatalystInstance()) {
61-
Log.d(RNBatchModuleImpl.LOGGER_TAG,
60+
if (reactContext == null || !reactContext.hasActiveReactInstance()) {
61+
Log.d(RNBatchModule.LOGGER_TAG,
6262
"Trying to send an event while react context is null" +
63-
" or has no active catalyst instance. Aborting.");
63+
" or has no active react instance. Aborting.");
6464
return;
6565
}
6666
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
@@ -106,15 +106,15 @@ public void dispatchEvent(@NonNull Batch.EventDispatcher.Type type,
106106
JSONObject customPayloadJSON = new JSONObject(customPayload);
107107
params.putMap("messagingCustomPayload", RNUtils.convertJSONObjectToWritableMap(customPayloadJSON));
108108
} catch (JSONException e) {
109-
Log.d(RNBatchModuleImpl.LOGGER_TAG,"Failed to parse messaging custom payload");
109+
Log.d(RNBatchModule.LOGGER_TAG,"Failed to parse messaging custom payload");
110110
}
111111
}
112112
}
113113
}
114114
}
115115
RNBatchEvent event = new RNBatchEvent(eventName, params);
116116
if (!isModuleReady() || !hasListener) {
117-
Log.d(RNBatchModuleImpl.LOGGER_TAG,
117+
Log.d(RNBatchModule.LOGGER_TAG,
118118
"Module is not ready or no listener registered yet. Queuing event: ".concat(eventName));
119119
queueEvent(event);
120120
return;
@@ -131,7 +131,7 @@ private void dequeueEvents() {
131131
if (events.isEmpty()) {
132132
return;
133133
}
134-
while(events.size() != 0) {
134+
while(!events.isEmpty()) {
135135
sendEvent(events.pop());
136136
}
137137
}
@@ -164,7 +164,7 @@ public void setReactContext(@NonNull ReactApplicationContext reactContext) {
164164
* @return true if ready
165165
*/
166166
private boolean isModuleReady() {
167-
return reactContext != null && reactContext.hasActiveCatalystInstance();
167+
return reactContext != null && reactContext.hasReactInstance();
168168
}
169169

170170
/**

0 commit comments

Comments
 (0)