Skip to content

fix(android): use reactApplicationContext.currentActivity#69

Merged
dianaKhortiuk-frontegg merged 1 commit into
frontegg:masterfrom
healthie:fix/android-current-activity-deprecation
Jun 26, 2026
Merged

fix(android): use reactApplicationContext.currentActivity#69
dianaKhortiuk-frontegg merged 1 commit into
frontegg:masterfrom
healthie:fix/android-current-activity-deprecation

Conversation

@airowe

@airowe airowe commented May 28, 2026

Copy link
Copy Markdown
Contributor

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).
@dianaKhortiuk-frontegg
dianaKhortiuk-frontegg marked this pull request as ready for review June 26, 2026 13:49

@dianaKhortiuk-frontegg dianaKhortiuk-frontegg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

reactApplicationContext.currentActivity is the correct modern accessor (the module-base currentActivity is deprecated). Thanks @airowe!

@dianaKhortiuk-frontegg
dianaKhortiuk-frontegg merged commit e5bbfb1 into frontegg:master Jun 26, 2026
@dianaKhortiuk-frontegg dianaKhortiuk-frontegg mentioned this pull request Jun 26, 2026
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.

2 participants