New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More β†’
Socket
Sign inDemoInstall
Socket

react-onesignal

Package Overview
Dependencies
Maintainers
9
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-onesignal - npm Package Compare versions

Comparing version 3.0.0-beta.5 to 3.0.0

132

dist/index.d.ts

@@ -44,55 +44,97 @@ declare global {

declare type NotificationEventName = 'click' | 'foregroundWillDisplay' | 'dismiss' | 'permissionChange' | 'permissionPromptDisplay';
interface NotificationButtonData extends NotificationAction {
url: string;
}
declare type SlidedownEventName = 'slidedownShown';
declare type OneSignalDeferredLoadedCallback = (onesignal: IOneSignalOneSignal) => void;
declare type OSNotification = {
id?: string;
title?: string;
body?: string;
data?: any;
url?: string;
icon?: string;
image?: string;
tag?: string;
requireInteraction?: boolean;
renotify?: true;
actions?: Array<NotificationActionButton>;
};
declare type NotificationActionButton = {
action: string;
title: string;
icon?: string;
url?: string;
};
export declare type NotificationClickResult = {
actionId?: string;
url?: string;
};
interface IOSNotification {
/**
* The OneSignal notification id;
* - Primary id on OneSignal's REST API and dashboard
*/
readonly notificationId: string;
/**
* Visible title text on the notification
*/
readonly title?: string;
/**
* Visible body text on the notification
*/
readonly body: string;
/**
* Visible icon the notification; URL format
*/
readonly icon?: string;
/**
* Visible small badgeIcon that displays on some devices; URL format
* Example: On Android's status bar
*/
readonly badgeIcon?: string;
/**
* Visible image on the notification; URL format
*/
readonly image?: string;
/**
* Visible buttons on the notification
*/
readonly actionButtons?: IOSNotificationActionButton[];
/**
* If this value is the same as existing notification, it will replace it
* Can be set when creating the notification with "Web Push Topic" on the dashboard
* or web_push_topic from the REST API.
*/
readonly topic?: string;
/**
* Custom object that was sent with the notification;
* definable when creating the notification from the OneSignal REST API or dashboard
*/
readonly additionalData?: object;
/**
* URL to open when clicking or tapping on the notification
*/
readonly launchURL?: string;
/**
* Confirm the push was received by reporting back to OneSignal
*/
readonly confirmDelivery: boolean;
}
interface IOSNotificationActionButton {
/**
* Any unique identifier to represent which button was clicked. This is typically passed back to the service worker
* and host page through events to identify which button was clicked.
* e.g. 'like-button'
*/
readonly actionId: string;
/**
* The notification action button's text.
*/
readonly text: string;
/**
* A valid publicly reachable HTTPS URL to an image.
*/
readonly icon?: string;
/**
* The URL to open the web browser to when this action button is clicked.
*/
readonly launchURL?: string;
}
interface NotificationClickResult {
readonly actionId?: string;
readonly url?: string;
}
declare type NotificationEventTypeMap = {
'click': NotificationClickResult;
'click': NotificationClickEvent;
'foregroundWillDisplay': NotificationForegroundWillDisplayEvent;
'dismiss': OSNotificationDataPayload;
'dismiss': NotificationDismissEvent;
'permissionChange': boolean;
'permissionPromptDisplay': void;
};
export declare type NotificationForegroundWillDisplayEvent = {
notification: OSNotification;
interface NotificationForegroundWillDisplayEvent {
readonly notification: IOSNotification;
preventDefault(): void;
};
declare type OSNotificationDataPayload = {
id: string;
content: string;
heading?: string;
url?: string;
data?: object;
rr?: string;
icon?: string;
image?: string;
tag?: string;
badge?: string;
vibrate?: VibratePattern;
buttons?: NotificationButtonData[];
};
}
interface NotificationDismissEvent {
notification: IOSNotification;
}
interface NotificationClickEvent {
readonly notification: IOSNotification;
readonly result: NotificationClickResult;
}
interface IInitObject {

@@ -99,0 +141,0 @@ appId: string;

@@ -120,12 +120,115 @@ const ONESIGNAL_SDK_ID = 'onesignal-sdk';

type NotificationEventName = 'click' | 'foregroundWillDisplay' | 'dismiss' | 'permissionChange' | 'permissionPromptDisplay';
interface NotificationButtonData extends NotificationAction { url: string; };
type SlidedownEventName = 'slidedownShown';
type OneSignalDeferredLoadedCallback = (onesignal: IOneSignalOneSignal) => void;
type OSNotification = { id?: string; title?: string; body?: string; data?: any; url?: string; icon?: string; image?: string; tag?: string; requireInteraction?: boolean; renotify?: true; actions?: Array<NotificationActionButton>; };
type NotificationActionButton = { action: string; title: string; icon?: string; url?: string; }
export type NotificationClickResult = { actionId?: string; url?: string; }
type NotificationEventTypeMap = { 'click': NotificationClickResult; 'foregroundWillDisplay': NotificationForegroundWillDisplayEvent; 'dismiss': OSNotificationDataPayload; 'permissionChange': boolean; 'permissionPromptDisplay': void; };
export type NotificationForegroundWillDisplayEvent = { notification: OSNotification; preventDefault(): void; }
type OSNotificationDataPayload = { id: string; content: string; heading?: string; url?: string; data?: object; rr?: string; icon?: string; image?: string; tag?: string; badge?: string; vibrate?: VibratePattern; buttons?: NotificationButtonData[]; };
interface IOSNotification {
/**
* The OneSignal notification id;
* - Primary id on OneSignal's REST API and dashboard
*/
readonly notificationId: string;
/**
* Visible title text on the notification
*/
readonly title?: string;
/**
* Visible body text on the notification
*/
readonly body: string;
/**
* Visible icon the notification; URL format
*/
readonly icon?: string;
/**
* Visible small badgeIcon that displays on some devices; URL format
* Example: On Android's status bar
*/
readonly badgeIcon?: string;
/**
* Visible image on the notification; URL format
*/
readonly image?: string;
/**
* Visible buttons on the notification
*/
readonly actionButtons?: IOSNotificationActionButton[];
/**
* If this value is the same as existing notification, it will replace it
* Can be set when creating the notification with "Web Push Topic" on the dashboard
* or web_push_topic from the REST API.
*/
readonly topic?: string;
/**
* Custom object that was sent with the notification;
* definable when creating the notification from the OneSignal REST API or dashboard
*/
readonly additionalData?: object;
/**
* URL to open when clicking or tapping on the notification
*/
readonly launchURL?: string;
/**
* Confirm the push was received by reporting back to OneSignal
*/
readonly confirmDelivery: boolean;
}
interface IOSNotificationActionButton {
/**
* Any unique identifier to represent which button was clicked. This is typically passed back to the service worker
* and host page through events to identify which button was clicked.
* e.g. 'like-button'
*/
readonly actionId: string;
/**
* The notification action button's text.
*/
readonly text: string;
/**
* A valid publicly reachable HTTPS URL to an image.
*/
readonly icon?: string;
/**
* The URL to open the web browser to when this action button is clicked.
*/
readonly launchURL?: string;
}
interface NotificationClickResult {
readonly actionId?: string;
readonly url?: string;
}
type NotificationEventTypeMap = {
'click': NotificationClickEvent;
'foregroundWillDisplay': NotificationForegroundWillDisplayEvent;
'dismiss': NotificationDismissEvent;
'permissionChange': boolean;
'permissionPromptDisplay': void;
}
interface NotificationForegroundWillDisplayEvent {
readonly notification: IOSNotification;
preventDefault(): void;
}
interface NotificationDismissEvent {
notification: IOSNotification;
}
interface NotificationClickEvent {
readonly notification: IOSNotification;
readonly result: NotificationClickResult;
}
interface IInitObject {

@@ -132,0 +235,0 @@ appId: string;

@@ -115,12 +115,12 @@

| Sync/Async | Function / Property | Description | Argument List |
| ---------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `async` | `setDefaultUrl()` | Sets the default URL for notifications. | `url` (string) |
| `async` | `setDefaultTitle()` | Sets the default title for notifications. | `title` (string) |
| `sync` | `isPushSupported()` | Returns true if the current browser supports web push. | |
| `async` | `requestPermission()` | Requests push notifications permission via the native browser prompt. | |
| `sync` | `addEventListener()` | Adds an event listener for the following events:<br><br>- `click`<br>- `willDisplay`<br>- `dismiss`<br>- `permissionPromptDisplay`<br>- `permissionChange`*<br> * argument type: bool | - `<event>` (string)<br>- `(arg: <type>) => {}` (callback) |
| `sync` | `removeEventListener()` | Removes the event listener. | `() => {}` (the event listener you want to remove) |
| | `permission` | A boolean representing whether or not the user has granted permission for push notifications. | |
| | `permissionNative` | A string representing the native push permission status: 'default', 'granted', or 'denied'. | |
| Sync/Async | Property/Function | Description | Argument List |
| ---------- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `async` | `setDefaultUrl()` | Sets the default URL for notifications. | `url` (string) |
| `async` | `setDefaultTitle()` | Sets the default title for notifications. | `title` (string) |
| `sync` | `isPushSupported()` | Returns true if the current browser supports web push. | |
| `async` | `requestPermission()` | Requests push notifications permission via the native browser prompt. | |
| | `permission` | Returns true if your site has permission to display notifications. | |
| | `permissionNative` | Returns browser's native notification permission status; `"default"`(end-user has not accept or decided yet), `"granted"`, or `"denied"`. | |
| `sync` | `addEventListener()` | Adds an event listener for the following events:<br><br>- `click`<br>- `foregroundWillDisplay`<br>- `dismiss`<br>- `permissionPromptDisplay`<br>- `permissionChange`*<br> * argument type: bool | - `<event>` (string)<br>- `(arg: <type>) => {}` (callback) |
| `sync` | `removeEventListener()` | Removes the event listener. | `() => {}` (the event listener you want to remove) |

@@ -162,4 +162,4 @@

| `async` | `optOut()` | Unsubscribes the current user from push notifications. | |
| `sync` | `addEventListener()` | Adds an event listener for the `subscriptionChange` event. | - `event` ("subscriptionChange")<br>- `listener` ((change: SubscriptionChangeEvent) => void) |
| `sync` | `removeEventListener()` | Removes an event listener for the `subscriptionChange` event. | - `event` ("subscriptionChange")<br>- `listener` ((change: SubscriptionChangeEvent) => void) |
| `sync` | `addEventListener()` | Adds an event listener for the `change` event. | - `event` ("change")<br>- `listener` ((change: SubscriptionChangeEvent) => void) |
| `sync` | `removeEventListener()` | Removes an event listener for the `change` event. | - `event` ("change")<br>- `listener` ((change: SubscriptionChangeEvent) => void) |

@@ -178,23 +178,6 @@ ### Debug Namespace

# Limitations
## May 2023
## Version 16 (beta)
Please test thoroughly prior to production use.
* Any User namespace calls must be invoked **after** initialization (async). Example: `OneSignal.User.addTag("tag", "2");`
* HTTP environments are not supported.
* HTTP environments are no longer supported.
* AMP environments are not supported.
* Identity verification is not functional.
* Identity verification not available yet, coming soon.
## January 2023
### Version 16 (alpha)
It is recommended this version is used **only** in development and staging envrionments.
* Switching between users via `login()` and `logout()` is unsafe. **Please stick to single user testing.**
* Any User namespace calls must be invoked **after** initialization (async). Example: `OneSignal.User.addTag("tag", "2");`
* Aliases will be available in a future release,
* HTTP environments are not supported.
* AMP environments are not supported.
* Identity verification is not functional.
* Outcomes are not functional.
# Glossary

@@ -347,2 +330,2 @@

Enjoy!
</details>
</details>
{
"name": "react-onesignal",
"version": "3.0.0-beta.5",
"version": "3.0.0",
"description": "React OneSignal Module: Make it easy to integrate OneSignal with your React App!",

@@ -5,0 +5,0 @@ "author": "rgomezp",

@@ -1,6 +0,15 @@

<p align="center">
<img src="https://media.onesignal.com/cms/Website%20Layout/logo-red.svg"/>
<br/>
<br/>
<span style="color: grey !important">Showing web push notifications from Chrome, Safari, and Firefox</span>
<h1 align="center">Welcome to react-onesignal πŸ‘‹</h1>
<p>
<a href="https://www.npmjs.com/package/react-onesignal" target="_blank">
<img alt="Version" src="https://img.shields.io/npm/v/react-onesignal.svg">
</a>
<a href="https://github.com/OneSignal/react-onesignal#readme" target="_blank">
<img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" />
</a>
<a href="https://github.com/OneSignal/react-onesignal/graphs/commit-activity" target="_blank">
<img alt="Maintenance" src="https://img.shields.io/badge/Maintained%3F-yes-green.svg" />
</a>
<a href="https://twitter.com/onesignal" target="_blank">
<img alt="Twitter: onesignal" src="https://img.shields.io/twitter/follow/onesignal.svg?style=social" />
</a>
</p>

@@ -10,3 +19,4 @@

This is a JavaScript module that can be used to easily include [OneSignal](https://onesignal.com/) code in a website or app that uses React for its front-end codebase.
* 🏠 [Homepage](https://github.com/OneSignal/react-onesignal#readme)
* πŸ–€ [npm](https://www.npmjs.com/package/react-onesignal)

@@ -18,6 +28,4 @@ OneSignal is the world's leader for Mobile Push Notifications, Web Push, and In-App Messaging. It is trusted by 2 million+ businesses to send 9 billion Push Notifications per day.

### Migration Guides
Versions 2.0 and 3.0 were recently released and include breaking changes. See the [Migration Guide](https://github.com/OneSignal/react-onesignal/blob/user-model/v1/MigrationGuide.md) to update your implementation.
Versions 3.0 were recently released and include breaking changes. See the [Migration Guide](https://github.com/OneSignal/react-onesignal/blob/main/MigrationGuide.md) to update your implementation.
> ATTENTION: v3 is currently in Beta 🚧 and includes a fundamental shift to the OneSignal subscriber ("player") model. Learn more [here](https://documentation.onesignal.com/v11.0/docs/user-model).
## Contents

@@ -153,72 +161,8 @@ - [Install](#install)

|-|-|
|'click' | NotificationClickResult|
|'click' | NotificationClickEvent|
|'foregroundWillDisplay'| NotificationForegroundWillDisplayEvent
| 'dismiss'| OSNotificationDataPayload|
| 'dismiss'| NotificationDismissEvent|
|'permissionChange'| boolean|
|'permissionPromptDisplay'| void|
<details>
<summary>Expand to see associated types</summary>
#### `NotificationClickResult`
| Property | Description |
|-------------------------|---------------------------------------------|
| `actionId` | A string representing the action ID associated with the click event |
| `url` | A string representing the URL associated with the click event |
#### `NotificationForegroundWillDisplayEvent`
| Property | Description |
|-------------------------|---------------------------------------------|
| `notification` | An `OSNotification` type object |
#### `OSNotification`
| Property | Description |
|-----------------------|----------------------------------------------------------------------------------------------------------------------|
| `id` | Optional string representing the unique identifier of the notification. |
| `title` | Optional string representing the title of the notification. |
| `body` | Optional string representing the body of the notification. |
| `data` | Optional data object associated with the notification. |
| `url` | Optional string representing the URL to be opened when the notification is clicked. |
| `icon` | Optional string representing the URL of the icon to be displayed with the notification. |
| `image` | Optional string representing the URL of the image to be displayed with the notification. |
| `tag` | Optional string representing a unique identifier for a group of notifications. |
| `requireInteraction` | Optional boolean indicating whether the notification requires user interaction or not. |
| `renotify` | Optional boolean indicating whether the notification should be replaced or not, if a notification with the same tag is already displayed. |
| `actions` | Optional array of `NotificationActionButton` objects representing the action buttons associated with the notification. |
#### `NotificationActionButton`
| Property | Description |
|-------------|-----------------------------------------------------------------------------------------------|
| `action` | A string representing the action associated with the button. |
| `title` | A string representing the title of the button. |
| `icon` | Optional string representing the URL of the icon to be displayed with the button. |
| `url` | Optional string representing the URL to be opened when the button is clicked. |
#### `OSNotificationDataPayload`
| Property | Description |
|-------------|-----------------------------------------------------------------------------------------------|
| `id` | A string representing the unique identifier of the notification data payload. |
| `content` | A string representing the content of the notification data payload. |
| `heading` | Optional string representing the heading of the notification data payload. |
| `url` | Optional string representing the URL to be opened when the notification data payload is clicked. |
| `data` | Optional object containing additional data associated with the notification data payload. |
| `rr` | Optional string with value 'y' or 'n' representing whether or not the notification has [Confirmed Delivery](https://documentation.onesignal.com/docs/confirmed-deliveries). |
| `icon` | Optional string representing the URL of the icon to be displayed with the notification data payload. |
| `image` | Optional string representing the URL of the image to be displayed with the notification data payload. |
| `tag` | Optional string representing a unique identifier for a group of notification data payloads. |
| `badge` | Optional string representing the URL of the badge to be displayed with the notification data payload. |
| `vibrate` | Optional array of numbers representing the vibration pattern of the notification data payload. |
| `buttons` | Optional array of `NotificationButtonData` objects representing the button data associated with the notification data payload. |
#### `NotificationButtonData`
| Property | Description |
|----------|------------------------------------------------------------------------------------------------------|
| `url` | A string representing the URL to be opened when the button is clicked. |
| `id` | A string representing the ID of the action. |
| `action` | A string representing the type of the action (inherited from `NotificationAction`). |
| `title` | A string representing the title of the action button (inherited from `NotificationAction`). |
| `icon` | Optional string representing the URL of the icon to be displayed with the action button. |
</details>
### Slidedown Namespace

@@ -236,4 +180,4 @@ | Event Name | Callback Argument Type |

```js
OneSignal.Notifications.addEventListener('click', (result) => {
console.log("The notification was clicked!", result);
OneSignal.Notifications.addEventListener('click', (event) => {
console.log("The notification was clicked!", event);
});

@@ -240,0 +184,0 @@ ```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc