未验证 提交 c0e010e4 编写于 作者: O openharmony_ci 提交者: Gitee

!16330 【3.2-Beta5】翻译完成 14983:优化 text-notification.md 示例代码

Merge pull request !16330 from ester.zhou/C05-14983
......@@ -45,7 +45,7 @@ The following table describes the APIs for notification publishing. You specify
- 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 = {
let notificationRequest: notificationManager.NotificationRequest = {
id: 1,
content: {
contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, // Basic notification
......@@ -59,10 +59,10 @@ The following table describes the APIs for notification publishing. You specify
notificationManager.publish(notificationRequest, (err) => {
if (err) {
console.error(`[ANS] failed to publish, error[${err}]`);
console.error(`[ANS] publish failed, code is ${err.code}, message is ${err.message}`);
return;
}
console.info(`[ANS] publish success`);
console.info(`[ANS] publish success.`);
});
```
......@@ -71,7 +71,7 @@ The following table describes the APIs for notification publishing. You specify
- In addition to the parameters in the normal text notification, the long text notification provides the **longText**, **briefText**, and **expandedTitle** parameters. The value of **longText** contains a maximum of 1024 bytes, while that of any other parameters contains less than 200 bytes. By default, a long-text notification looks in the same way as a normal text notification. When expanded, the notification displays the title and content specified in **expandedTitle** and **longText**, respectively.
```ts
let notificationRequest = {
let notificationRequest: notificationManager.NotificationRequest = {
id: 1,
content: {
contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_LONG_TEXT, // Long-text notification
......@@ -89,10 +89,10 @@ The following table describes the APIs for notification publishing. You specify
// Publish the notification.
notificationManager.publish(notificationRequest, (err) => {
if (err) {
console.error(`[ANS] failed to publish, error[${err}]`);
console.error(`[ANS] publish failed, code is ${err.code}, message is ${err.message}`);
return;
}
console.info(`[ANS] publish success`);
console.info(`[ANS] publish success.`);
});
```
......@@ -101,7 +101,7 @@ The following table describes the APIs for notification publishing. You specify
- 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 = {
let notificationRequest: notificationManager.NotificationRequest = {
id: 1,
content: {
contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_MULTILINE, // Multi-line text notification
......@@ -118,7 +118,7 @@ The following table describes the APIs for notification publishing. You specify
// Publish the notification.
notificationManager.publish(notificationRequest, (err) => {
if (err) {
console.error(`[ANS] failed to publish, error[${err}]`);
console.error(`[ANS] publish failed, code is ${err.code}, message is ${err.message}`);
return;
}
console.info(`[ANS] publish success`);
......@@ -127,11 +127,11 @@ The following table describes the APIs for notification publishing. You specify
Below is an example of the multi-line notification.
![en-us_image_0000001417062446](figures/en-us_image_0000001417062446.png)
- In addition to the parameters in the normal text notification, the picture-attached text notification provides the **picture**, **briefText**, and **expandedTitle** parameters. The value of **picture** is a pixel map that does not exceed 2 MB.
- In addition to the parameters in the normal text notification, the picture-attached text notification provides the **picture**, **briefText**, and **expandedTitle** parameters. The value of **picture** is a **PixelMap** object that does not exceed 2 MB.
```ts
let notificationPicture: PixelMap = undefined; // Obtain the pixel map information.
let notificationRequest = {
let imagePixelMap: PixelMap = undefined; // Obtain the PixelMap information.
let notificationRequest: notificationManager.NotificationRequest = {
id: 1,
content: {
contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_PICTURE,
......@@ -141,7 +141,7 @@ The following table describes the APIs for notification publishing. You specify
additionalText: 'test_additionalText',
briefText: 'test_briefText',
expandedTitle: 'test_expandedTitle',
picture: notificationPicture
picture: imagePixelMap
}
}
}
......@@ -149,10 +149,10 @@ The following table describes the APIs for notification publishing. You specify
// Publish the notification.
notificationManager.publish(notificationRequest, (err) => {
if (err) {
console.error(`[ANS] failed to publish, error[${err}]`);
console.error(`[ANS] publish failed, code is ${err.code}, message is ${err.message}`);
return;
}
console.info(`[ANS] publish success `);
console.info(`[ANS] publish success.`);
});
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册