@@ -170,19 +170,36 @@ export default class OneSignal {
170170 /* R E G I S T R A T I O N E T C */
171171
172172 /**
173- * Prompts the iOS user for push notifications.
173+ * Prompts the user for push notifications permission in iOS and Android 13+.
174+ * Use the fallbackToSettings parameter to prompt to open the settings app if a user has already declined push permissions.
175+ *
176+ * Call with promptForPushNotificationsWithUserResponse(fallbackToSettings?, handler?)
177+ *
178+ * Recommended: Do not use and instead follow: https://documentation.onesignal.com/docs/ios-push-opt-in-prompt.
179+ * @param {boolean } fallbackToSettings
174180 * @param {(response:boolean) => void } handler
175181 * @returns void
176182 */
177- static promptForPushNotificationsWithUserResponse ( handler : ( response : boolean ) => void ) : void {
183+ static promptForPushNotificationsWithUserResponse ( fallbackToSettingsOrHandler ?: boolean | ( ( response : boolean ) => void ) , handler ? : ( response : boolean ) => void ) : void {
178184 if ( ! isNativeModuleLoaded ( RNOneSignal ) ) return ;
179185
180- if ( Platform . OS === 'ios' ) {
181- isValidCallback ( handler ) ;
182- RNOneSignal . promptForPushNotificationsWithUserResponse ( handler ) ;
183- } else {
184- console . log ( "promptForPushNotificationsWithUserResponse: this function is not supported on Android" ) ;
186+ let fallbackToSettings = false ;
187+
188+ if ( typeof fallbackToSettingsOrHandler === "function" ) {
189+ // Method was called like promptForPushNotificationsWithUserResponse(handler: function)
190+ handler = fallbackToSettingsOrHandler ;
185191 }
192+ else if ( typeof fallbackToSettingsOrHandler === "boolean" ) {
193+ // Method was called like promptForPushNotificationsWithUserResponse(fallbackToSettings: boolean, handler?: function)
194+ fallbackToSettings = fallbackToSettingsOrHandler ;
195+ }
196+ // Else method was called like promptForPushNotificationsWithUserResponse(), no need to modify
197+
198+ if ( ! handler && Platform . OS === 'ios' ) {
199+ handler = function ( ) { } ;
200+ }
201+
202+ RNOneSignal . promptForPushNotificationsWithUserResponse ( fallbackToSettings , handler ) ;
186203 }
187204
188205 /**
0 commit comments