Skip to content

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

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

abdulraqeeb33 wants to merge 4 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

OneSignal.loginWithProfile(externalId: string, profile: OneSignalUserProfile, jwtBearerToken?: string): Promise<LoginResult>

Exports OneSignalUserProfile, LoginResult, LoginData, LoginError, LoginErrorCode, LoginErrorSource. The Android plugin is Kotlin, so it calls the suspend OneSignal.login directly on the existing pluginScope. iOS and web short-circuit in TypeScript via Capacitor.getPlatform(); Swift is untouched.

Testing

Unit testing

301 tests pass (99.1% statements, 97.1% branches). The iOS-envelope test fails if the platform guard is removed.

Manual testing

bun run lint and demo tsc pass for demo and demo_pods. :onesignal-capacitor-plugin:compileDebugKotlin succeeded against the locally published Android SDK. format:check (README.md) and verify (missing example node modules) fail identically on main. Not run on a device or iOS.

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(externalId, profile, jwt?) resolving with a typed
LoginResult parsed from the native OneSignalResult.toMap() envelope. iOS and web
resolve with an UNKNOWN failure from the TS layer. Bumps Android SDK to 5.11.0
and adds a LOGIN WITH PROFILE flow to the demo apps.

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.

AR Abdul Azeez and others added 3 commits October 13, 2026 11:09
Reject a success envelope that also carries errors, log native login
failures, cover web in the platform guard test, and drop stale demo results
when a logout or another login happens during the await.

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>
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