Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Resolve OneSignal Android SDK version
id: android-sdk-version
run: |
VERSION=$(grep -E '^onesignal\s*=' android/gradle/libs.versions.toml | sed -E 's/.*"([^"]+)".*/\1/')
VERSION=$(grep -E '^onesignal\s*=\s*"' android/gradle/libs.versions.toml | sed -E 's/.*"([^"]+)".*/\1/')
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"

- name: Wait for OneSignal Android SDK on Maven Central
Expand Down
73 changes: 6 additions & 67 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,75 +2,14 @@

# Using Vite+, the Unified Toolchain for the Web

This project is using Vite+, a unified toolchain built on top of Vite, Rolldown, Vitest, tsdown, Oxlint, Oxfmt, and Vite Task. Vite+ wraps runtime management, package management, and frontend tooling in a single global CLI called `vp`. Vite+ is distinct from Vite, but it invokes Vite through `vp dev` and `vp build`.
This project is using Vite+, a unified toolchain built on top of Vite, Rolldown, Vitest, tsdown, Oxlint, Oxfmt, and Vite Task. Vite+ wraps runtime management, package management, and frontend tooling in a single global CLI called `vp`. Vite+ is distinct from Vite, and it invokes Vite through `vp dev` and `vp build`. Run `vp help` to print a list of commands and `vp <command> --help` for information about a specific command.

## Vite+ Workflow
Docs are local at `node_modules/vite-plus/docs` or online at https://viteplus.dev/guide/.

`vp` is a global binary that handles the full development lifecycle. Run `vp help` to print a list of commands and `vp <command> --help` for information about a specific command.

### Start

- create - Create a new project from a template
- migrate - Migrate an existing project to Vite+
- config - Configure hooks and agent integration
- staged - Run linters on staged files
- install (`i`) - Install dependencies
- env - Manage Node.js versions

### Develop

- dev - Run the development server
- check - Run format, lint, and TypeScript type checks
- lint - Lint code
- fmt - Format code
- test - Run tests

### Execute

- run - Run monorepo tasks
- exec - Execute a command from local `node_modules/.bin`
- dlx - Execute a package binary without installing it as a dependency
- cache - Manage the task cache

### Build

- build - Build for production
- pack - Build libraries
- preview - Preview production build

### Manage Dependencies

Vite+ automatically detects and wraps the underlying package manager such as pnpm, npm, or Yarn through the `packageManager` field in `package.json` or package manager-specific lockfiles.

- add - Add packages to dependencies
- remove (`rm`, `un`, `uninstall`) - Remove packages from dependencies
- update (`up`) - Update packages to latest versions
- dedupe - Deduplicate dependencies
- outdated - Check for outdated packages
- list (`ls`) - List installed packages
- why (`explain`) - Show why a package is installed
- info (`view`, `show`) - View package information from the registry
- link (`ln`) / unlink - Manage local package links
- pm - Forward a command to the package manager

### Maintain

- upgrade - Update `vp` itself to the latest version

These commands map to their corresponding tools. For example, `vp dev --port 3000` runs Vite's dev server and works the same as Vite. `vp test` runs JavaScript tests through the bundled Vitest. The version of all tools can be checked using `vp --version`. This is useful when researching documentation, features, and bugs.

## Common Pitfalls

- **Using the package manager directly:** Do not use pnpm, npm, or Yarn directly. Vite+ can handle all package manager operations.
- **Always use Vite commands to run tools:** Don't attempt to run `vp vitest` or `vp oxlint`. They do not exist. Use `vp test` and `vp lint` instead.
- **Running scripts:** Vite+ commands take precedence over `package.json` scripts. If there is a `test` script defined in `scripts` that conflicts with the built-in `vp test` command, run it using `vp run test`.
- **Do not install Vitest, Oxlint, Oxfmt, or tsdown directly:** Vite+ wraps these tools. They must not be installed directly. You cannot upgrade these tools by installing their latest versions. Always use Vite+ commands.
- **Use Vite+ wrappers for one-off binaries:** Use `vp dlx` instead of package-manager-specific `dlx`/`npx` commands.
- **Import JavaScript modules from `vite-plus`:** Instead of importing from `vite` or `vitest`, all modules should be imported from the project's `vite-plus` dependency. For example, `import { defineConfig } from 'vite-plus';` or `import { expect, test, vi } from 'vite-plus/test';`. You must not install `vitest` to import test utilities.
- **Type-Aware Linting:** There is no need to install `oxlint-tsgolint`, `vp lint --type-aware` works out of the box.

