Skip to content

Commit

Permalink
Merge pull request #1101 from OneSignal/fix/notification_request_perm…
Browse files Browse the repository at this point in the history
…ission_rm_soft_prompt

[Fix] Remove soft-prompt in Notifications.requestPermission
  • Loading branch information
jkasten2 committed Aug 25, 2023
2 parents 53bbca3 + c75eed1 commit 5eca501
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/onesignal/NotificationsNamespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,17 @@ export default class NotificationsNamespace extends EventListenerBase {

/**
* Shows a native browser prompt.
* Requirement: Must be called from a "user gesture" (click / tap event).
* Otherwise some browsers (Firefox & Safari) won't show anything.
* Implementation choice note: We don't have any "error" handling when the
* requirement is not met, as browsers do not provide an API for this, w/o
* requiring be passed to this function that is.
* See https://github.com/OneSignal/OneSignal-Website-SDK/issues/1098
* @PublicApi
*/
async requestPermission(): Promise<void> {
await awaitOneSignalInitAndSupported();
const requiresUserInteraction = OneSignal.environmentInfo?.requiresUserInteraction;
if (!requiresUserInteraction) {
await OneSignal.context.promptsManager.internalShowNativePrompt();
return;
}

await OneSignal.Slidedown.promptPush();
await OneSignal.context.promptsManager.internalShowNativePrompt();
}

addEventListener<K extends NotificationEventName>(event: K, listener: (obj: NotificationEventTypeMap[K]) => void): void {
Expand Down

0 comments on commit 5eca501

Please sign in to comment.