js-apis-system-notification.md 2.5 KB
Newer Older
E
ester.zhou 已提交
1
# @system.notification (Notification)
E
add doc  
ester.zhou 已提交
2

E
esterzhou 已提交
3
> **NOTE**
E
ester.zhou 已提交
4
> - The APIs of this module are no longer maintained since API version 7. You are advised to use [@ohos.notification](js-apis-notification.md).
E
add doc  
ester.zhou 已提交
5 6 7 8 9 10 11
> 
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.


## Modules to Import


E
ester.zhou 已提交
12
```ts
E
add doc  
ester.zhou 已提交
13 14 15 16 17 18 19
import notification from '@system.notification';
```

## ActionResult

**System capability**: SystemCapability.Notification.Notification

E
ester.zhou 已提交
20 21 22 23 24
| Name       | Type                                          | Mandatory| Description                     |
| ----------- | ---------------------------------------------- | ---- | ------------------------- |
| bundleName  | string                                          | Yes  | Name of the application bundle to which the notification will be redirected after being clicked.                 |
| abilityName  | string                                          | Yes  | Name of the application ability to which the notification will be redirected after being clicked.|
| uri         | string                                          | No  | URI of the page to be redirected to.             |
E
add doc  
ester.zhou 已提交
25 26 27 28 29 30


## ShowNotificationOptions

**System capability**: SystemCapability.Notification.Notification

E
ester.zhou 已提交
31 32 33 34 35
| Name         | Type                                          | Mandatory| Description                       |
| ------------- | ---------------------------------------------- | ---- | ------------------------- |
| contentTitle  | string                                          | No  | Notification title.                 |
| contentText   | string                                          | No  | Notification content.                 |
| clickAction   | ActionResult                                    | No  | Action triggered when the notification is clicked.    |
E
add doc  
ester.zhou 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53


## notification.show

show(options?: ShowNotificationOptions): void

Displays a notification.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | ShowNotificationOptions | No| Notification title.|

**Example**
```javascript
E
esterzhou 已提交
54 55 56 57 58 59 60 61
export default {
    show() {
        notification.show({
            contentTitle: 'title info',
            contentText: 'text',
            clickAction: {
                bundleName: 'com.example.testapp',
                abilityName: 'notificationDemo',
E
ester.zhou 已提交
62 63
                uri: '/path/to/notification'
            }
E
esterzhou 已提交
64
        });
E
ester.zhou 已提交
65
    }
E
add doc  
ester.zhou 已提交
66 67
}
```