Skip to content

Commit

Permalink
getNotificationPermissions ignore mobile ios
Browse files Browse the repository at this point in the history
  • Loading branch information
xnerhu committed Nov 26, 2023
1 parent be7cfbf commit 0f0dbb8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions playground/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
getMozAppearanceSupport,
isAndroid,
isDesktopWebKit,
isIPad,
} from '../src/utils/browser'
import './style.css'

Expand Down Expand Up @@ -44,6 +45,7 @@ const runDetection = async (): Promise<DetectionResult> => {
mozAppearanceSupport: getMozAppearanceSupport(),
isAndroid: isAndroid(),
isDesktopWebKit: isDesktopWebKit(),
isIPad: isIPad(),
}

return {
Expand Down
7 changes: 6 additions & 1 deletion src/sources/notification_permissions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { BotdError, State } from '../types'
import { BotdError, BrowserEngineKind, State } from '../types'
import { getBrowserEngineKind, isDesktopWebKit } from '../utils/browser'

export default async function getNotificationPermissions(): Promise<boolean> {
if (window.Notification === undefined) {
// if on mobile ios, ignore
if (getBrowserEngineKind() === BrowserEngineKind.Webkit && !isDesktopWebKit()) {
return false
}
throw new BotdError(State.Undefined, 'window.Notification is undefined')
}
if (navigator.permissions === undefined) {
Expand Down

0 comments on commit 0f0dbb8

Please sign in to comment.