fix(notification): not support in mobile browser (#1588)
Co-authored-by: sealday <sealday@gmail.com> Reviewed-on: daoyoucloud/tachybase#1588
This commit is contained in:
parent
7b59aeb73d
commit
b4a11fdc8e
@ -3,10 +3,12 @@ import { Plugin } from '@tachybase/client';
|
|||||||
import PluginMessagesClient from '..';
|
import PluginMessagesClient from '..';
|
||||||
import { lang } from '../locale';
|
import { lang } from '../locale';
|
||||||
|
|
||||||
|
const isSupported = () => 'Notification' in window && 'serviceWorker' in navigator && 'PushManager' in window;
|
||||||
|
|
||||||
export class PluginWebNotification extends Plugin {
|
export class PluginWebNotification extends Plugin {
|
||||||
async afterLoad() {
|
async afterLoad() {
|
||||||
// 请求用户授予权限
|
// 请求用户授予权限
|
||||||
if (Notification.permission !== 'denied') {
|
if (isSupported() && Notification.permission !== 'denied') {
|
||||||
await Notification.requestPermission();
|
await Notification.requestPermission();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user