fix(android): use reactApplicationContext.currentActivity#69
Draft
airowe wants to merge 1 commit into
Draft
Conversation
`ReactContextBaseJavaModule.getCurrentActivity()` was made `protected` and `@Deprecated` in React Native 0.80+ (the recommendation in the deprecation message is to use `reactApplicationContext.currentActivity` directly). In RN 0.80 with Kotlin compiling against the updated Java stub, the Kotlin-inherited property syntax `currentActivity` no longer resolves at the subclass level — the compiler emits `Cannot access 'getCurrentActivity': it is protected/protected and package/package in 'ReactContextBaseJavaModule'` or, depending on the toolchain version, a runtime crash on the `auth.login(activity!!, ...)` call site. Switching to `reactApplicationContext.currentActivity` (the property the deprecation message recommends) restores the behaviour on RN 0.80+ and leaves older RN versions functionally identical, since `reactApplicationContext` was already used elsewhere in the file (see `getName()` / `auth` getter). Affected entry points: `login`, `directLoginAction`, `loginWithPasskeys`, `registerPasskeys` (4 sites).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces 4 uses of
currentActivityinFronteggRNModule.ktwithreactApplicationContext.currentActivity. Affected entry points:login,directLoginAction,loginWithPasskeys,registerPasskeys.Problem
ReactContextBaseJavaModule.getCurrentActivity()was madeprotected+@Deprecatedin React Native 0.80, with the deprecation message recommendingreactApplicationContext.currentActivitydirectly.In Kotlin compiling against the updated Java stub, the inherited-Java-property shorthand
currentActivityno longer resolves cleanly at the subclass level — depending on the Kotlin/RN toolchain versions you either get a compile error (Cannot access 'getCurrentActivity': it is protected ...) or a runtime NPE on theauth.login(activity!!, ...)site.Fix
Use the property the deprecation message points at.
reactApplicationContextis already used elsewhere in the same file (getName(), theauthgetter), so no new imports or fields needed.Compatibility
reactApplicationContext.currentActivityhas been the public getter onReactApplicationContextsince RN 0.60+, so this change is functionally identical on every supported RN version.Manual test plan
Reviewer / maintainer:
Cannot access 'getCurrentActivity'Kotlin error (before this PR: compile fails).cd example && yarn start:androidstill launches and login completes.login()— standard hosted logindirectLoginAction()— social provider direct login (e.g. Google)loginWithPasskeys()— passkey loginregisterPasskeys()— passkey registrationreact-native-sdk-e2e.yml) is green on this branch — covers thelogin()path.The change is a property rename (one symbol → another, same return type and semantics), so unit-test coverage is not added; behavioural equivalence is best verified by exercising each entry point in the example app.
Related
Part of a small batch we found while integrating the SDK — JVM 17 target and
BuildConfiglookup are separate PRs.