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](../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**Figure 1** Progress notification 9 10 11 12 13## Available APIs 14 15| Name| Description| 16| -------- | -------- | 17| isSupportTemplate(templateName: string, callback: AsyncCallback<boolean>): void | Checks whether a specific template is supported. This API uses an asynchronous callback to return the result. For details, see [isSupportTemplate()](../reference/apis/js-apis-notificationManager.md#notificationmanagerissupporttemplate).<br>Only the progress-type template is supported.| 18 19 20## How to Develop 21 221. [Request notification authorization](notification-enable.md). Your application can send notifications only after obtaining user authorization. 23 242. Import the module. 25 26 ```ts 27 import notificationManager from '@ohos.notificationManager'; 28 import Base from '@ohos.base'; 29 ``` 30 313. Check whether a specific template is supported. In this example, the template of the **downloadTemplate** type is checked. 32 33 ```ts 34 notificationManager.isSupportTemplate('downloadTemplate').then((data:boolean) => { 35 console.info(`[ANS] isSupportTemplate success`); 36 console.info('Succeeded in supporting download template notification.'); 37 let isSupportTpl: boolean = data; // The value true means that the template of the downloadTemplate type is supported, and false means the opposite. 38 }).catch((err:Base.BusinessError) => { 39 console.error(`Failed to support download template notification. Code is ${err.code}, message is ${err.message}`); 40 }); 41 ``` 42 43 > **NOTE** 44 > 45 > Proceed with the step below only when the specified template is supported. 46 474. Create a **NotificationRequest** object and publish a progress notification. 48 49 ```ts 50 let notificationRequest: notificationManager.NotificationRequest = { 51 id: 5, 52 content: { 53 notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, 54 normal: { 55 title: 'test_title', 56 text: 'test_text', 57 additionalText: 'test_additionalText' 58 } 59 }, 60 // Create a progress template. The name field has a fixed value of downloadTemplate. 61 template: { 62 name: 'downloadTemplate', 63 data: { title: 'File Title', fileName: 'music.mp4', progressValue: 45 } 64 } 65 } 66 67 // Publish the notification. 68 notificationManager.publish(notificationRequest, (err:Base.BusinessError) => { 69 if (err) { 70 console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); 71 return; 72 } 73 console.info('Succeeded in publishing notification.'); 74 }); 75 ``` 76