Skip to content

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

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

Task<LoginResult> LoginWithProfileAsync(String externalId, OneSignalUserProfile profile, String? jwtBearerToken = null);

On IOneSignal and the static OneSignal. New OneSignalUserProfile, LoginResult (Success, Data, Error), LoginData, OneSignalError in OneSignalSDK.DotNet.Core/User/. Codes are strings, matching the wire shape.

  • Android: LoginResultContinuation implements Kotlin.Coroutines.IContinuation against the generated Login(..., IContinuation) binding (no Metadata.xml change needed). Handles the non-COROUTINE_SUSPENDED return, completes a TaskCompletionSource exactly once, and maps Result$Failure / exceptions to UNKNOWN. Result is marshalled via ToMap() and the repo's Json.Deserialize.
  • iOS: returns the envelope from iOSOneSignal.cs; no native call.

Testing

Unit testing

No test project in the repo. A scratch console app (not committed) ran 17 parser cases: success, backend and client failures, malformed and wrong-type input.

Manual testing

With the locally published 5.11.0 AARs: dotnet build of the Core binding, Android, iOS and OneSignalSDK.DotNet, plus the demo for net10.0-android and net10.0-ios, all succeeded. Android emulator: invalid email and SMS returned INVALID_ARGUMENT from native, an empty externalId was caught in C#, and the await resumed on the main thread. A real backend login was not run.

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 IOneSignal.LoginWithProfileAsync returning a typed LoginResult parsed from the native OneSignalResult.toMap() envelope.
Android bridges the suspend login(externalId, profile, jwt) through a Kotlin Continuation; iOS returns an unsupported failure.
Bumps versions.json to Android 5.11.0; the binding AARs still need update_native_binaries.sh once 5.11.0 is on Maven Central.
Demo gains a LOGIN WITH PROFILE button and dialog on Android.

Co-authored-by: Cursor <cursoragent@cursor.com>
@abdulraqeeb33
abdulraqeeb33 requested a review from a team October 13, 2026 16:01
@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 targets OneSignal Android SDK 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).
  2. This repo commits the native AARs under each binding's Jars/. Only versions.json is bumped here; the AARs are still 5.10.2, so OneSignalSDK.DotNet.Android will not compile (no OneSignalUserProfile / OneSignalResult) until we run ./update_native_binaries.sh --android_native_version=5.11.0 after the release and commit the result to this branch.
  3. Local verification built against 5.11.0-composite-local AARs, which I published from Android main into my own ~/.m2 (mavenLocal). Those AARs were reverted and are not in this diff.
  4. Plan: release Android 5.11.0, update the binaries on this branch, re-run CI, then mark ready.

AR Abdul Azeez and others added 2 commits October 13, 2026 11:21
Reject a success envelope that carries errors, and report and log the
native exception message instead of the kotlin.Result wrapper.

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