Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-onesignal

Package Overview
Dependencies
Maintainers
3
Versions
136
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.0.9 to 3.1.0

ios/RCTOneSignal/RCTOneSignalEventEmitter.h

59

index.js
'use strict';
import { NativeModules, NativeAppEventEmitter, NetInfo, Platform } from 'react-native';
import { NativeModules, NativeEventEmitter, NetInfo, Platform } from 'react-native';
import invariant from 'invariant';
var _eventBroadcastNames = [
const RNOneSignal = NativeModules.OneSignal;
var oneSignalEventEmitter = new NativeEventEmitter(RNOneSignal);
const eventBroadcastNames = [
'OneSignal-remoteNotificationReceived',
'OneSignal-remoteNotificationOpened',
'OneSignal-remoteNotificationsRegistered',
'OneSignal-idsAvailable'
'OneSignal-idsAvailable',
'OneSignal-emailSubscription'
];
var _eventNames = [ "received", "opened", "registered", "ids" ];
var _eventNames = [ "received", "opened", "ids", "emailSubscription"];

@@ -20,4 +24,4 @@ var _notificationHandler = new Map();

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];

@@ -28,12 +32,4 @@

var RNOneSignal = NativeModules.OneSignal;
var DEVICE_NOTIF_RECEIVED_EVENT = 'OneSignal-remoteNotificationReceived';
var DEVICE_NOTIF_OPENED_EVENT = 'OneSignal-remoteNotificationOpened';
var DEVICE_NOTIF_REG_EVENT = 'OneSignal-remoteNotificationsRegistered';
var DEVICE_IDS_AVAILABLE = 'OneSignal-idsAvailable';
function handleEventBroadcast(type, broadcast) {
return NativeAppEventEmitter.addListener(
return oneSignalEventEmitter.addListener(
broadcast, (notification) => {

@@ -51,2 +47,4 @@ // Check if we have added listener for this type yet

);
console.log("NATIVE MODULES: ", NativeModules);
}

@@ -74,3 +72,3 @@

invariant(
type === 'received' || type === 'opened' || type === 'registered' || type === 'ids',
type === 'received' || type === 'opened' || type === 'registered' || type === 'ids' || type == 'emailSubscription',
'OneSignal only supports `received`, `opened`, `registered`, and `ids` events'

@@ -91,3 +89,3 @@ );

invariant(
type === 'received' || type === 'opened' || type === 'registered' || type === 'ids',
type === 'received' || type === 'opened' || type === 'registered' || type === 'ids' || type == 'emailSubscription',
'OneSignal only supports `received`, `opened`, `registered`, and `ids` events'

@@ -202,2 +200,27 @@ );

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

@@ -204,0 +227,0 @@ static setLocationShared(shared) {

{
"name": "react-native-onesignal",
"version": "3.0.9",
"version": "3.1.0",
"description": "React Native OneSignal Component",

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

@@ -338,3 +338,2 @@ # React Native OneSignal

OneSignal.addEventListener('opened', this.onOpened);
OneSignal.addEventListener('registered', this.onRegistered);
OneSignal.addEventListener('ids', this.onIds);

@@ -346,3 +345,2 @@ }

OneSignal.removeEventListener('opened', this.onOpened);
OneSignal.removeEventListener('registered', this.onRegistered);
OneSignal.removeEventListener('ids', this.onIds);

@@ -362,6 +360,2 @@ }

onRegistered(notifData) {
console.log("Device had been registered for push notifications!", notifData);
}
onIds(device) {

@@ -441,2 +435,32 @@ console.log('Device info: ', device);

### Using Email Features
OneSignal now allows you to send emails to your userbase. This email can be set using the OneSignal react-native SDK.
To set the email:
```javascript
let emailAuthCode = ""; //Your email auth code should be securely generated by your backend server
OneSignal.setEmail("test@test.com", emailAuthCode, {(error) => {
//handle error if it occurred
}});
```
If you don't want to implement email auth hashing on your backend (which is heavily recommended), you can still use the OneSignal email feature in an unauthenticated state like this:
```javascript
OneSignal.setEmail("test@test.com", {(error) => {
//handle error if it occurred
}});
```
If your application implements logout functionality, you can logout of the OneSignal email for this user using the logout function:
```javascript
OneSignal.logoutEmail({(error) => {
//handle error if it occurred
}});
```
### Getting Player ID and Push Token

@@ -740,3 +764,6 @@

### Issue 6 - Make `react-native-onesignal` work with Redux
Please see the `examples/RNOneSignal/redux-index.js` file for example code and comments. Note that it will not compile, but instead serves as a template for how to handle Redux integration in general, and specifically including the edge case for intercepting the `onOpened` event when a User taps a push notification and prompts the app to open from a previously unopened state.
## CREDITS

@@ -743,0 +770,0 @@ Thanks for all the awesome fellows that contributed to this repository!

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

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