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
6
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 3.6.5 to 3.7.0

84

index.js

@@ -9,21 +9,39 @@

/**
1.
These events are used to broadcast events to native code
*/
const OS_REMOTE_NOTIFICATION_RECEIVED = 'OneSignal-remoteNotificationReceived';
const OS_REMOTE_NOTIFICATION_OPENED = 'OneSignal-remoteNotificationOpened';
const OS_IDS_AVAILABLE = 'OneSignal-idsAvailable';
//const OS_SUBSCRIPTION = 'OneSignal-subscription';
//const OS_PERMISSION = 'OneSignal-permission';
const OS_EMAIL_SUBSCRIPTION = 'OneSignal-emailSubscription';
const OS_IN_APP_MESSAGE_CLICKED = 'OneSignal-inAppMessageClicked';
// Add more native broadcast strings here...
const eventBroadcastNames = [
const _eventBroadcastNames = [
OS_REMOTE_NOTIFICATION_RECEIVED,
OS_REMOTE_NOTIFICATION_OPENED,
OS_IDS_AVAILABLE,
// OS_SUBSCRIPTION,
// OS_PERMISSION,
OS_EMAIL_SUBSCRIPTION,
OS_IN_APP_MESSAGE_CLICKED
OS_IN_APP_MESSAGE_CLICKED,
// Append new native broadcast strings here
];
/**
2.
These events are used to interpret events from native code
*/
const NOTIFICATION_RECEIVED_EVENT = "received";
const NOTIFICATION_OPENED_EVENT = "opened";
const IDS_AVAILABLE_EVENT = "ids";
//const SUBSCRIPTION_EVENT = "subscription";
//const PERMISSION_EVENT = "permission";
const EMAIL_SUBSCRIPTION_EVENT = "emailSubscription";
const IN_APP_MESSAGE_CLICKED_EVENT = "inAppMessageClicked";
// Add more JS string events here...

@@ -34,4 +52,7 @@ const _eventNames = [

IDS_AVAILABLE_EVENT,
// SUBSCRIPTION_EVENT,
// PERMISSION_EVENT,
EMAIL_SUBSCRIPTION_EVENT,
IN_APP_MESSAGE_CLICKED_EVENT
IN_APP_MESSAGE_CLICKED_EVENT,
// Append new JS string events here
];

@@ -48,4 +69,4 @@

for(var i = 0; i < eventBroadcastNames.length; i++) {
var eventBroadcastName = eventBroadcastNames[i];
for(var i = 0; i < _eventBroadcastNames.length; i++) {
var eventBroadcastName = _eventBroadcastNames[i];
var eventName = _eventNames[i];

@@ -78,7 +99,12 @@

export default class OneSignal {
/**
Listen to events of received, opened, ids, subscription, permission, emailSubscription, inAppMessageClicked
TODO: We currently have implemented the steps up until connecting the "SUBSCRIPTION_EVENT" and "PERMISSION_EVENT"
Currently the getPermissionSubscriptionState is used to get all device information and
needs to be broken up into using the native observers to fire these React-Native handlers
*/
static addEventListener(type, handler) {
if (!checkIfInitialized()) return;
// Listen to events of notification received, opened, device registered, IDSAvailable, and IAMClicked.
invariant(

@@ -88,5 +114,7 @@ type === NOTIFICATION_RECEIVED_EVENT ||

type === IDS_AVAILABLE_EVENT ||
// type === SUBSCRIPTION_EVENT ||
// type === PERMISSION_EVENT ||
type === EMAIL_SUBSCRIPTION_EVENT ||
type === IN_APP_MESSAGE_CLICKED_EVENT,
'OneSignal only supports `received`, `opened`, `ids`, `emailSubscription`, and `inAppMessageClicked` events'
'OneSignal only supports received, opened, ids, emailSubscription, and inAppMessageClicked events'
);

@@ -96,2 +124,3 @@

// Make native request to init notification opened handler
if (type === NOTIFICATION_OPENED_EVENT) {

@@ -101,3 +130,3 @@ RNOneSignal.initNotificationOpenedHandlerParams();

// triggers ids event
// Make native request to init idsAvailable handler
if (type === IDS_AVAILABLE_EVENT) {

@@ -107,2 +136,3 @@ RNOneSignal.idsAvailable();

// Make native request to init IAM handler
if (type === IN_APP_MESSAGE_CLICKED_EVENT) {

@@ -131,5 +161,7 @@ if (Platform.OS === 'android') {

type === IDS_AVAILABLE_EVENT ||
// type === SUBSCRIPTION_EVENT ||
// type === PERMISSION_EVENT ||
type === EMAIL_SUBSCRIPTION_EVENT ||
type === IN_APP_MESSAGE_CLICKED_EVENT,
'OneSignal only supports `received`, `opened`, `ids`, `emailSubscription`, and `inAppMessageClicked` events'
'OneSignal only supports received, opened, ids, emailSubscription, and inAppMessageClicked events'
);

@@ -302,15 +334,9 @@

if (emailAuthCode == undefined) {
//emailAuthCode is an optional parameter
//since JS does not support function overloading,
//unauthenticated setEmail calls will have emailAuthCode as the callback
if (emailAuthCode === undefined)
emailAuthCode = null;
RNOneSignal.setUnauthenticatedEmail(email, function(){});
} else if (callback == undefined && typeof emailAuthCode == 'function') {
RNOneSignal.setUnauthenticatedEmail(email, emailAuthCode);
} else if (callback == undefined) {
RNOneSignal.setEmail(email, emailAuthCode, function(){});
} else {
RNOneSignal.setEmail(email, emailAuthCode, callback);
}
if (callback === undefined)
callback = function(){};
RNOneSignal.setEmail(email, emailAuthCode, callback);
}

@@ -422,12 +448,18 @@

static setExternalUserId(externalId) {
static setExternalUserId(externalId, callback) {
if (!checkIfInitialized()) return;
RNOneSignal.setExternalUserId(externalId);
if (callback === undefined)
callback = function(){};
RNOneSignal.setExternalUserId(externalId, callback);
}
static removeExternalUserId() {
static removeExternalUserId(callback) {
if (!checkIfInitialized()) return;
RNOneSignal.removeExternalUserId();
if (callback === undefined)
callback = function(){};
RNOneSignal.removeExternalUserId(callback);
}

@@ -434,0 +466,0 @@

{
"name": "react-native-onesignal",
"version": "3.6.5",
"version": "3.7.0",
"description": "React Native OneSignal SDK",

@@ -5,0 +5,0 @@ "main": "index",

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

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