MOEN-45999: Add Flutter Android bridge and Dart interface for jwt - #236
MOEN-45999: Add Flutter Android bridge and Dart interface for jwt#236kkgowtham-engg-sdk wants to merge 10 commits into
Conversation
|
🚪 Hodor is reviewing this PR... 👀 |
There was a problem hiding this comment.
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
authenticationDetailsmethod to pass JWT auth details from Dart → Android → native SDK - Event emitter integration for
onAuthenticationErrorevents flowing back from native → Android → Dart - Correct event mapping in
EventEmitterImplfor 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()fromplugin-base-bom:4.0.0-SNAPSHOT(which includes JWT support) - ✅ Event emitter correctly handles
AuthenticationErrorEventand maps it toonAuthenticationErrorcallback - ✅ 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:
passAuthenticationDetailsandauthenticationErrorToJsonexist inandroid-plugin-base:4.0.0-SNAPSHOT - ✅ BOM version
plugin-base-bom:4.0.0-SNAPSHOTalready correct in base branch (feature/MOEN-45889_major_version_update) - ✅ Event flow matches existing patterns:
AuthenticationErrorEvent→EventEmitterImpl.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:
- Add
AuthenticationErrorCallbackHandlertypedef incallback/callbacks.dart(similar toLogoutCompleteCallbackHandler) - Add callback field in
CallbackCacheclass - Add callback listener registration method in
MoEngageFlutterclass - Add event handler in
MoECoreControllerto deserialize and routeonAuthenticationErrorevents - Add
passAuthenticationDetails(authData, appId)method toMoEngageFlutterPlatformabstract class andMethodChannelMoEngageFlutterimplementation - Define
const String methodAuthenticationDetails = 'authenticationDetails';inconstants.dart - Add
const String callbackOnAuthenticationError = 'onAuthenticationError';inconstants.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. 🛡️
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>
36ea3de to
5199237
Compare
Summary
moengage_flutter_androidpackage (core) —authenticationDetails(fire-and-forget) +onAuthenticationErrorevent viaEventEmitterImplmoengage_flutter_platform_interface) + public API (moengage_flutter) for JWT authenticationMoEngageFlutter.passAuthenticationDetails(token, userIdentifier)MoEngageFlutter.setAuthenticationErrorCallbackHandler(handler)→AuthenticationErrorDatawithJwtErrorCodeexample/lib/main.dart): registerssetAuthenticationErrorCallbackHandlerininitState, plus a "Pass JWT Authentication Details" demo tilefeature/MOEN-45889_major_version_update(already onandroid-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:
masterin mobile-sdk-contracts (contract dir:authentication, top-level core contract)Changelogs updated
packages/moengage_flutter/moengage_flutter_android/CHANGELOG.mdpackages/moengage_flutter/moengage_flutter_platform_interface/CHANGELOG.mdpackages/moengage_flutter/moengage_flutter/CHANGELOG.mdMethods
authenticationDetailsPluginHelper.passAuthenticationDetails(context, payload)passAuthenticationDetails(token, userIdentifier)onAuthenticationError(event)EventEmitterImpl.emitAuthenticationErrorEvent→authenticationErrorToJsonsetAuthenticationErrorCallbackHandler(handler)Sample App
example/lib/main.dartupdated to demonstrate the new JWT authentication APIs (listener registration + demo tile)🤖 Generated with Claude Code