Skip to content

Conversation

@ThomasMengelatte
Copy link
Contributor

@ThomasMengelatte ThomasMengelatte commented Oct 20, 2025

Problem

AndroidX Activity 1.9+ introduced a breaking change in the onNewIntent() method signature for Kotlin projects. The Android API changed to make the Intent parameter non-nullable (Intent instead of Intent?), which conflicts with the code automatically generated by our Expo plugin.

Technical context: This change in AndroidX Activity affects Expo projects starting from SDK 54, which adopted AndroidX Activity 1.9+. Projects using earlier versions (Expo SDK ≤ 53 with AndroidX Activity < 1.9) use the older nullable signature.

Before (AndroidX Activity < 1.9):

override fun onNewIntent(intent: Intent?) {
    super.onNewIntent(intent)
    Batch.onNewIntent(this, intent)
}

After (AndroidX Activity 1.9+):

override fun onNewIntent(intent: Intent) {  // Non-nullable!
    super.onNewIntent(intent)
    Batch.onNewIntent(this, intent)
}

Without this fix, developers using AndroidX Activity 1.9+ encounter Kotlin compilation errors when the plugin generates code with the old nullable signature.

Solution

Added the optional shouldUseNonNullableIntent parameter to the Expo plugin config, allowing developers to specify the Intent parameter nullability based on their AndroidX Activity version.

Usage Examples

For AndroidX Activity 1.9+:

{
  "plugins": [
    [
      "@batch.com/react-native-plugin",
      {
        "androidApiKey": "YOUR_ANDROID_API_KEY",
        "iosApiKey": "YOUR_IOS_API_KEY",
        "shouldUseNonNullableIntent": true
      }
    ]
  ]
}

For AndroidX Activity < 1.9 - default behavior:

{
  "plugins": [
    [
      "@batch.com/react-native-plugin",
      {
        "androidApiKey": "YOUR_ANDROID_API_KEY",
        "iosApiKey": "YOUR_IOS_API_KEY"
      }
    ]
  ]
}

Note: If shouldUseNonNullableIntent is not specified, it defaults to false to maintain backward compatibility with existing projects.

@arnaud-roland arnaud-roland self-requested a review October 20, 2025 12:47
@ThomasMengelatte ThomasMengelatte force-pushed the fix/nullable-intent-android-api branch 3 times, most recently from 3ecc4ac to 24bff48 Compare October 20, 2025 13:04
@YannickLanteri
Copy link

Thanks for the fix, @ThomasMengelatte. Much appreciated!!

@ThomasMengelatte ThomasMengelatte force-pushed the fix/nullable-intent-android-api branch 3 times, most recently from ffb0b3e to 3ceda62 Compare October 21, 2025 13:53
Refactor MainActivity modification logic for Intent nullability
Add comprehensive tests for MainActivity Intent nullability
Add test fixtures for nullable Intent MainActivity
@ThomasMengelatte ThomasMengelatte force-pushed the fix/nullable-intent-android-api branch from 3ceda62 to 7b56940 Compare October 21, 2025 14:05
@ThomasMengelatte ThomasMengelatte force-pushed the fix/nullable-intent-android-api branch from 7b56940 to 8e03eb6 Compare October 21, 2025 14:51
@ThomasMengelatte ThomasMengelatte changed the title Releases version 11.0.1 Releases version 11.1.0 Oct 21, 2025
Copy link
Contributor

@arnaud-roland arnaud-roland left a comment

Choose a reason for hiding this comment

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

LGTM, thanks !

@ThomasMengelatte ThomasMengelatte merged commit 5ea1485 into master Oct 21, 2025
2 checks passed
@ThomasMengelatte ThomasMengelatte deleted the fix/nullable-intent-android-api branch October 21, 2025 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants