1# Publishing a Text Notification 2 3You can publish text notifications to send SMS messages, alert messages, and more. There are two types of text notifications: normal text and multi-line text. 4 5**Table 1** Basic notification content types 6 7| Type | Description | 8| ------------------------------- | ------------- | 9| NOTIFICATION_CONTENT_BASIC_TEXT | Normal text notification.| 10| NOTIFICATION_CONTENT_MULTILINE | Multi-line text notification.| 11 12 13Notifications are displayed in the notification panel, which is the only supported subscriber to notifications. The following figure shows the effect of a text notification. 14> **NOTE** 15> 16> The figures are for reference only. The actual effect may vary. 17 18**Figure 1** Example of the text notification 19 20 21 22 23## Available APIs 24 25The following table describes the APIs for notification publishing. You specify the notification information – content, ID, slot type, and publish time – by setting the [NotificationRequest](../reference/apis-notification-kit/js-apis-inner-notification-notificationRequest.md#notificationrequest) parameter in the APIs. 26 27| Name| Description| 28| -------- | -------- | 29| publish(request: NotificationRequest, callback: AsyncCallback<void>): void | Publishes a notification. | 30| cancel(id: number, label: string, callback: AsyncCallback<void>): void | Cancels a notification. | 31| cancelAll(callback: AsyncCallback<void>): void; | Cancels all notifications published by the application.| 32 33 34## How to Develop 35 361. [Request notification authorization](notification-enable.md). Your application can send notifications only after obtaining user authorization. 37 382. Import the module. 39 40 ```ts 41 import notificationManager from '@ohos.notificationManager'; 42 import Base from '@ohos.base'; 43 ``` 44 453. Create a **NotificationRequest** object and publish a progress notification. 46 - A normal text notification consists of the **title**, **text**, and **additionalText** parameters, of which **title** and **text** are mandatory. The value of these parameters contains less than 200 bytes. 47 48 ```ts 49 let notificationRequest: notificationManager.NotificationRequest = { 50 id: 1, 51 content: { 52 notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, // Basic notification 53 normal: { 54 title: 'test_title', 55 text: 'test_text', 56 additionalText: 'test_additionalText', 57 } 58 } 59 }; 60 notificationManager.publish(notificationRequest, (err:Base.BusinessError) => { 61 if (err) { 62 console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); 63 return; 64 } 65 console.info('Succeeded in publishing notification.'); 66 }); 67 ``` 68 69 Below is an example of the normal text notification. 70  71 72 - In addition to the parameters in the normal text notification, the multi-line text notification provides the **lines**, **briefText**, and **longTitle** parameters. The value of these parameters contains less than 200 bytes. By default, a multi-line notification looks in the same way as a normal text notification. When expanded, the notification displays the title and content specified in **longTitle** and **lines**, respectively. 73 74 ```ts 75 let notificationRequest: notificationManager.NotificationRequest = { 76 id: 3, 77 content: { 78 notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_MULTILINE, // Multi-line text notification 79 multiLine: { 80 title: 'test_title', 81 text: 'test_text', 82 briefText: 'test_briefText', 83 longTitle: 'test_longTitle', 84 lines: ['line_01', 'line_02', 'line_03', 'line_04'], 85 } 86 } 87 }; 88 // Publish the notification. 89 notificationManager.publish(notificationRequest, (err:Base.BusinessError) => { 90 if (err) { 91 console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); 92 return; 93 } 94 console.info('Succeeded in publishing notification.'); 95 }); 96 ``` 97 98 Below is an example of the multi-line notification. 99  100