# Publishing a Text Notification You 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. **Table 1** Basic notification content types | Type | Description | | ------------------------------- | ------------- | | NOTIFICATION_CONTENT_BASIC_TEXT | Normal text notification.| | NOTIFICATION_CONTENT_MULTILINE | Multi-line text notification.| Notifications are displayed in the notification panel, which is the only supported subscriber to notifications. The following figure shows the effect of a text notification. > **NOTE** > > The figures are for reference only. The actual effect may vary. **Figure 1** Example of the text notification ![en-us_image_0000001466462305](figures/en-us_image_0000001466462305.png) ## Available APIs The 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. | Name| Description| | -------- | -------- | | publish(request: NotificationRequest, callback: AsyncCallback<void>): void | Publishes a notification. | | cancel(id: number, label: string, callback: AsyncCallback<void>): void | Cancels a notification. | | cancelAll(callback: AsyncCallback<void>): void; | Cancels all notifications published by the application.| ## How to Develop 1. [Request notification authorization](notification-enable.md). Your application can send notifications only after obtaining user authorization. 2. Import the module. ```ts import notificationManager from '@ohos.notificationManager'; import Base from '@ohos.base'; ``` 3. Create a **NotificationRequest** object and publish a progress notification. - 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. ```ts let notificationRequest: notificationManager.NotificationRequest = { id: 1, content: { notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, // Basic notification normal: { title: 'test_title', text: 'test_text', additionalText: 'test_additionalText', } } }; notificationManager.publish(notificationRequest, (err:Base.BusinessError) => { if (err) { console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); return; } console.info('Succeeded in publishing notification.'); }); ``` Below is an example of the normal text notification. ![en-us_image_0000001466782033](figures/en-us_image_0000001466782033.png) - 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. ```ts let notificationRequest: notificationManager.NotificationRequest = { id: 3, content: { notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_MULTILINE, // Multi-line text notification multiLine: { title: 'test_title', text: 'test_text', briefText: 'test_briefText', longTitle: 'test_longTitle', lines: ['line_01', 'line_02', 'line_03', 'line_04'], } } }; // Publish the notification. notificationManager.publish(notificationRequest, (err:Base.BusinessError) => { if (err) { console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); return; } console.info('Succeeded in publishing notification.'); }); ``` Below is an example of the multi-line notification. ![en-us_image_0000001417062446](figures/en-us_image_0000001417062446.png)