Skip to content

chore: [SDK-5619] standardize push subscription UI in the demo apps - #76

Merged
fadi-george merged 5 commits into
mainfrom
fadi/sdk-5619
Oct 27, 2026
Merged

fadi-george merged 5 commits into
mainfrom
fadi/sdk-5619

Conversation

@fadi-george

@fadi-george fadi-george commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Description

One Line Summary

Standardize the demo push subscription UI and add a language selector.

capacitor_android_01_push_status_subscribed capacitor_android_02_opted_out_unsubscribed capacitor_android_03_language_row capacitor_android_04_language_picker_open capacitor_android_05_spanish_selected capacitor_ios_01_push_status_subscribed capacitor_ios_02_opted_out_unsubscribed capacitor_ios_03_language_row capacitor_ios_04_language_picker_open capacitor_ios_05_spanish_selected

Details

Motivation

SDK-5619, part of SDK-5300 (standardize push subscription UI across SDK demo apps). Matches the Android demo (OneSignal/OneSignal-Android-SDK#2760) and the Cordova demo (OneSignal/OneSignal-Cordova-SDK#1216). Spec: sdk-shared/demo/build.md.

Scope

Demo apps only: examples/demo and examples/demo_pods, which each have their own src, so the change is applied to both. SDK unchanged. demo_cap7, demo-nx and demo-no-location have no Push or User section.

  • Push section: new read-only Status row above the toggle. It shows Subscribed only when the user is opted in, notification permission is granted, and a push token is present; otherwise Unsubscribed. It updates from the existing subscription and permission observers, and the push token is now tracked too.
  • The toggle label changes from "Enabled" to Opted In. The existing test ID is unchanged, so Appium selectors still work. The status row uses push_subscription_status, same as Android.
  • User section: new Language row after External ID with Device Default plus the same 43 languages, in the same order, as Android and iOS (user_language_dropdown). It calls setLanguage(code), and Device Default sends '', which the native SDK resolves to the device language. The choice is saved only so the picker shows it after a restart; it is not re-sent at launch, since native keeps its own value. Logout resets it to Device Default, as Android and iOS do.
  • Picker: Ionic IonSelect popover with a single down chevron (toggleIcon={chevronDown}), the value right-aligned next to it, and the open menu widened to 280px and capped at half the screen height (.language-popover).

Testing

Unit testing

No unit tests; demo UI reading existing SDK state.

Manual testing

vp run lint, vp test run, tsc --noEmit and vp run build pass for both demos (vp fmt --check flags only README.md, already unformatted on main). Ran examples/demo on an Android emulator and an iOS 26.5 simulator: Status switches between Subscribed and Unsubscribed with the toggle, and selecting Spanish then Device Default works (the native SDK sends es, then the device language).

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • 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
    • If it is hard to explain how any codes changes are related to each other then it most likely needs to be more than one PR
  • 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
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
    • Simplify with less code, followed by splitting up code into well named functions and variables, followed by adding comments to the code.
  • I have reviewed this PR myself, ensuring it meets each checklist item
    • WIP (Work In Progress) is ok, but explain what is still in progress and what you would like feedback on. Start the PR title with "WIP" to indicate this.

🤖 Generated with Claude Code

fadi-george and others added 3 commits October 27, 2026 11:27
…emos

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fadi-george
fadi-george requested a review from a team October 27, 2026 18:59

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multi-model review (Opus 5.5, GPT 5.6 Sol, Grok 4.7) of this demo-only Status / Opted In / language-picker change.

The two copies stay aligned, test IDs are preserved, and Status is derived the way the spec describes. Two correctness gaps are worth fixing:

  1. Language picker can go stale on user switch. Logout resets via setLanguage(''), but loginUser (and stored-id login at startup) leave the cached picker value. Native starts a new user with no language, so the dropdown can show the previous choice while the SDK uses device default or a backend value.
  2. The picker commits even when native does not. setLanguage fire-and-forgets the SDK call and always writes preferences + React state. If iOS drops the call under missing privacy consent, or the promise rejects, the UI stays wrong across restarts because language is never re-sent at launch.

Also consider: setPushEnabled still updates isPushEnabled immediately, so the new Status row can flash Subscribed before opt-in succeeds; and adding getTokenAsync() to the existing Promise.all in load() means one reject skips isReady / the push prompt.

Open in Web View Automation 

Sent by Cursor Automation: PR Reviews

Comment thread examples/demo/src/hooks/useOneSignal.ts
Comment thread examples/demo/src/hooks/useOneSignal.ts Outdated

@abdulraqeeb33 abdulraqeeb33 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found.

The language list, empty-string reset, and logout-only cache clear match the Android and iOS demos. push_enabled_toggle is unchanged, and the shared Appium spec selects that id.

The picker staying as-is across login is the same behavior those demos ship. I would leave it.

useOneSignal.ts (both demos) repeats the empty-code reset already stated in examples/build.md.

@abdulraqeeb33 abdulraqeeb33 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by my earlier review. Fadi's inline replies confirm the picker/login behavior is intentional cross-demo parity (per sdk-shared/demo/build.md); dropping these nits. GitHub won't let me self-dismiss the approval.

fadi-george and others added 2 commits October 27, 2026 13:16
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…etLanguage

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fadi-george
fadi-george merged commit 8269ef5 into main Oct 27, 2026
2 checks passed
@fadi-george
fadi-george deleted the fadi/sdk-5619 branch October 27, 2026 20:38
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.

2 participants