Skip to content

feat: [SDK-5024] add loginWithProfile (Android only) - #1191

Draft
abdulraqeeb33 wants to merge 2 commits into
mainfrom
ar/sdk-5024-composite-login
Draft

abdulraqeeb33 wants to merge 2 commits into
mainfrom
ar/sdk-5024-composite-login

Conversation

@abdulraqeeb33

Copy link
Copy Markdown
Contributor

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

  • New method only. Existing login is unchanged (its void return type cannot change).
  • Returns a result mirroring the Android wire shape (success, data, error). Never throws or rejects; bad input resolves INVALID_ARGUMENT, anything unexpected resolves UNKNOWN.
  • iOS: the iOS SDK has no equivalent yet. On iOS this resolves immediately with { 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.
  • Android native dependency bumped to 5.11.0 (unreleased, see the comment below).
  • Demo: "LOGIN WITH PROFILE" button and dialog, Android only, with the composite_login_* test IDs from the shared spec (sdk-shared#58).

Public API

static Future<OSLoginResult> loginWithProfile(String externalId, OSUserProfile profile, [String? jwtBearerToken])

New types in lib/src/loginresult.dart: OSUserProfile, OSLoginResult, OSLoginData, OSResultError. iOS short-circuits in Dart; Objective-C is untouched. Android bridge passes a Continuation from Java and handles the non-suspending return path; the reply fires once on the main thread.

Testing

Unit testing

288 tests pass (98.2% coverage). Covers argument marshalling, success/failure/malformed envelopes, input validation, and the iOS envelope (fails if the platform guard is removed).

Manual testing

flutter analyze, dart format, spotlessJavaCheck clean. flutter build apk --debug of examples/demo succeeded against the locally published Android SDK. Not run on a device or iOS. examples/demo-pods not updated (it has drifted from demo).

Affected code checklist

  • Notifications
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible (Android jobs cannot resolve 5.11.0 until it is released, see comment)
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
  • I have reviewed this PR myself, ensuring it meets each checklist item

Adds OneSignal.loginWithProfile, which logs in and applies an email, SMS,
tags and aliases in one request and resolves with a typed OSLoginResult.
Android calls the native suspend login through a Continuation; iOS returns
a failure envelope from Dart. Bumps native Android to 5.11.0.

Co-authored-by: Cursor <cursoragent@cursor.com>
@abdulraqeeb33
abdulraqeeb33 requested a review from a team October 13, 2026 15:52
@abdulraqeeb33

Copy link
Copy Markdown
Contributor Author

Heads-up on the native Android dependency, so the red Android CI doesn't cause alarm:

  1. This bumps the OneSignal Android SDK to 5.11.0, which is not published yet. It is the release that will carry login(externalId, profile) (OneSignal-Android-SDK#2743, API dump in #2787). Until it is on Maven Central, Android jobs here fail to resolve it. Expected, and why this is a draft.
  2. Local verification compiled against 5.11.0-composite-local, which I published from Android main into my own ~/.m2 (mavenLocal). Neither mavenLocal() nor that version is in this diff. The committed version is 5.11.0 only.
  3. Plan: release Android 5.11.0, re-run CI, then mark ready for review.

Reject a success envelope that carries errors, log native failures, and
surface the exception message instead of its toString.

Co-authored-by: Cursor <cursoragent@cursor.com>
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