Repository navigation
feat: [SDK-5024] add loginWithProfile (Android only) - #2004
Draft
abdulraqeeb33 wants to merge 4 commits into
Draft
abdulraqeeb33 wants to merge 4 commits into
abdulraqeeb33 wants to merge 4 commits into
Conversation
Adds OneSignal.loginWithProfile, which logs in with a profile and resolves with a typed result. Android bridges the native suspend login via a Continuation and marshals OneSignalResult.toMap(). iOS resolves the unsupported failure envelope. Bumps the Android SDK to 5.11.0 and adds a demo dialog. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
|
Heads-up on the native Android dependency, so the red Android CI doesn't cause alarm:
|
Resolve INVALID_ARGUMENT when the profile cannot be read, reject a success envelope that carries errors, log native failures with a non-null message, and keep the demo from writing stale state or leaving loading stuck. Co-authored-by: Cursor <cursoragent@cursor.com>
The user change listener and fetchUserDataFromApi also bump requestSequenceRef, so a successful login that changed the onesignalId was treated as stale and never saved the external id.
The native constructor is now private so new profile fields never break compiled callers. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Description
One Line Summary
Add
loginWithProfile(externalId, profile, jwt?): one Create User call that logs in and attaches email, SMS, tags and aliases. Android only for now.Details
Motivation
Exposes the Android SDK's composite
login(externalId, profile)(OneSignal-Android-SDK#2743) so wrapper apps can log in with a profile in a single request and get a typed result back.Scope
loginis unchanged (its void return type cannot change).success,data,error). Never throws or rejects; bad input resolvesINVALID_ARGUMENT, anything unexpected resolvesUNKNOWN.{ success: false, error: [{ code: "UNKNOWN", source: "CLIENT", message: "loginWithProfile is only supported on Android" }] }and calls no native iOS API, so it cannot crash or hang.5.11.0(unreleased, see the comment below).composite_login_*test IDs from the shared spec (sdk-shared#58).Public API
TurboModule spec gains
loginWithProfile(externalId, profile, jwt): Promise<Object>. Because the spec is shared,RCTOneSignalEventEmitter.mmimplements it too and resolves the Android-only envelope (JS also short-circuits on iOS first). Android bridge passes aContinuationfrom Java, handles the non-suspending return path, and resolves once.The promise never rejects, unlike other async APIs here. Callers branch on
success.Testing
Unit testing
475 tests pass (98.6% statements). Covers marshalling, result parsing (including dropped-null iOS dictionaries), validation, and the iOS envelope (fails if the guard is removed).
Manual testing
vp check,vp fmt --check,spotlessJavaCheck, demotscpass.:react-native-onesignal:compileDebugJavaWithJavacsucceeded against the locally published Android SDK; codegen signatures match. iOS not compiled locally, so the.mmchange relies on CI. Not run on a device.Affected code checklist
Checklist
Overview
Testing
Final pass