Skip to content

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

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

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

public abstract Task<LoginResult> LoginWithProfileAsync(string externalId, OneSignalUserProfile profile, string jwtBearerToken = null);

Plus static OneSignal.LoginWithProfileAsync. New OneSignalUserProfile and LoginResult (Success, Data, Errors). Parsing uses the bundled MiniJSON; no new dependency.

  • Android: reuses the SDK's public com.onesignal.Continue.with (same as RequestPermissionAsync), so no new Java plugin file. A non-suspending return is detected by checking for a OneSignalResult instance rather than the stdlib COROUTINE_SUSPENDED marker, which R8 can rename under JNI lookup.
  • iOS: returns the envelope in OneSignaliOS.cs. No new DllImport, so no IL2CPP link risk. Editor stub does the same.

Open naming question for reviewers: the list is Errors (C# plural) while the other wrappers mirror the wire key error.

Testing

Unit testing

No repo test harness. A scratch parser test (not committed) passed 21/21 including the real native JSON.

Manual testing

Roslyn compile of SDK core/Android/iOS/Editor and demo scripts with all defines pass; csharpier check and validate-unity-distribution.py pass. javac against the locally published aar confirmed every signature used. Not run in the Editor or on a device (no Unity license on the build machine).

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.LoginWithProfileAsync(externalId, profile, jwt) returning a typed LoginResult.
Android calls the native suspend login through Continue.with and parses OneSignalResult.toMap().
iOS and the Editor return the unsupported failure without touching native code.
Bumps the native Android SDK to 5.11.0 and adds LOGIN WITH PROFILE to the demo.

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 2 commits October 13, 2026 11:07
Rename LoginData.OnesignalId to OneSignalId to match User.OneSignalId.
Build the Consumer proxy inside the guard so it can never throw, log native
failures once, use the exception message, and reject success with errors.

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