Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ This is a major release with **important breaking changes**, please see our [mig
- Removed Expo support from this repository. You should now use our new dedicated [Batch-Expo-Plugin](https://github.com/BatchLabs/Batch-Expo-Plugin).

**Core**
- Batch requires react-native v0.77 or higher.
- Removed support for the old React Native architecture (Native Module). The plugin is now a pure Turbo Module and requires the new architecture enabled.
- 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.

**Android**
- The plugin is no longer auto-initialized. You should now call `RNBatchModuleImpl.initialize(application)` from `MainApplication.onCreate()` to complete setup.
- The plugin is no longer auto-initialized. You should now call `RNBatchModule.initialize(application)` from `MainApplication.onCreate()` to complete setup.
- 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`.


Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ As this plugin is built over Batch's Native SDKs, their respective Android and i

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

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)

Expand Down
29 changes: 5 additions & 24 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

def isNewArchitectureEnabled() {
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}

buildscript {
if (project == rootProject) {
repositories {
Expand All @@ -26,9 +22,7 @@ buildscript {
}

apply plugin: 'com.android.library'
if (isNewArchitectureEnabled()) {
apply plugin: 'com.facebook.react'
}
apply plugin: 'com.facebook.react'

android {
namespace 'com.batch.batch_rn'
Expand All @@ -41,17 +35,6 @@ android {
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
versionCode 1
versionName "1.0"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
}

sourceSets {
main {
if (isNewArchitectureEnabled()) {
java.srcDirs += ['src/newarch']
} else {
java.srcDirs += ['src/oldarch']
}
}
}

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

if (isNewArchitectureEnabled()) {
react {
jsRootDir = file("../src/")
libraryName = "RNBatch"
codegenJavaPackageName = "com.batch.batch_rn"
}
react {
jsRootDir = file("../src/")
libraryName = "RNBatch"
codegenJavaPackageName = "com.batch.batch_rn"
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class RNBatchEventDispatcher implements BatchEventDispatcher {

/**
* Event Queue
*
* <p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doupt

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ca marche les tags html en javadoc

* We need to queue events because Batch SDK is started before
* we have react context catalyst instance ready.
*/
Expand All @@ -57,10 +57,10 @@ public class RNBatchEventDispatcher implements BatchEventDispatcher {
* @param event dispatched event
*/
private void sendEvent(@NonNull RNBatchEvent event) {
if (reactContext == null || !reactContext.hasActiveCatalystInstance()) {
Log.d(RNBatchModuleImpl.LOGGER_TAG,
if (reactContext == null || !reactContext.hasActiveReactInstance()) {
Log.d(RNBatchModule.LOGGER_TAG,
"Trying to send an event while react context is null" +
" or has no active catalyst instance. Aborting.");
" or has no active react instance. Aborting.");
return;
}
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
Expand Down Expand Up @@ -106,15 +106,15 @@ public void dispatchEvent(@NonNull Batch.EventDispatcher.Type type,
JSONObject customPayloadJSON = new JSONObject(customPayload);
params.putMap("messagingCustomPayload", RNUtils.convertJSONObjectToWritableMap(customPayloadJSON));
} catch (JSONException e) {
Log.d(RNBatchModuleImpl.LOGGER_TAG,"Failed to parse messaging custom payload");
Log.d(RNBatchModule.LOGGER_TAG,"Failed to parse messaging custom payload");
}
}
}
}
}
RNBatchEvent event = new RNBatchEvent(eventName, params);
if (!isModuleReady() || !hasListener) {
Log.d(RNBatchModuleImpl.LOGGER_TAG,
Log.d(RNBatchModule.LOGGER_TAG,
"Module is not ready or no listener registered yet. Queuing event: ".concat(eventName));
queueEvent(event);
return;
Expand All @@ -131,7 +131,7 @@ private void dequeueEvents() {
if (events.isEmpty()) {
return;
}
while(events.size() != 0) {
while(!events.isEmpty()) {
sendEvent(events.pop());
}
}
Expand Down Expand Up @@ -164,7 +164,7 @@ public void setReactContext(@NonNull ReactApplicationContext reactContext) {
* @return true if ready
*/
private boolean isModuleReady() {
return reactContext != null && reactContext.hasActiveCatalystInstance();
return reactContext != null && reactContext.hasReactInstance();
Comment on lines 164 to +167

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 Badge ReactContext API renamed but dependency version unchanged

Event dispatching now relies on ReactApplicationContext.hasActiveReactInstance() and hasReactInstance(). These methods only exist in newer React Native releases; in 0.73 (still the declared dependency) the available methods are hasActiveCatalystInstance()/hasCatalystInstance(). Without updating the required React Native version this change results in a compilation failure for current consumers. Consider reverting to the older methods or documenting the higher minimum React Native version.

Useful? React with 👍 / 👎.

Copy link
Contributor Author

@arnaud-roland arnaud-roland Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's bump to 0.77, older react native version still maintained (hasReactInstance has been introduced in 0.75)

}

/**
Expand Down
Loading