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
22 changes: 20 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
12.0.0
----

This is a major release with **important breaking changes**, please see our [migration guide](https://doc.batch.com/react-native/advanced/11x-migration/) for more info on how to update your current Batch implementation.

**Expo**
- 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 `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`.


11.1.0
___
----

**Expo**
- Added configuration field `shouldUseNonNullableIntent` to control whether the MainActivity's `onNewIntent` method uses a nullable or non-nullable Intent parameter on Android. This is required for compatibility with AndroidX Activity 1.9+ which uses non-nullable Intent types. By default, it is set to `false` (nullable Intent) for backwards compatibility. Set it to `true` if you're using AndroidX Activity 1.9 or higher.


11.0.0
___
----

**Plugin**
* Updated Batch to 3.1
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>
* 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();
}

/**
Expand Down
Loading