## Review Checklist for Agents
## Review Checklist

- [ ] Run `vp install` after pulling remote changes and before getting started.
- [ ] Run `vp check` and `vp test` to validate changes.
- [ ] Run `vp check` and `vp test` to format, lint, type check and test changes.
- [ ] Check if there are `vite.config.ts` tasks or `package.json` scripts necessary for validation, run via `vp run <script>`.

<!--VITE PLUS END-->
66 changes: 16 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ See the `examples/demo` directory for a full working example.

<docgen-index>

* [`initialize(...)`](#initialize)
* [`login(...)`](#login)
* [`logout()`](#logout)
* [`setConsentRequired(...)`](#setconsentrequired)
* [`setConsentGiven(...)`](#setconsentgiven)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)
- [`initialize(...)`](#initialize)
- [`login(...)`](#login)
- [`logout()`](#logout)
- [`setConsentRequired(...)`](#setconsentrequired)
- [`setConsentGiven(...)`](#setconsentgiven)
- [Interfaces](#interfaces)
- [Type Aliases](#type-aliases)

</docgen-index>

Expand All @@ -51,8 +51,7 @@ Initialize the SDK with your OneSignal app ID. Call during app startup.
| ----------- | ------------------- |
| **`appId`** | <code>string</code> |

--------------------

---

### login(...)

Expand All @@ -66,8 +65,7 @@ Log in to OneSignal as the user identified by `externalId`, switching the user c
| ---------------- | ------------------- |
| **`externalId`** | <code>string</code> |

--------------------

---

### logout()

Expand All @@ -77,8 +75,7 @@ logout() => Promise<void>

Log out the current user. The SDK will reference a new device-scoped user.

--------------------

---

### setConsentRequired(...)

Expand All @@ -92,8 +89,7 @@ Set whether user privacy consent is required before sending data to OneSignal. C
| -------------- | -------------------- |
| **`required`** | <code>boolean</code> |

--------------------

---

### setConsentGiven(...)

Expand All @@ -107,12 +103,10 @@ Indicate whether the user has granted privacy consent.
| ------------- | -------------------- |
| **`granted`** | <code>boolean</code> |

--------------------

---

### Interfaces


#### OneSignalDebugAPI

Debug helpers exposed via `OneSignal.Debug`.
Expand All @@ -122,7 +116,6 @@ Debug helpers exposed via `OneSignal.Debug`.
| **setLogLevel** | (logLevel: <a href="#loglevel">LogLevel</a>) =&gt; void | Set the log level printed to LogCat (Android) or the Xcode console (iOS). |
| **setAlertLevel** | (visualLogLevel: <a href="#loglevel">LogLevel</a>) =&gt; void | Set the log level shown to the user as alert dialogs. |


#### OneSignalUserAPI

Current-user operations exposed via `OneSignal.User`.
Expand Down Expand Up @@ -153,22 +146,19 @@ Current-user operations exposed via `OneSignal.User`.
| **getExternalId** | () =&gt; Promise&lt;string \| null&gt; | Get the external ID set via `login`, or null if the user is anonymous. |
| **trackEvent** | (name: string, properties?: object \| undefined) =&gt; Promise&lt;void&gt; | Track a custom event with an optional set of JSON-serializable properties. |


#### UserChangedState

| Prop | Type |
| ------------- | ----------------------------------------------- |
| **`current`** | <code><a href="#userstate">UserState</a></code> |


#### UserState

| Prop | Type |
| ----------------- | ------------------- |
| **`onesignalId`** | <code>string</code> |
| **`externalId`** | <code>string</code> |


#### OneSignalPushSubscriptionAPI

Push subscription state and controls exposed via `OneSignal.User.pushSubscription`.
Expand All @@ -183,15 +173,13 @@ Push subscription state and controls exposed via `OneSignal.User.pushSubscriptio
| **optIn** | () =&gt; Promise&lt;void&gt; | Opt the user in to push notifications. Prompts for permission if needed. |
| **optOut** | () =&gt; Promise&lt;void&gt; | Opt the user out of push notifications on this device. |


#### PushSubscriptionChangedState

| Prop | Type |
| -------------- | ----------------------------------------------------------------------- |
| **`previous`** | <code><a href="#pushsubscriptionstate">PushSubscriptionState</a></code> |
| **`current`** | <code><a href="#pushsubscriptionstate">PushSubscriptionState</a></code> |


#### PushSubscriptionState

| Prop | Type |
Expand All @@ -200,7 +188,6 @@ Push subscription state and controls exposed via `OneSignal.User.pushSubscriptio
| **`token`** | <code>string</code> |
| **`optedIn`** | <code>boolean</code> |


#### OneSignalNotificationsAPI

Notification permission and event handling exposed via `OneSignal.Notifications`.
Expand All @@ -218,23 +205,20 @@ Notification permission and event handling exposed via `OneSignal.Notifications`
| **removeNotification** | (id: number) =&gt; Promise&lt;void&gt; | Android only. Cancel a single notification by its Android notification ID. |
| **removeGroupedNotifications** | (id: string) =&gt; Promise&lt;void&gt; | Android only. Cancel a group of notifications by group key. |


#### NotificationClickEvent

| Prop | Type |
| ------------------ | --------------------------------------------------------------------------- |
| **`result`** | <code><a href="#notificationclickresult">NotificationClickResult</a></code> |
| **`notification`** | <code>OSNotification</code> |


#### NotificationClickResult

| Prop | Type |
| -------------- | ------------------- |
| **`actionId`** | <code>string</code> |
| **`url`** | <code>string</code> |


#### OneSignalInAppMessagesAPI

In-app message triggers and event handling exposed via `OneSignal.InAppMessages`.
Expand All @@ -251,22 +235,19 @@ In-app message triggers and event handling exposed via `OneSignal.InAppMessages`
| **setPaused** | (pause: boolean) =&gt; void | Pause or resume the display of in-app messages. |
| **getPaused** | () =&gt; Promise&lt;boolean&gt; | Whether in-app messaging is currently paused. |


#### InAppMessageClickEvent

| Prop | Type |
| ------------- | --------------------------------------------------------------------------- |
| **`message`** | <code><a href="#osinappmessage">OSInAppMessage</a></code> |
| **`result`** | <code><a href="#inappmessageclickresult">InAppMessageClickResult</a></code> |


#### OSInAppMessage

| Prop | Type |
| --------------- | ------------------- |
| **`messageId`** | <code>string</code> |


#### InAppMessageClickResult

| Prop | Type |
Expand All @@ -276,35 +257,30 @@ In-app message triggers and event handling exposed via `OneSignal.InAppMessages`
| **`url`** | <code>string</code> |
| **`urlTarget`** | <code><a href="#inappmessageactionurltype">InAppMessageActionUrlType</a></code> |


#### InAppMessageWillDisplayEvent

| Prop | Type |
| ------------- | --------------------------------------------------------- |
| **`message`** | <code><a href="#osinappmessage">OSInAppMessage</a></code> |


#### InAppMessageDidDisplayEvent

| Prop | Type |
| ------------- | --------------------------------------------------------- |
| **`message`** | <code><a href="#osinappmessage">OSInAppMessage</a></code> |


#### InAppMessageWillDismissEvent

| Prop | Type |
| ------------- | --------------------------------------------------------- |
| **`message`** | <code><a href="#osinappmessage">OSInAppMessage</a></code> |


#### InAppMessageDidDismissEvent

| Prop | Type |
| ------------- | --------------------------------------------------------- |
| **`message`** | <code><a href="#osinappmessage">OSInAppMessage</a></code> |


#### OneSignalSessionAPI

Outcome reporting exposed via `OneSignal.Session`.
Expand All @@ -315,7 +291,6 @@ Outcome reporting exposed via `OneSignal.Session`.
| **addUniqueOutcome** | (name: string) =&gt; Promise&lt;void&gt; | <a href="#record">Record</a> a unique outcome with the given name against the current session. |
| **addOutcomeWithValue** | (name: string, value: number) =&gt; Promise&lt;void&gt; | <a href="#record">Record</a> an outcome with the given name and value against the current session. |


#### OneSignalLocationAPI

Location permission and sharing exposed via `OneSignal.Location`.
Expand All @@ -326,7 +301,6 @@ Location permission and sharing exposed via `OneSignal.Location`.
| **setShared** | (shared: boolean) =&gt; void | Enable or disable sharing the device location with OneSignal. |
| **isShared** | () =&gt; Promise&lt;boolean&gt; | Whether the device location is currently shared with OneSignal. |


#### OneSignalLiveActivitiesAPI

Live activity controls exposed via `OneSignal.LiveActivities`. iOS only unless noted.
Expand All @@ -340,56 +314,48 @@ Live activity controls exposed via `OneSignal.LiveActivities`. iOS only unless n
| **setupDefault** | (options?: <a href="#liveactivitysetupoptions">LiveActivitySetupOptions</a> \| undefined) =&gt; Promise&lt;void&gt; | Set up the OneSignal default live activity, optionally enabling pushToStart/pushToUpdate. |
| **startDefault** | (activityId: string, attributes: <a href="#record">Record</a>&lt;string, unknown&gt;, content: <a href="#record">Record</a>&lt;string, unknown&gt;) =&gt; Promise&lt;void&gt; | Start a live activity backed by the OneSignal default attributes type. |


### Type Aliases


#### LogLevel

<code>(typeof <a href="#loglevel">LogLevel</a>)[keyof typeof LogLevel]</code>


#### Record

Construct a type with a set of properties K of type T

<code>{ [P in K]: T; }</code>

<code>{
[P in K]: T;
}</code>

#### OSNotificationPermission

<code>(typeof <a href="#osnotificationpermission">OSNotificationPermission</a>)[keyof typeof OSNotificationPermission]</code>


#### NotificationEventName

<code>'click' | 'foregroundWillDisplay' | 'permissionChange'</code>


#### NotificationEventTypeMap

<code>{ click: <a href="#notificationclickevent">NotificationClickEvent</a>; foregroundWillDisplay: NotificationWillDisplayEvent; permissionChange: boolean; }</code>


#### InAppMessageEventName

<code>'click' | 'willDisplay' | 'didDisplay' | 'willDismiss' | 'didDismiss'</code>


#### InAppMessageEventTypeMap

<code>{ click: <a href="#inappmessageclickevent">InAppMessageClickEvent</a>; willDisplay: <a href="#inappmessagewilldisplayevent">InAppMessageWillDisplayEvent</a>; didDisplay: <a href="#inappmessagediddisplayevent">InAppMessageDidDisplayEvent</a>; willDismiss: <a href="#inappmessagewilldismissevent">InAppMessageWillDismissEvent</a>; didDismiss: <a href="#inappmessagediddismissevent">InAppMessageDidDismissEvent</a>; }</code>


#### InAppMessageActionUrlType

<code>'browser' | 'webview' | 'replacement'</code>


#### LiveActivitySetupOptions

The setup options for `OneSignal.LiveActivities.setupDefault`.

<code>{ /** * When true, OneSignal will listen for pushToStart tokens for the `OneSignalLiveActivityAttributes` structure. */ enablePushToStart: boolean; /** * When true, OneSignal will listen for pushToUpdate tokens for each start live activity that uses the * `OneSignalLiveActivityAttributes` structure. */ enablePushToUpdate: boolean; }</code>
<code>{ /** _ When true, OneSignal will listen for pushToStart tokens for the `OneSignalLiveActivityAttributes` structure. _/ enablePushToStart: boolean; /** _ When true, OneSignal will listen for pushToUpdate tokens for each start live activity that uses the _ `OneSignalLiveActivityAttributes` structure. \*/ enablePushToUpdate: boolean; }</code>

</docgen-api>
2 changes: 1 addition & 1 deletion android/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ compileSdk = "35"
junit = "4.13.2"
kotlin = "1.9.25"
minSdk = "23"
onesignal = "5.8.1"
onesignal = "5.9.1"
targetSdk = "35"

[libraries]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class OneSignalCapacitorPlugin : Plugin(),
initialized = true

OneSignalWrapper.sdkType = "capacitor"
OneSignalWrapper.sdkVersion = "010002"
OneSignalWrapper.sdkVersion = "010003"
OneSignal.initWithContext(context, appId)

// If the SDK was initialized from a non-Activity context (FCM/work
Expand Down
Loading
Loading