1# Publishing a Progress Notification
2
3
4The progress notification is a commonly used notification type, mainly used to display the progress of an ongoing operation, such as file downloading. When publishing a progress notification through the notification subsystem, you can use the readily available template by specifying the related attributes, such as the template name and template data.
5
6In the [NotificationTemplate](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis-notification-kit/js-apis-inner-notification-notificationTemplate.md), which can only be of the progress type, **data** indicates custom template data.
7
8## Available APIs
9
10
11
12| Name| Description|
13| -------- | -------- |
14| isSupportTemplate(templateName: string): Promise\<boolean\> | Checks whether a specific template is supported. This API uses an asynchronous callback to return the result. For details, see [isSupportTemplate()](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis-notification-kit/js-apis-notificationManager.md#notificationmanagerissupporttemplate).<br>Only the progress-type template is supported.|
15
16
17## How to Develop
18
191. Import the module.
20
21   ```ts
22   import { notificationManager } from '@kit.NotificationKit';
23   import { BusinessError } from '@kit.BasicServicesKit';
24   import { hilog } from '@kit.PerformanceAnalysisKit';
25
26   const TAG: string = '[PublishOperation]';
27   const DOMAIN_NUMBER: number = 0xFF00;
28   ```
29
302. Check whether a specific template is supported. In this example, the template of the **downloadTemplate** type is checked.
31
32   ```ts
33   notificationManager.isSupportTemplate('downloadTemplate').then((data:boolean) => {
34     hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in supporting download template notification.');
35     let isSupportTpl: boolean = data; // The value true means that the template of the downloadTemplate type is supported, and false means the opposite.
36   }).catch((err: BusinessError) => {
37     hilog.error(DOMAIN_NUMBER, TAG, `Failed to support download template notification. Code is ${err.code}, message is ${err.message}`);
38   });
39   ```
40
41   > **NOTE**
42   > Proceed with the step below only when the specified template is supported.
43
443. Create a **NotificationRequest** object and publish a progress notification.
45
46   ```ts
47   let notificationRequest: notificationManager.NotificationRequest = {
48     id: 5,
49     content: {
50       notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
51       normal: {
52         title: 'test_title',
53         text: 'test_text',
54         additionalText: 'test_additionalText'
55       }
56     },
57     // Create a progress template. The name field has a fixed value of downloadTemplate.
58     template: {
59       name: 'downloadTemplate',
60       data: { title: 'File Title', fileName: 'music.mp4', progressValue: 45 }
61     }
62   }
63
64   // Publish the notification.
65   notificationManager.publish(notificationRequest, (err: BusinessError) => {
66     if (err) {
67       hilog.error(DOMAIN_NUMBER, TAG, `Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
68       return;
69     }
70     hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in publishing notification.');
71   });
72   ```
73