react-native-onesignal
Advanced tools
Comparing version 4.3.11 to 4.4.0
@@ -73,7 +73,13 @@ import { DeviceState, ChangeEvent, PermissionChange, SubscriptionChange, EmailSubscriptionChange, SMSSubscriptionChange } from './models/Subscription'; | ||
/** | ||
* Prompts the iOS user for push notifications. | ||
* Prompts the user for push notifications permission in iOS and Android 13+. | ||
* Use the fallbackToSettings parameter to prompt to open the settings app if a user has already declined push permissions. | ||
* | ||
* Call with promptForPushNotificationsWithUserResponse(fallbackToSettings?, handler?) | ||
* | ||
* Recommended: Do not use and instead follow: https://documentation.onesignal.com/docs/ios-push-opt-in-prompt. | ||
* @param {boolean} fallbackToSettings | ||
* @param {(response:boolean) => void} handler | ||
* @returns void | ||
*/ | ||
static promptForPushNotificationsWithUserResponse(handler: (response: boolean) => void): void; | ||
static promptForPushNotificationsWithUserResponse(fallbackToSettingsOrHandler?: boolean | ((response: boolean) => void), handler?: (response: boolean) => void): void; | ||
/** | ||
@@ -80,0 +86,0 @@ * Only applies to iOS (does nothing on Android as it always silently registers) |
@@ -183,16 +183,29 @@ 'use strict'; | ||
/** | ||
* Prompts the iOS user for push notifications. | ||
* Prompts the user for push notifications permission in iOS and Android 13+. | ||
* Use the fallbackToSettings parameter to prompt to open the settings app if a user has already declined push permissions. | ||
* | ||
* Call with promptForPushNotificationsWithUserResponse(fallbackToSettings?, handler?) | ||
* | ||
* Recommended: Do not use and instead follow: https://documentation.onesignal.com/docs/ios-push-opt-in-prompt. | ||
* @param {boolean} fallbackToSettings | ||
* @param {(response:boolean) => void} handler | ||
* @returns void | ||
*/ | ||
OneSignal.promptForPushNotificationsWithUserResponse = function (handler) { | ||
OneSignal.promptForPushNotificationsWithUserResponse = function (fallbackToSettingsOrHandler, handler) { | ||
if (!(0, helpers_1.isNativeModuleLoaded)(RNOneSignal)) | ||
return; | ||
if (react_native_1.Platform.OS === 'ios') { | ||
(0, helpers_1.isValidCallback)(handler); | ||
RNOneSignal.promptForPushNotificationsWithUserResponse(handler); | ||
var fallbackToSettings = false; | ||
if (typeof fallbackToSettingsOrHandler === "function") { | ||
// Method was called like promptForPushNotificationsWithUserResponse(handler: function) | ||
handler = fallbackToSettingsOrHandler; | ||
} | ||
else { | ||
console.log("promptForPushNotificationsWithUserResponse: this function is not supported on Android"); | ||
else if (typeof fallbackToSettingsOrHandler === "boolean") { | ||
// Method was called like promptForPushNotificationsWithUserResponse(fallbackToSettings: boolean, handler?: function) | ||
fallbackToSettings = fallbackToSettingsOrHandler; | ||
} | ||
// Else method was called like promptForPushNotificationsWithUserResponse(), no need to modify | ||
if (!handler && react_native_1.Platform.OS === 'ios') { | ||
handler = function () { }; | ||
} | ||
RNOneSignal.promptForPushNotificationsWithUserResponse(fallbackToSettings, handler); | ||
}; | ||
@@ -199,0 +212,0 @@ /** |
{ | ||
"name": "react-native-onesignal", | ||
"version": "4.3.11", | ||
"version": "4.4.0", | ||
"description": "React Native OneSignal SDK", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -173,15 +173,32 @@ 'use strict'; | ||
/** | ||
* Prompts the iOS user for push notifications. | ||
* Prompts the user for push notifications permission in iOS and Android 13+. | ||
* Use the fallbackToSettings parameter to prompt to open the settings app if a user has already declined push permissions. | ||
* | ||
* Call with promptForPushNotificationsWithUserResponse(fallbackToSettings?, handler?) | ||
* | ||
* Recommended: Do not use and instead follow: https://documentation.onesignal.com/docs/ios-push-opt-in-prompt. | ||
* @param {boolean} fallbackToSettings | ||
* @param {(response:boolean) => void} handler | ||
* @returns void | ||
*/ | ||
static promptForPushNotificationsWithUserResponse(handler: (response: boolean) => void): void { | ||
static promptForPushNotificationsWithUserResponse(fallbackToSettingsOrHandler?: boolean | ((response: boolean) => void), handler?: (response: boolean) => void): void { | ||
if (!isNativeModuleLoaded(RNOneSignal)) return; | ||
if (Platform.OS === 'ios') { | ||
isValidCallback(handler); | ||
RNOneSignal.promptForPushNotificationsWithUserResponse(handler); | ||
} else { | ||
console.log("promptForPushNotificationsWithUserResponse: this function is not supported on Android"); | ||
let fallbackToSettings = false; | ||
if (typeof fallbackToSettingsOrHandler === "function") { | ||
// Method was called like promptForPushNotificationsWithUserResponse(handler: function) | ||
handler = fallbackToSettingsOrHandler; | ||
} | ||
else if (typeof fallbackToSettingsOrHandler === "boolean") { | ||
// Method was called like promptForPushNotificationsWithUserResponse(fallbackToSettings: boolean, handler?: function) | ||
fallbackToSettings = fallbackToSettingsOrHandler; | ||
} | ||
// Else method was called like promptForPushNotificationsWithUserResponse(), no need to modify | ||
if (!handler && Platform.OS === 'ios') { | ||
handler = function(){}; | ||
} | ||
RNOneSignal.promptForPushNotificationsWithUserResponse(fallbackToSettings, handler); | ||
} | ||
@@ -188,0 +205,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
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
856790
2644