fix: request push notifications on mobile (#553)
parent
613c5315b3
commit
f28923f86f
|
@ -36,7 +36,7 @@ const isLegacyAccount = computed(() => !currentUser.value?.vapidKey)
|
|||
<button
|
||||
btn-outline rounded-full font-bold py4 flex="~ gap2 center" m5
|
||||
type="button"
|
||||
:class="busy ? 'border-transparent' : null"
|
||||
:class="busy || isLegacyAccount ? 'border-transparent' : null"
|
||||
:disabled="busy || isLegacyAccount"
|
||||
@click="$emit('subscribe')"
|
||||
>
|
||||
|
|
|
@ -74,14 +74,14 @@ export const usePushManager = () => {
|
|||
|
||||
if (!notificationPermission.value || (notificationPermission.value === 'prompt' && !hiddenNotification.value[acct])) {
|
||||
// safari 16 does not support navigator.permissions.query for notifications
|
||||
try {
|
||||
permission = (await navigator.permissions?.query({ name: 'notifications' }))?.state
|
||||
}
|
||||
catch {
|
||||
permission = await Promise.resolve(Notification.requestPermission()).then((p: NotificationPermission) => {
|
||||
return p === 'default' ? 'prompt' : p
|
||||
})
|
||||
}
|
||||
// try {
|
||||
// permission = (await navigator.permissions?.query({ name: 'notifications' }))?.state
|
||||
// }
|
||||
// catch {
|
||||
permission = await Promise.resolve(Notification.requestPermission()).then((p: NotificationPermission) => {
|
||||
return p === 'default' ? 'prompt' : p
|
||||
})
|
||||
// }
|
||||
}
|
||||
else {
|
||||
permission = notificationPermission.value
|
||||
|
|
|
@ -43,7 +43,7 @@ export const onPush = (event: PushEvent) => {
|
|||
icon,
|
||||
lang: preferred_locale,
|
||||
tag: notification_id,
|
||||
timestamp: new Date().getUTCDate(),
|
||||
timestamp: new Date().getTime(),
|
||||
}
|
||||
return self.registration.showNotification(options.title, notificationOptions)
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue