Skip to content

MOEN-45999: Add Flutter Android bridge and Dart interface for jwt - #236

Open
kkgowtham-engg-sdk wants to merge 10 commits into
feature/MOEN-45889_major_version_updatefrom
feature/MOEN-45999-jwt_authentication
Open

MOEN-45999: Add Flutter Android bridge and Dart interface for jwt#236
kkgowtham-engg-sdk wants to merge 10 commits into
feature/MOEN-45889_major_version_updatefrom
feature/MOEN-45999-jwt_authentication

Conversation

@kkgowtham-engg-sdk

@kkgowtham-engg-sdk kkgowtham-engg-sdk commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Android: JWT Authentication Support added to the existing moengage_flutter_android package (core) — authenticationDetails (fire-and-forget) + onAuthenticationError event via EventEmitterImpl
  • Dart: platform interface (moengage_flutter_platform_interface) + public API (moengage_flutter) for JWT authentication
    • MoEngageFlutter.passAuthenticationDetails(token, userIdentifier)
    • MoEngageFlutter.setAuthenticationErrorCallbackHandler(handler)AuthenticationErrorData with JwtErrorCode
  • Sample app (example/lib/main.dart): registers setAuthenticationErrorCallbackHandler in initState, plus a "Pass JWT Authentication Details" demo tile
  • No iOS changes in this PR (Android + Dart only, per request)
  • Android BOM: unchanged, inherited from feature/MOEN-45889_major_version_update (already on android-bom 4.0.0 / plugin-base-bom 4.0.0-SNAPSHOT, which includes JWT support merged in plugin-base 6.1.0)

Related PRs

Contract

Branch: master in mobile-sdk-contracts (contract dir: authentication, top-level core contract)

Changelogs updated

  • packages/moengage_flutter/moengage_flutter_android/CHANGELOG.md
  • packages/moengage_flutter/moengage_flutter_platform_interface/CHANGELOG.md
  • packages/moengage_flutter/moengage_flutter/CHANGELOG.md

Methods

Method Type Android handler Dart
authenticationDetails fire-and-forget PluginHelper.passAuthenticationDetails(context, payload) passAuthenticationDetails(token, userIdentifier)
onAuthenticationError (event) event EventEmitterImpl.emitAuthenticationErrorEventauthenticationErrorToJson setAuthenticationErrorCallbackHandler(handler)

Sample App

  • example/lib/main.dart updated to demonstrate the new JWT authentication APIs (listener registration + demo tile)

🤖 Generated with Claude Code

@moe-hodor

moe-hodor Bot commented Jul 14, 2026

Copy link
Copy Markdown

🚪 Hodor is reviewing this PR... 👀

@moe-hodor moe-hodor Bot added cfr:neutral Change Failure Rate: neutral impact branch:feature Planned work — new functionality or enhancement (neutral CFR) labels Jul 14, 2026

@moe-hodor moe-hodor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review: MOEN-45999 — Add Flutter Android bridge for JWT

Branching & CFR: feature/MOEN-45999-jwt_authentication — category: feature, impact: Neutral CFR


Summary

This PR adds the Android Kotlin bridge for JWT authentication support to the Flutter SDK. It implements:

  • Fire-and-forget authenticationDetails method to pass JWT auth details from Dart → Android → native SDK
  • Event emitter integration for onAuthenticationError events flowing back from native → Android → Dart
  • Correct event mapping in EventEmitterImpl for authentication error events

This is Phase 1 (Android bridge only) — Dart platform interface and iOS implementation are explicitly mentioned as following in subsequent commits on this branch.


Quality Gates

PR Size: 38 lines across 4 files — well-scoped
ℹ️ Tests: No test files modified — existing tests should still pass
Commits: 1 commit
No migrations or config drift detected


Jira Alignment: MOEN-45999

Ticket scope: "JWT support for Flutter"
PR addresses: Android bridge layer (as stated in DoD — "Implementation complete")
ℹ️ Remaining work: Dart interface + iOS bridge (explicitly noted in PR description)


