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

react-native-onesignal

Package Overview
Dependencies
Maintainers
11
Versions
137
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-onesignal - npm Package Compare versions

Comparing version 5.0.0 to 5.0.1

6

dist/events/EventManager.js

@@ -79,2 +79,8 @@ "use strict";

}
else if (eventName === events_1.PERMISSION_CHANGED) {
var typedPayload_1 = payload;
handlerArray.forEach(function (handler) {
handler(typedPayload_1.permission);
});
}
else {

@@ -81,0 +87,0 @@ handlerArray.forEach(function (handler) {

7

dist/index.d.ts
import { NotificationEventName, NotificationEventTypeMap, NotificationClickEvent } from './models/NotificationEvents';
import { OSNotificationPermission, PushSubscriptionChangedState } from './models/Subscription';
import { PushSubscriptionState, OSNotificationPermission, PushSubscriptionChangedState } from './models/Subscription';
import NotificationWillDisplayEvent from './events/NotificationWillDisplayEvent';
import { OutcomeEvent } from './models/Outcomes';
import { InAppMessage, InAppMessageEventTypeMap, InAppMessageEventName, InAppMessageClickEvent, InAppMessageWillDisplayEvent, InAppMessageDidDisplayEvent, InAppMessageWillDismissEvent, InAppMessageDidDismissEvent } from './models/InAppMessage';

@@ -233,5 +232,5 @@ export declare enum LogLevel {

}
export { NotificationWillDisplayEvent, NotificationClickEvent, InAppMessage, InAppMessageClickEvent, InAppMessageWillDisplayEvent, InAppMessageDidDisplayEvent, InAppMessageWillDismissEvent, InAppMessageDidDismissEvent, OutcomeEvent, };
export { NotificationWillDisplayEvent, NotificationClickEvent, InAppMessage, InAppMessageClickEvent, InAppMessageWillDisplayEvent, InAppMessageDidDisplayEvent, InAppMessageWillDismissEvent, InAppMessageDidDismissEvent, PushSubscriptionState, PushSubscriptionChangedState, OSNotificationPermission, };
export { default as OSNotification } from './OSNotification';
export { NotificationClickResult } from './models/NotificationEvents';
export { OSNotificationPermission } from './models/Subscription';
export { InAppMessageClickResult } from './models/InAppMessage';

@@ -42,3 +42,3 @@ 'use strict';

Object.defineProperty(exports, "__esModule", { value: true });
exports.NotificationWillDisplayEvent = exports.OneSignal = exports.LogLevel = void 0;
exports.OSNotificationPermission = exports.NotificationWillDisplayEvent = exports.OneSignal = exports.LogLevel = void 0;
var react_native_1 = require("react-native");

@@ -48,2 +48,3 @@ var EventManager_1 = __importDefault(require("./events/EventManager"));

var Subscription_1 = require("./models/Subscription");
Object.defineProperty(exports, "OSNotificationPermission", { enumerable: true, get: function () { return Subscription_1.OSNotificationPermission; } });
var NotificationWillDisplayEvent_1 = __importDefault(require("./events/NotificationWillDisplayEvent"));

@@ -749,3 +750,1 @@ exports.NotificationWillDisplayEvent = NotificationWillDisplayEvent_1.default;

Object.defineProperty(exports, "OSNotification", { enumerable: true, get: function () { return OSNotification_1.default; } });
var Subscription_2 = require("./models/Subscription");
Object.defineProperty(exports, "OSNotificationPermission", { enumerable: true, get: function () { return Subscription_2.OSNotificationPermission; } });

@@ -29,6 +29,25 @@ # React Native v5.0.0 Migration Guide

# Migration Guide (v3 to v5)
# Migration Guide (v4 to v5)
The React Native SDK accesses the OneSignal native iOS and Android SDKs. For this update, all SDK versions are aligning across OneSignal’s suite of client SDKs. As such, the React Native SDK is making the jump from `v3` to `v5`.
The React Native SDK accesses the OneSignal native iOS and Android SDKs. For this update, all SDK versions are aligning across OneSignal’s suite of client SDKs. As such, the native iOS SDK is making the jump from `v3` to `v5`. See existing install instructions [here](https://documentation.onesignal.com/docs/react-native-sdk-setup) for more information.
## iOS
### Notification Service Extension Changes
In your Project Root > ios > Podfile, update the notification service extension:
```
// 4.x.x
target 'OneSignalNotificationServiceExtension' do
pod 'OneSignalXCFramework', '>= 3.0', '< 4.0'
end
// 5.x.x
target 'OneSignalNotificationServiceExtension' do
pod 'OneSignalXCFramework', '>= 5.0', '< 6.0'
end
```
Close Xcode. While still in the ios directory, run `pod install --repo-update`.
# API Changes

@@ -52,3 +71,3 @@

Initialization of the OneSignal SDK is now completed through the `init` method. A typical initialization now looks similar to below.
Initialization of the OneSignal SDK is now completed through the `initialize` method. A typical initialization now looks similar to below.

@@ -76,3 +95,3 @@ Navigate to your index.ts file, or the first Javascript file that loads with your app.

```typescript
OneSignal.User.login('USER_EXTERNAL_ID');
OneSignal.login('USER_EXTERNAL_ID');
```

@@ -85,3 +104,3 @@

```typescript
OneSignal.User.logout();
OneSignal.logout();
```

@@ -100,7 +119,5 @@

```typescript
const id: string =
await OneSignal.User.pushSubscription.getPushSubscriptionId();
const token: string =
await OneSignal.User.pushSubscription.getPushSubscriptionToken();
const optedIn: boolean = await OneSignal.User.pushSubscription.getOptedIn();
const id: string = OneSignal.User.pushSubscription.getPushSubscriptionId();
const token: string = OneSignal.User.pushSubscription.getPushSubscriptionToken();
const optedIn: boolean = OneSignal.User.pushSubscription.getOptedIn();
```

@@ -110,3 +127,3 @@

To receive push notifications on the device, call the push subscription’s `optIn` method. If needed, this method will prompt the user for push notifications permission.
To receive push notifications on the device, call the push subscription’s `optIn()` method. If needed, this method will prompt the user for push notifications permission.

@@ -154,4 +171,4 @@ Note: For greater control over prompting for push notification permission, you may use the `OneSignal.Notifications.requestPermission` method detailed below in the API Reference.

| `OneSignal.initialize("YOUR_ONESIGNAL_APP_ID")` | _Initializes the OneSignal SDK. This should be called during startup of the application._ |
| `OneSignal.User.login("USER_EXTERNAL_ID")` | _Login to OneSignal under the user identified by the [externalId] provided. The act of logging a user into the OneSignal SDK will switch the [user] context to that specific user.<br><br> - If the [externalId] exists, the user will be retrieved and the context will be set from that user information. If operations have already been performed under a device-scoped user, they **_will not_** be applied to the now logged in user (they will be lost).<br> - If the [externalId] does not exist the user, the user will be created and the context set from the current local state. If operations have already been performed under a device-scoped user, those operations **_will_** be applied to the newly created user.<br><br>**_Push Notifications and In App Messaging_**<br>Logging in a new user will automatically transfer the push notification and in app messaging subscription from the current user (if there is one) to the newly logged in user. This is because both push notifications and in-app messages are owned by the device._ |
| `OneSignal.User.logout()` | _Logout the user previously logged in via [login]. The [user] property now references a new device-scoped user. A device-scoped user has no user identity that can later be retrieved, except through this device as long as the app remains installed and the app data is not cleared._ |
| `OneSignal.login("USER_EXTERNAL_ID")` | _Login to OneSignal under the user identified by the [externalId] provided. The act of logging a user into the OneSignal SDK will switch the [user] context to that specific user.<br><br> - If the [externalId] exists, the user will be retrieved and the context will be set from that user information. If operations have already been performed under a device-scoped user, they **_will not_** be applied to the now logged in user (they will be lost).<br> - If the [externalId] does not exist the user, the user will be created and the context set from the current local state. If operations have already been performed under a device-scoped user, those operations **_will_** be applied to the newly created user.<br><br>**_Push Notifications and In App Messaging_**<br>Logging in a new user will automatically transfer the push notification and in app messaging subscription from the current user (if there is one) to the newly logged in user. This is because both push notifications and in-app messages are owned by the device._ |
| `OneSignal.logout()` | _Logout the user previously logged in via [login]. The [user] property now references a new device-scoped user. A device-scoped user has no user identity that can later be retrieved, except through this device as long as the app remains installed and the app data is not cleared._ |
| `OneSignal.setConsentGiven(true)` | _Indicates whether privacy consent has been granted. This field is only relevant when the application has opted into data privacy protections. See [requiresPrivacyConsent]._ |

@@ -164,3 +181,3 @@ | `OneSignal.setConsentRequired(true)` | _Determines whether a user must consent to privacy prior to their user data being sent up to OneSignal. This should be set to `true` prior to the invocation of `initialize` to ensure compliance._

Please refer to OneSignal’s guide on [Live Activities](https://documentation.onesignal.com/docs/live-activities), the [Live Activities Quickstart](https://documentation.onesignal.com/docs/live-activities-quickstart) tutorial, and the [existing SDK reference](https://documentation.onesignal.com/docs/sdk-reference#live-activities) on Live Activities.
Please refer to OneSignal’s guide on [Live Activities](https://documentation.onesignal.com/docs/live-activities), the [Live Activities Quickstart](https://documentation.onesignal.com/docs/live-activities-quickstart) tutorial, and the [existing SDK reference](https://documentation.onesignal.com/docs/live-activities-sdk-methods) on Live Activities.

@@ -212,14 +229,12 @@ | **React Native** | **Description** |

| --------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `await OneSignal.User.pushSubscription.getId()` | _The readonly push subscription ID._ |
| `await OneSignal.User.pushSubscription.getToken()` | _The readonly push token._ |
| `await OneSignal.User.pushSubscription.getOptedIn()` | _Gets a boolean value indicating whether the current user is opted in to push notifications. This returns `true` when the app has notifications permission and `optedOut` is called. **_Note:_** Does not take into account the existence of the subscription ID and push token. This boolean may return `true` but push notifications may still not be received by the user._ |
| `OneSignal.User.pushSubscription.getPushSubscriptionId()` | _The readonly push subscription ID._ |
| `OneSignal.User.pushSubscription.getPushSubscriptionToken()` | _The readonly push token._ |
| `OneSignal.User.pushSubscription.getOptedIn()` | _Gets a boolean value indicating whether the current user is opted in to push notifications. This returns `true` when the app has notifications permission and `optedOut` is called. **_Note:_** Does not take into account the existence of the subscription ID and push token. This boolean may return `true` but push notifications may still not be received by the user._ |
| `OneSignal.User.pushSubscription.optIn()` | _Call this method to receive push notifications on the device or to resume receiving of push notifications after calling `optOut`. If needed, this method will prompt the user for push notifications permission._ |
| `OneSignal.User.pushSubscription.optOut()` | _If at any point you want the user to stop receiving push notifications on the current device (regardless of system-level permission status), you can call this method to opt out._ |
| `OneSignal.User.pushSubscription.addEventListener('change', listener: (event) => void)`<br><br>**_See below for usage_** | _The `OSPushSubscriptionObserver.onPushSubscriptionDidChange` method will be fired on the passed-in object when the push subscription changes._ |
| `OneSignal.User.pushSubscription.removeEventListener('change', listener)`<br><br>**_See below for usage_** | _Remove a push subscription observer that has been previously added._ |
| `OneSignal.User.pushSubscription.addEventListener('change', listener: (event) => void)`<br><br>**_See below for usage_** | _Adds the listener to run when the push subscription changes._ |
| `OneSignal.User.pushSubscription.removeEventListener('change', listener)`<br><br>**_See below for usage_** | _Remove a push subscription listener that has been previously added._ |
### Push Subscription Observer
Any object implementing the `OSPushSubscriptionObserver` protocol can be added as an observer. You can call `removeEventListener` to remove any existing listeners.
```typescript

@@ -249,10 +264,11 @@ // Create an observer

| **React Native** | **Description** |
| **React Native** | **Description** |
|--------------------------------------- | --------------- |
| `await OneSignal.Notifications.hasPermission()` | _Whether this app has push notification permission._ |
| `await OneSignal.Notifications.canRequestPermission()` | _Whether attempting to request notification permission will show a prompt. Returns `true` if the device has not been prompted for push notification permission already._ | `await OneSignal.Notifications.permissionNative()` | _(ios only) Returns the enum for the native permission of the device. It will be one of: NotDetermined, Denied, Authorized, Provisional (only available in iOS 12), Ephemeral (only available in iOS 14) _ |
| `OneSignal.Notifications.hasPermission()` | _Whether this app has push notification permission._ |
| `await OneSignal.Notifications.canRequestPermission()` | _Whether attempting to request notification permission will show a prompt. Returns `true` if the device has not been prompted for push notification permission already._ |
| `await OneSignal.Notifications.permissionNative()` | _(ios only) Returns the enum for the native permission of the device. It will be one of: NotDetermined, Denied, Authorized, Provisional (only available in iOS 12), Ephemeral (only available in iOS 14)_ |
| `OneSignal.Notifications.clearAll();` | _Removes all OneSignal notifications._ |
| `OneSignal.Notifications.removeNotification(32432)` | _(Android only) Cancels a single OneSignal notification based on its Android notification integer ID. Use instead of Android's [android.app.NotificationManager.cancel], otherwise the notification will be restored when your app is restarted._ |
| `OneSignal.Notifications.removeGroupedNotifications("GROUP_KEY")` | _(Android only) Cancels a group of OneSignal notifications with the provided group key. Grouping notifications is a OneSignal concept, there is no [android.app.NotificationManager] equivalent._ |
| `OneSignal.Notifications.requestPermission()`<br><br>**_See below for usage_** | _Prompt the user for permission to receive push notifications. This will display the native system prompt to request push notification permission._ |
| `await OneSignal.Notifications.requestPermission(fallbackToSettings: boolean)`<br><br>**_See below for usage_** | _Prompt the user for permission to receive push notifications. This will display the native system prompt to request push notification permission._ |
| `OneSignal.Notifications.registerForProvisionalAuthorization()` | _(iOS only) Instead of having to prompt the user for permission to send them push notifications, your app can request provisional authorization._ |

@@ -267,3 +283,3 @@ | `OneSignal.Notifications.addEventListener("permissionChange", (observer) => {});`<br><br>**_See below for usage_** | _This method will fire when a notification permission setting changes. This happens when the user enables or disables notifications for your app from the system settings outside of your app._ |

```typescript
OneSignal.Notifications.requestPermission((accepted) => {
OneSignal.Notifications.requestPermission(true).then(accepted => {
console.log('User accepted notifications: ' + accepted);

@@ -279,3 +295,3 @@ });

// Add an observer
OneSignal.Notifications.addEventListener('permissionChange', (granted) =>{
OneSignal.Notifications.addEventListener('permissionChange', (granted: boolean) => {
console.log('OneSignal: permission changed:', granted);

@@ -291,3 +307,3 @@ });

```typescript
OneSignal.Notifications.addEventListener('foregroundWillDisplay', (event) => {
OneSignal.Notifications.addEventListener('foregroundWillDisplay', (event: NotificationWillDisplayEvent) => {
event.preventDefault();

@@ -304,3 +320,3 @@ // some async work

```typescript
OneSignal.Notifications.addEventListener('click', (event) => {
OneSignal.Notifications.addEventListener('click', (event: NotificationClickEvent) => {
console.log('OneSignal: notification clicked: ' + event);

@@ -316,12 +332,6 @@ });

| ----------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `await OneSignal.Location.isShared()` <br><br>**_See below for usage_** | _Whether location is currently shared with OneSignal._ |
| `OneSignal.Location.setShared(shared: boolean)` | _Set whether location is currently shared with OneSignal._ |
| `await OneSignal.Location.isShared()` | _Whether location is currently shared with OneSignal._ |
| `OneSignal.Location.requestPermission()` | _Use this method to manually prompt the user for location permissions. This allows for geotagging so you send notifications to users based on location._ |
### isShared method
```typescript
const shared: boolean = await OneSignal.Location.isShared();
console.log('Location shared: ', shared);
```
## InAppMessages Namespace

@@ -333,3 +343,3 @@

| ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `await OneSignal.InAppMessages.getPaused()`<br><br>**_See below for usage_**<br><br>`OneSignal.InAppMessages.setPaused(true)` | _Whether in-app messaging is currently paused. When set to `true`, no IAM will be presented to the user regardless of whether they qualify for them. When set to `false`, any IAMs the user qualifies for will be presented to the user at the appropriate time._ |
| `await OneSignal.InAppMessages.getPaused()`<br><br>`OneSignal.InAppMessages.setPaused(true)` | _Whether in-app messaging is currently paused. When set to `true`, no IAM will be presented to the user regardless of whether they qualify for them. When set to `false`, any IAMs the user qualifies for will be presented to the user at the appropriate time._ |
| `OneSignal.InAppMessages.addTrigger("triggerKey", "triggerValue")` | _Add a trigger for the current user. Triggers are currently explicitly used to determine whether a specific IAM should be displayed to the user. See [Triggers](https://documentation.onesignal.com/docs/iam-triggers).<br><br>If the trigger key already exists, it will be replaced with the value provided here. Note that triggers are not persisted to the backend. They only exist on the local device and are applicable to the current user._ |

@@ -343,9 +353,2 @@ | `OneSignal.InAppMessages.addTriggers({"triggerKey1":"triggerValue", "triggerKey2": "triggerValue"})` | _Add multiple triggers for the current user. Triggers are currently explicitly used to determine whether a specific IAM should be displayed to the user. See [Triggers](https://documentation.onesignal.com/docs/iam-triggers).<br><br>If any trigger key already exists, it will be replaced with the value provided here. Note that triggers are not persisted to the backend. They only exist on the local device and are applicable to the current user._ |

### In-App Message isPaused method
```typescript
const paused = await OneSignal.InAppMessages.getPaused();
console.log('IAM paused: ', paused);
```
### In-App Message Click Listener

@@ -352,0 +355,0 @@

{
"name": "react-native-onesignal",
"version": "5.0.0",
"version": "5.0.1",
"description": "React Native OneSignal SDK",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -100,2 +100,7 @@ import {

});
} else if (eventName === PERMISSION_CHANGED) {
const typedPayload = payload as { permission: boolean };
handlerArray.forEach((handler) => {
handler(typedPayload.permission);
});
} else {

@@ -102,0 +107,0 @@ handlerArray.forEach((handler) => {

@@ -27,3 +27,2 @@ 'use strict';

import NotificationWillDisplayEvent from './events/NotificationWillDisplayEvent';
import { OutcomeEvent } from './models/Outcomes';
import {

@@ -795,3 +794,5 @@ InAppMessage,

InAppMessageDidDismissEvent,
OutcomeEvent,
PushSubscriptionState,
PushSubscriptionChangedState,
OSNotificationPermission,
};

@@ -801,2 +802,2 @@

export { NotificationClickResult } from './models/NotificationEvents';
export { OSNotificationPermission } from './models/Subscription';
export { InAppMessageClickResult } from './models/InAppMessage';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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