Skip to content

fix(android): use reactApplicationContext.currentActivity#69

Draft
airowe wants to merge 1 commit into
frontegg:masterfrom
healthie:fix/android-current-activity-deprecation
Draft

fix(android): use reactApplicationContext.currentActivity#69
airowe wants to merge 1 commit into
frontegg:masterfrom
healthie:fix/android-current-activity-deprecation

Conversation

@airowe
Copy link
Copy Markdown

@airowe airowe commented May 28, 2026

Summary

Replaces 4 uses of currentActivity in FronteggRNModule.kt with reactApplicationContext.currentActivity. Affected entry points: login, directLoginAction, loginWithPasskeys, registerPasskeys.

Problem

ReactContextBaseJavaModule.getCurrentActivity() was made protected + @Deprecated in React Native 0.80, with the deprecation message recommending reactApplicationContext.currentActivity directly.

In Kotlin compiling against the updated Java stub, the inherited-Java-property shorthand currentActivity no 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 the auth.login(activity!!, ...) site.

Fix

Use the property the deprecation message points at. reactApplicationContext is already used elsewhere in the same file (getName(), the auth getter), so no new imports or fields needed.

Compatibility

reactApplicationContext.currentActivity has been the public getter on ReactApplicationContext since RN 0.60+, so this change is functionally identical on every supported RN version.

Manual test plan

Reviewer / maintainer:

  • On RN 0.80+: example app compiles without the Cannot access 'getCurrentActivity' Kotlin error (before this PR: compile fails).
  • On older RN (e.g. 0.74): cd example && yarn start:android still launches and login completes.
  • Login flow exercises each affected entry point at least once:
    • login() — standard hosted login
    • directLoginAction() — social provider direct login (e.g. Google)
    • loginWithPasskeys() — passkey login
    • registerPasskeys() — passkey registration
  • Existing E2E suite (react-native-sdk-e2e.yml) is green on this branch — covers the login() 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 BuildConfig lookup are separate PRs.

`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).
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.

1 participant