Issues Found

🟢 0 Critical | 🟡 0 Warnings | 💡 2 Suggestions


Key Observations

What's Good:

  • ✅ Correct use of PluginHelper.passAuthenticationDetails() from plugin-base-bom:4.0.0-SNAPSHOT (which includes JWT support)
  • ✅ Event emitter correctly handles AuthenticationErrorEvent and maps it to onAuthenticationError callback
  • ✅ Proper imports from plugin-base (authenticationErrorToJson, AuthenticationErrorEvent)
  • ✅ Method handler wired correctly in MoEngageFlutterPlugin.onMethodCall()
  • ✅ Error handling with try-catch and logging in all new methods
  • ✅ Consistent with existing code patterns (matches logout, identifyUser, etc.)
  • ✅ CHANGELOG updated with correct [minor] change

Architectural Verification:

  • ✅ Dependencies verified via cross-org search: passAuthenticationDetails and authenticationErrorToJson exist in android-plugin-base:4.0.0-SNAPSHOT
  • ✅ BOM version plugin-base-bom:4.0.0-SNAPSHOT already correct in base branch (feature/MOEN-45889_major_version_update)
  • ✅ Event flow matches existing patterns: AuthenticationErrorEventEventEmitterImpl.emitAuthenticationErrorEvent() → MethodChannel → Dart (once Dart layer is added)

No Blocking Issues Found
The Android bridge implementation is complete and correct. The missing Dart layer (platform interface + public API + callback handlers) is intentional per the PR description ("Dart platform interface + public API to follow in a subsequent commit on this branch").


Suggestions for Follow-Up Work

💡 When implementing the Dart layer in subsequent commits, ensure:

  1. Add AuthenticationErrorCallbackHandler typedef in callback/callbacks.dart (similar to LogoutCompleteCallbackHandler)
  2. Add callback field in CallbackCache class
  3. Add callback listener registration method in MoEngageFlutter class
  4. Add event handler in MoECoreController to deserialize and route onAuthenticationError events
  5. Add passAuthenticationDetails(authData, appId) method to MoEngageFlutterPlatform abstract class and MethodChannelMoEngageFlutter implementation
  6. Define const String methodAuthenticationDetails = 'authenticationDetails'; in constants.dart
  7. Add const String callbackOnAuthenticationError = 'onAuthenticationError'; in constants.dart

💡 Consider adding integration tests for the full JWT flow once iOS + Dart layers are complete (can be deferred to a separate PR).


Regression Risk

🟢 Low — This PR is purely additive. No existing code paths modified, only new method + event handler added.


Verdict

Android bridge implementation is complete and correct. No blocking issues. The PR is scoped correctly as Phase 1 (Android-only), with Dart + iOS explicitly noted as follow-up work on this branch.

Once the Dart platform interface and iOS bridge are added in subsequent commits, the full JWT feature will be complete.


Hodor says: The Android gate is solid. The bridge holds. 🛡️

@kkgowtham-engg-sdk kkgowtham-engg-sdk changed the title MOEN-45999: Add Flutter Android bridge for jwt MOEN-45999: Add Flutter Android bridge and Dart interface for jwt Jul 14, 2026
kkgowtham-engg-sdk and others added 5 commits July 23, 2026 11:26
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@kkgowtham-engg-sdk
kkgowtham-engg-sdk force-pushed the feature/MOEN-45999-jwt_authentication branch from 36ea3de to 5199237 Compare July 23, 2026 05:56
Comment thread packages/moengage_flutter/moengage_flutter/lib/src/moengage_flutter.dart Outdated
Comment thread packages/moengage_flutter/moengage_flutter_android/android/build.gradle Outdated
Comment thread packages/moengage_flutter/moengage_flutter/lib/src/moengage_flutter.dart Outdated
Comment thread example/lib/constants.dart Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

branch:feature Planned work — new functionality or enhancement (neutral CFR) cfr:neutral Change Failure Rate: neutral impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants