react-native-onesignal
Advanced tools
Comparing version 3.0.4 to 3.0.5
54
index.js
@@ -9,6 +9,6 @@ | ||
var DEVICE_NOTIF_RECEIVED_EVENT = 'remoteNotificationReceived'; | ||
var DEVICE_NOTIF_OPENED_EVENT = 'remoteNotificationOpened'; | ||
var DEVICE_NOTIF_REG_EVENT = 'remoteNotificationsRegistered'; | ||
var DEVICE_IDS_AVAILABLE = 'idsAvailable'; | ||
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'; | ||
@@ -90,3 +90,3 @@ const _notifHandlers = new Map(); | ||
static registerForPushNotifications() { | ||
if (Platform.OS == 'ios') { | ||
if (Platform.OS === 'ios') { | ||
RNOneSignal.registerForPushNotifications(); | ||
@@ -97,6 +97,18 @@ } else { | ||
} | ||
static promptForPushNotificationsWithUserResponse(callback: Function) { | ||
if (Platform.OS === 'ios') { | ||
invariant( | ||
typeof callback === 'function', | ||
'Must provide a valid callback' | ||
); | ||
RNOneSignal.promptForPushNotificationsWithUserResponse(callback); | ||
} else { | ||
console.log("This function is not supported on Android"); | ||
} | ||
} | ||
static requestPermissions(permissions) { | ||
var requestedPermissions = {}; | ||
if (Platform.OS == 'ios') { | ||
if (Platform.OS === 'ios') { | ||
if (permissions) { | ||
@@ -126,3 +138,3 @@ requestedPermissions = { | ||
static checkPermissions(callback: Function) { | ||
if (Platform.OS == 'ios') { | ||
if (Platform.OS === 'ios') { | ||
invariant( | ||
@@ -138,2 +150,10 @@ typeof callback === 'function', | ||
static getPermissionSubscriptionState(callback: Function) { | ||
invariant( | ||
typeof callback === 'function', | ||
'Must provide a valid callback' | ||
); | ||
RNOneSignal.getPermissionSubscriptionState(callback); | ||
} | ||
static sendTag(key, value) { | ||
@@ -156,3 +176,3 @@ RNOneSignal.sendTag(key, value); | ||
static enableVibrate(enable) { | ||
if (Platform.OS == 'android') { | ||
if (Platform.OS === 'android') { | ||
RNOneSignal.enableVibrate(enable); | ||
@@ -165,3 +185,3 @@ } else { | ||
static enableSound(enable) { | ||
if (Platform.OS == 'android') { | ||
if (Platform.OS === 'android') { | ||
RNOneSignal.enableSound(enable); | ||
@@ -186,3 +206,3 @@ } else { | ||
static inFocusDisplaying(displayOption) { | ||
if (Platform.OS == 'android') { | ||
if (Platform.OS === 'android') { | ||
RNOneSignal.inFocusDisplaying(displayOption); | ||
@@ -192,7 +212,7 @@ } | ||
static postNotification(contents, data, player_id) { | ||
if (Platform.OS == 'android') { | ||
RNOneSignal.postNotification(JSON.stringify(contents), JSON.stringify(data), player_id); | ||
static postNotification(contents, data, player_id, otherParameters) { | ||
if (Platform.OS === 'android') { | ||
RNOneSignal.postNotification(JSON.stringify(contents), JSON.stringify(data), player_id, JSON.stringify(otherParameters)); | ||
} else { | ||
RNOneSignal.postNotification(contents, data, player_id); | ||
RNOneSignal.postNotification(contents, data, player_id, otherParameters); | ||
} | ||
@@ -202,3 +222,3 @@ } | ||
static clearOneSignalNotifications() { | ||
if (Platform.OS == 'android') { | ||
if (Platform.OS === 'android') { | ||
RNOneSignal.clearOneSignalNotifications(); | ||
@@ -211,3 +231,3 @@ } else { | ||
static cancelNotification(id) { | ||
if (Platform.OS == 'android') { | ||
if (Platform.OS === 'android') { | ||
RNOneSignal.cancelNotification(id); | ||
@@ -228,2 +248,2 @@ } else { | ||
} | ||
} |
{ | ||
"name": "react-native-onesignal", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"description": "React Native OneSignal Component", | ||
@@ -5,0 +5,0 @@ "main": "index", |
@@ -31,2 +31,3 @@ # React Native OneSignal | ||
- [Change User Subscription Status](#change-user-subscription-status) | ||
- [Check Push Notification and User Subscription Status](#check-push-notification-and-user-subscription-status) | ||
- [Post Notification (Peer-to-Peer Notifications)](#post-notification-peer-to-peer-notifications) | ||
@@ -196,11 +197,2 @@ - [Prompt Location](#prompt-location) | ||
* After `application ` insert the code for the notification event: | ||
```objc | ||
// Required for the notification event. | ||
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification { | ||
[RCTOneSignal didReceiveRemoteNotification:notification]; | ||
} | ||
``` | ||
* You're All Set! | ||
@@ -403,2 +395,16 @@ | ||
### Check Push Notification and User Subscription Status | ||
We exposed the getPermissionSubscriptionState API of OneSignal (both Android & iOS). | ||
*Allows you to check whether notifications are enabled for the app, whether user is subscribed to notifications through OneSignal, and what the user's in-app subscription preference is. It also provides access to pushToken and userId* | ||
```javascript | ||
// Check push notification and OneSignal subscription statuses | ||
OneSignal.getPermissionSubscriptionState((status) => { | ||
console.log(status); | ||
}); | ||
``` | ||
### Post Notification (Peer-to-Peer Notifications) | ||
@@ -405,0 +411,0 @@ |
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
433047
198
625
72