react-native-onesignal
Advanced tools
@@ -32,3 +32,3 @@ apply plugin: 'com.android.library' | ||
| // classes if needed. Such as com.onesignal.NotificationExtenderService | ||
| api 'com.onesignal:OneSignal:4.7.3' | ||
| api 'com.onesignal:OneSignal:4.8.1' | ||
@@ -35,0 +35,0 @@ testImplementation 'junit:junit:4.12' |
@@ -471,2 +471,16 @@ /* | ||
| @ReactMethod | ||
| public void promptForPushNotificationsWithUserResponse(final boolean fallbackToSettings, final Callback callback) { | ||
| final Callback[] callbackArr = new Callback[]{ callback }; | ||
| OneSignal.promptForPushNotifications(fallbackToSettings, new OneSignal.PromptForPushNotificationPermissionResponseHandler() { | ||
| @Override | ||
| public void response(boolean accepted) { | ||
| if (callbackArr[0] != null) { | ||
| callbackArr[0].invoke(accepted); | ||
| callbackArr[0] = null; | ||
| } | ||
| } | ||
| }); | ||
| } | ||
| @ReactMethod | ||
| public void promptLocation() { | ||
@@ -473,0 +487,0 @@ OneSignal.promptLocation(); |
+8
-2
@@ -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) |
+20
-7
@@ -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 @@ /** |
@@ -197,8 +197,2 @@ #import "RCTOneSignalEventEmitter.h" | ||
| RCT_EXPORT_METHOD(promptForPushNotificationPermissions:(RCTResponseSenderBlock)callback) { | ||
| [OneSignal promptForPushNotificationsWithUserResponse:^(BOOL accepted) { | ||
| callback(@[@(accepted)]); | ||
| }]; | ||
| } | ||
| RCT_EXPORT_METHOD(requestPermissions:(NSDictionary *)permissions) { | ||
@@ -330,7 +324,7 @@ if (RCTRunningInAppExtension()) { | ||
| RCT_EXPORT_METHOD(promptForPushNotificationsWithUserResponse:(RCTResponseSenderBlock)callback) { | ||
| RCT_EXPORT_METHOD(promptForPushNotificationsWithUserResponse:(BOOL)fallbackToSettings withResponse:(RCTResponseSenderBlock)callback) { | ||
| [OneSignal promptForPushNotificationsWithUserResponse:^(BOOL accepted) { | ||
| [OneSignal onesignalLog:ONE_S_LL_VERBOSE message:@"Prompt For Push Notifications Success"]; | ||
| callback(@[@(accepted)]); | ||
| }]; | ||
| } fallbackToSettings:fallbackToSettings]; | ||
| } | ||
@@ -337,0 +331,0 @@ |
+1
-1
| { | ||
| "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", |
+24
-7
@@ -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 @@ |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
856790
0.34%3588
1.3%