Notification
Importimport { notification } from "@ant-design/x"; |
Sourcecomponents/notification |
Docs |
Importimport { notification } from "@ant-design/x"; |
Sourcecomponents/notification |
Docs |
Notification
is a system application notification and is controlled by the operating system's notification permissions. If the system notification permission is turned off, the open
method call of XNotification will have no effect. System Permission Settings.window.Notification
. If the browser environment does not support Notification, the method calls of XNotification will have no effect.dir
attribute will be ignored by most browsers.To successfully send a notification, you need to ensure that the current domain has been granted notification permission.
Property | Description | Type | Default | Version |
---|---|---|---|---|
permission | Indicates whether the user has granted permission to display web notifications for the current origin. | NotificationPermission | - | - |
requestPermission | Requests permission from the user to display notifications for the current origin. | ()=> Promise</NotificationPermission/> | - | - |
open | Push a notification to the user | (config: XNotificationOpenArgs)=> void | - | - |
close | Close pushed notifications. You can pass a tag list to close specific notifications, or call without arguments to close all. | (config?: string[])=> void | - | - |
type NotificationPermission =| 'granted' // The user has explicitly granted the current origin permission to display system notifications.| 'denied' // The user has explicitly denied the current origin permission to display system notifications.| 'default'; // The user's decision is unknown; in this case, the application behaves as if the permission was "denied".
type XNotificationOpenArgs = {openConfig: NotificationOptions & {title: string;onClick?: (event: Event, close?: Notification['close']) => void;onClose?: (event: Event) => void;onError?: (event: Event) => void;onShow?: (event: Event) => void;duration?: number;};closeConfig: NotificationOptions['tag'][];};
interface NotificationOptions {badge?: string;body?: string;data?: any;dir?: NotificationDirection;icon?: string;lang?: string;requireInteraction?: boolean;silent?: boolean | null;tag?: string;}
type useNotification = [{ permission: XNotification['permission'] },{open: XNotification['open'];close: XNotification['close'];requestPermission: XNotification['requestPermission'];},];
Notification
settings on WindowsThe setting path for different versions of the Windows system will be different. You can refer to the approximate path: "Start" menu > "Settings" > "System" > and then select "Notifications & actions" on the left, after which you can operate on global notifications and application notifications.
Notification
settings on MacOn a Mac, use the "Notifications" settings to specify the period during which you do not want to be disturbed by notifications, and control how notifications are displayed in the "Notification Center". To change these settings, choose "Apple" menu > "System Settings", then click "Notifications" in the sidebar (you may need to scroll down).
origin
to display system notifications, and the onShow
callback has also been triggered. Why can't the pushed notification be displayed?Notification
is a system-level feature. Please ensure that notifications are enabled for the browser application on your device.