Skip to content

Commit

Permalink
fix: android build error with React Native 0.76
Browse files Browse the repository at this point in the history
When using React Native 0.76 the Android build fails with an error:
```
java/com/dooboolab/RNIap/PromiseUtlis.kt:40:21 Type mismatch: inferred type is String? but String was expected
```

The issue seems to be caused by the fact that in RN 0.76 the Promise class was rewritten from Java to Kotlin and the code parameter of the reject method is a non-nullable String now: facebook/react-native@de73e44#diff-74cbd5a9d82e4c21dbc37dd72a92e31542e574dc6425d2454c3ce53e71e08bbeR31 but in react-native-iap it is called with a nullable string: https://github.com/hyochan/react-native-iap/blob/12.15.6/android/src/main/java/com/dooboolab/rniap/PromiseUtlis.kt#L40.

This change updates that call to use an empty string "" for code if for some reason it's null.

Fixes hyochan#2871
  • Loading branch information
mlazari committed Oct 27, 2024
1 parent e7ae2d8 commit 98b2555
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion android/src/main/java/com/dooboolab/rniap/PromiseUtlis.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fun Promise.safeReject(
throwable: Throwable?,
) {
try {
this.reject(code, message, throwable)
this.reject(code ?: "", message, throwable)
} catch (oce: ObjectAlreadyConsumedException) {
Log.d(TAG, "Already consumed ${oce.message}")
}
Expand Down

0 comments on commit 98b2555

Please sign in to comment.