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

!23591 notification目录下适配ArkTs

Merge pull request !23591 from XKK/0831
...@@ -28,6 +28,7 @@ After a notification is read, the count on the badge is decremented by 1. If the ...@@ -28,6 +28,7 @@ After a notification is read, the count on the badge is decremented by 1. If the
```ts ```ts
import notificationManager from '@ohos.notificationManager'; import notificationManager from '@ohos.notificationManager';
import Base from '@ohos.base';
``` ```
2. Increase the count on the badge. 2. Increase the count on the badge.
...@@ -37,7 +38,7 @@ After a notification is read, the count on the badge is decremented by 1. If the ...@@ -37,7 +38,7 @@ After a notification is read, the count on the badge is decremented by 1. If the
In this example, the **setBadgeNumber** API is called to add a badge. This API is called after a new notification is published. In this example, the **setBadgeNumber** API is called to add a badge. This API is called after a new notification is published.
```ts ```ts
function setBadgeNumberCallback(err) { function setBadgeNumberCallback(err:Base.BusinessError) {
if (err) { if (err) {
console.error(`Failed to set badge number. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to set badge number. Code is ${err.code}, message is ${err.message}`);
return; return;
...@@ -54,7 +55,7 @@ After a notification is read, the count on the badge is decremented by 1. If the ...@@ -54,7 +55,7 @@ After a notification is read, the count on the badge is decremented by 1. If the
After a notification is read, the application needs to call the API to set the number of remaining unread notifications. The badge is then updated. After a notification is read, the application needs to call the API to set the number of remaining unread notifications. The badge is then updated.
```ts ```ts
function setBadgeNumberCallback(err) { function setBadgeNumberCallback(err:Base.BusinessError) {
if (err) { if (err) {
console.error(`Failed to set badge number. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to set badge number. Code is ${err.code}, message is ${err.message}`);
return; return;
......
...@@ -36,6 +36,7 @@ For details about the APIs, see [@ohos.notificationManager](../reference/apis/js ...@@ -36,6 +36,7 @@ For details about the APIs, see [@ohos.notificationManager](../reference/apis/js
```ts ```ts
import notificationManager from '@ohos.notificationManager'; import notificationManager from '@ohos.notificationManager';
import Base from '@ohos.base';
``` ```
2. Call the API to request notification to be enabled. 2. Call the API to request notification to be enabled.
...@@ -43,7 +44,7 @@ For details about the APIs, see [@ohos.notificationManager](../reference/apis/js ...@@ -43,7 +44,7 @@ For details about the APIs, see [@ohos.notificationManager](../reference/apis/js
```ts ```ts
notificationManager.requestEnableNotification().then(() => { notificationManager.requestEnableNotification().then(() => {
console.info(`[ANS] requestEnableNotification success`); console.info(`[ANS] requestEnableNotification success`);
}).catch((err) => { }).catch((err:Base.BusinessError) => {
console.error(`[ANS] requestEnableNotification failed, code is ${err.code}, message is ${err.message}`); console.error(`[ANS] requestEnableNotification failed, code is ${err.code}, message is ${err.message}`);
}); });
``` ```
...@@ -40,31 +40,31 @@ The major APIs for notification subscription are described as follows. For detai ...@@ -40,31 +40,31 @@ The major APIs for notification subscription are described as follows. For detai
```ts ```ts
import notificationSubscribe from '@ohos.notificationSubscribe'; import notificationSubscribe from '@ohos.notificationSubscribe';
import Base from '@ohos.base';
``` ```
3. Create a **subscriber** object. 3. Create a **subscriber** object.
```ts ```ts
let subscriber = { let subscriber:notificationSubscribe.NotificationSubscriber = {
onConsume: function (data) { onConsume: (data:notificationSubscribe.SubscribeCallbackData) => {
let req = data.request; let req = data.request;
console.info(`onConsume callback. req.id: ${req.id}`); console.info(`onConsume callback. req.id: ${req.id}`);
}, },
onCancel: function (data) { onCancel: (data:notificationSubscribe.SubscribeCallbackData) => {
let req = data.request; let req = data.request;
console.info(`onCancel callback. req.id: ${req.id}`); console.info(`onCancel callback. req.id: ${req.id}`);
}, },
onUpdate: function (data) { onUpdate: (data) => {
let req = data.request; console.info(`onUpdate callback. req.id: ${req.sortedHashCode}`);
console.info(`onUpdate callback. req.id: ${req.id}`);
}, },
onConnect: function () { onConnect: () => {
console.info(`onConnect callback.}`); console.info(`onConnect callback.}`);
}, },
onDisconnect: function () { onDisconnect: () => {
console.info(`onDisconnect callback.}`); console.info(`onDisconnect callback.}`);
}, },
onDestroy: function () { onDestroy: () => {
console.info(`onDestroy callback.}`); console.info(`onDestroy callback.}`);
}, },
}; };
...@@ -73,11 +73,10 @@ The major APIs for notification subscription are described as follows. For detai ...@@ -73,11 +73,10 @@ The major APIs for notification subscription are described as follows. For detai
4. Initiate notification subscription. 4. Initiate notification subscription.
```ts ```ts
notificationSubscribe.subscribe(subscriber, (err, data) => { // This API uses an asynchronous callback to return the result. notificationSubscribe.subscribe(subscriber, (err:Base.BusinessError) => { // This API uses an asynchronous callback to return the result.
if (err) { if (err) {
console.error(`Failed to subscribe notification. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to subscribe notification. Code is ${err.code}, message is ${err.message}`);
return; return;
} }
console.info(`Succeeded in subscribing to notification. Data: ${data}`);
}); });
``` ```
...@@ -31,6 +31,8 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/ ...@@ -31,6 +31,8 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/
```typescript ```typescript
import notificationManager from '@ohos.notificationManager'; import notificationManager from '@ohos.notificationManager';
import wantAgent from '@ohos.app.ability.wantAgent'; import wantAgent from '@ohos.app.ability.wantAgent';
import { WantAgent } from '@ohos.app.ability.wantAgent';
import Base from '@ohos.base';
``` ```
3. Create a **WantAgentInfo** object. 3. Create a **WantAgentInfo** object.
...@@ -38,10 +40,10 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/ ...@@ -38,10 +40,10 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/
Scenario 1: Create a [WantAgentInfo](../reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md) object for starting a UIAbility component. Scenario 1: Create a [WantAgentInfo](../reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md) object for starting a UIAbility component.
```typescript ```typescript
let wantAgentObj = null; // Save the WantAgent object created. It will be used to complete the trigger operations. let wantAgentObj:WantAgent = null; // Save the WantAgent object created. It will be used to complete the trigger operations.
// Set the action type through operationType of WantAgentInfo. // Set the action type through operationType of WantAgentInfo.
let wantAgentInfo = { let wantAgentInfo:wantAgent.WantAgentInfo = {
wants: [ wants: [
{ {
deviceId: '', deviceId: '',
...@@ -62,10 +64,10 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/ ...@@ -62,10 +64,10 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/
Scenario 2: Create a [WantAgentInfo](../reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md) object for publishing a [common event](../application-models/common-event-overview.md). Scenario 2: Create a [WantAgentInfo](../reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md) object for publishing a [common event](../application-models/common-event-overview.md).
```typescript ```typescript
let wantAgentObj = null; // Save the WantAgent object created. It will be used to complete the trigger operations. let wantAgentObj:WantAgent = null; // Save the WantAgent object created. It will be used to complete the trigger operations.
// Set the action type through operationType of WantAgentInfo. // Set the action type through operationType of WantAgentInfo.
let wantAgentInfo = { let wantAgentInfo:wantAgent.WantAgentInfo = {
wants: [ wants: [
{ {
action: 'event_name', // Set the action name. action: 'event_name', // Set the action name.
...@@ -82,7 +84,7 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/ ...@@ -82,7 +84,7 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/
```typescript ```typescript
// Create a WantAgent object. // Create a WantAgent object.
wantAgent.getWantAgent(wantAgentInfo, (err, data) => { wantAgent.getWantAgent(wantAgentInfo, (err:Base.BusinessError, data:WantAgent) => {
if (err) { if (err) {
console.error(`Failed to get want agent. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to get want agent. Code is ${err.code}, message is ${err.message}`);
return; return;
...@@ -110,7 +112,7 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/ ...@@ -110,7 +112,7 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/
wantAgent: wantAgentObj, wantAgent: wantAgentObj,
} }
notificationManager.publish(notificationRequest, (err) => { notificationManager.publish(notificationRequest, (err:Base.BusinessError) => {
if (err) { if (err) {
console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
return; return;
......
...@@ -20,17 +20,18 @@ In the [NotificationTemplate](../reference/apis/js-apis-inner-notification-notif ...@@ -20,17 +20,18 @@ In the [NotificationTemplate](../reference/apis/js-apis-inner-notification-notif
```ts ```ts
import notificationManager from '@ohos.notificationManager'; import notificationManager from '@ohos.notificationManager';
import Base from '@ohos.base';
``` ```
3. Check whether a specific template is supported. In this example, the template of the **downloadTemplate** type is checked. 3. Check whether a specific template is supported. In this example, the template of the **downloadTemplate** type is checked.
```ts ```ts
notificationManager.isSupportTemplate('downloadTemplate').then((data) => { notificationManager.isSupportTemplate('downloadTemplate').then((data:boolean) => {
console.info(`[ANS] isSupportTemplate success`); console.info(`[ANS] isSupportTemplate success`);
console.info('Succeeded in supporting download template notification.'); console.info('Succeeded in supporting download template notification.');
let isSupportTpl: boolean = data; // The value true means that the template of the downloadTemplate type is supported, and false means the opposite. let isSupportTpl: boolean = data; // The value true means that the template of the downloadTemplate type is supported, and false means the opposite.
// ... // ...
}).catch((err) => { }).catch((err:Base.BusinessError) => {
console.error(`Failed to support download template notification. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to support download template notification. Code is ${err.code}, message is ${err.message}`);
}); });
``` ```
...@@ -60,7 +61,7 @@ In the [NotificationTemplate](../reference/apis/js-apis-inner-notification-notif ...@@ -60,7 +61,7 @@ In the [NotificationTemplate](../reference/apis/js-apis-inner-notification-notif
} }
// Publish the notification. // Publish the notification.
notificationManager.publish(notificationRequest, (err) => { notificationManager.publish(notificationRequest, (err:Base.BusinessError) => {
if (err) { if (err) {
console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
return; return;
......
...@@ -38,6 +38,7 @@ The following table describes the APIs for notification publishing. You specify ...@@ -38,6 +38,7 @@ The following table describes the APIs for notification publishing. You specify
```ts ```ts
import notificationManager from '@ohos.notificationManager'; import notificationManager from '@ohos.notificationManager';
import Base from '@ohos.base';
``` ```
3. Create a **NotificationRequest** object and publish a progress notification. 3. Create a **NotificationRequest** object and publish a progress notification.
...@@ -56,7 +57,7 @@ The following table describes the APIs for notification publishing. You specify ...@@ -56,7 +57,7 @@ The following table describes the APIs for notification publishing. You specify
} }
}; };
notificationManager.publish(notificationRequest, (err) => { notificationManager.publish(notificationRequest, (err:Base.BusinessError) => {
if (err) { if (err) {
console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
return; return;
...@@ -86,7 +87,7 @@ The following table describes the APIs for notification publishing. You specify ...@@ -86,7 +87,7 @@ The following table describes the APIs for notification publishing. You specify
}; };
// Publish the notification. // Publish the notification.
notificationManager.publish(notificationRequest, (err) => { notificationManager.publish(notificationRequest, (err:Base.BusinessError) => {
if (err) { if (err) {
console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
return; return;
...@@ -115,7 +116,7 @@ The following table describes the APIs for notification publishing. You specify ...@@ -115,7 +116,7 @@ The following table describes the APIs for notification publishing. You specify
}; };
// Publish the notification. // Publish the notification.
notificationManager.publish(notificationRequest, (err) => { notificationManager.publish(notificationRequest, (err:Base.BusinessError) => {
if (err) { if (err) {
console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
return; return;
...@@ -146,7 +147,7 @@ The following table describes the APIs for notification publishing. You specify ...@@ -146,7 +147,7 @@ The following table describes the APIs for notification publishing. You specify
}; };
// Publish the notification. // Publish the notification.
notificationManager.publish(notificationRequest, (err) => { notificationManager.publish(notificationRequest, (err:Base.BusinessError) => {
if (err) { if (err) {
console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
return; return;
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
```ts ```ts
import notificationManager from '@ohos.notificationManager'; import notificationManager from '@ohos.notificationManager';
import Base from '@ohos.base';
``` ```
2. 增加角标个数。 2. 增加角标个数。
...@@ -37,7 +38,7 @@ ...@@ -37,7 +38,7 @@
示例为调用setBadgeNumber接口增加角标,在发布完新的通知后,调用该接口。 示例为调用setBadgeNumber接口增加角标,在发布完新的通知后,调用该接口。
```ts ```ts
function setBadgeNumberCallback(err) { function setBadgeNumberCallback(err:Base.BusinessError) {
if (err) { if (err) {
console.error(`Failed to set badge number. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to set badge number. Code is ${err.code}, message is ${err.message}`);
return; return;
...@@ -54,7 +55,7 @@ ...@@ -54,7 +55,7 @@
一条通知被查看后,应用需要调用接口设置剩下未读通知个数,桌面刷新角标。 一条通知被查看后,应用需要调用接口设置剩下未读通知个数,桌面刷新角标。
```ts ```ts
function setBadgeNumberCallback(err) { function setBadgeNumberCallback(err:Base.BusinessError) {
if (err) { if (err) {
console.error(`Failed to set badge number. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to set badge number. Code is ${err.code}, message is ${err.message}`);
return; return;
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
```ts ```ts
import notificationManager from '@ohos.notificationManager'; import notificationManager from '@ohos.notificationManager';
import Base from '@ohos.base';
``` ```
2. 请求发送通知的许可。 2. 请求发送通知的许可。
...@@ -42,7 +43,7 @@ ...@@ -42,7 +43,7 @@
```ts ```ts
notificationManager.requestEnableNotification().then(() => { notificationManager.requestEnableNotification().then(() => {
console.info(`[ANS] requestEnableNotification success`); console.info(`[ANS] requestEnableNotification success`);
}).catch((err) => { }).catch((err:Base.BusinessError) => {
console.error(`[ANS] requestEnableNotification failed, code is ${err.code}, message is ${err.message}`); console.error(`[ANS] requestEnableNotification failed, code is ${err.code}, message is ${err.message}`);
}); });
``` ```
......
...@@ -40,31 +40,31 @@ ...@@ -40,31 +40,31 @@
```ts ```ts
import notificationSubscribe from '@ohos.notificationSubscribe'; import notificationSubscribe from '@ohos.notificationSubscribe';
import Base from '@ohos.base';
``` ```
3. 创建订阅者对象。 3. 创建订阅者对象。
```ts ```ts
let subscriber = { let subscriber:notificationSubscribe.NotificationSubscriber = {
onConsume: function (data) { onConsume: (data:notificationSubscribe.SubscribeCallbackData) => {
let req = data.request; let req = data.request;
console.info(`onConsume callback. req.id: ${req.id}`); console.info(`onConsume callback. req.id: ${req.id}`);
}, },
onCancel: function (data) { onCancel: (data:notificationSubscribe.SubscribeCallbackData) => {
let req = data.request; let req = data.request;
console.info(`onCancel callback. req.id: ${req.id}`); console.info(`onCancel callback. req.id: ${req.id}`);
}, },
onUpdate: function (data) { onUpdate: (data) => {
let req = data.request; console.info(`onUpdate callback. req.id: ${req.sortedHashCode}`);
console.info(`onUpdate callback. req.id: ${req.id}`);
}, },
onConnect: function () { onConnect: () => {
console.info(`onConnect callback.}`); console.info(`onConnect callback.}`);
}, },
onDisconnect: function () { onDisconnect: () => {
console.info(`onDisconnect callback.}`); console.info(`onDisconnect callback.}`);
}, },
onDestroy: function () { onDestroy: () => {
console.info(`onDestroy callback.}`); console.info(`onDestroy callback.}`);
}, },
}; };
...@@ -73,11 +73,10 @@ ...@@ -73,11 +73,10 @@
4. 发起通知订阅。 4. 发起通知订阅。
```ts ```ts
notificationSubscribe.subscribe(subscriber, (err, data) => { // callback形式调用异步接口 notificationSubscribe.subscribe(subscriber, (err:Base.BusinessError) => { // callback形式调用异步接口
if (err) { if (err) {
console.error(`Failed to subscribe notification. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to subscribe notification. Code is ${err.code}, message is ${err.message}`);
return; return;
} }
console.info(`Succeeded in subscribing to notification. Data: ${data}`);
}); });
``` ```
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
```typescript ```typescript
import notificationManager from '@ohos.notificationManager'; import notificationManager from '@ohos.notificationManager';
import wantAgent from '@ohos.app.ability.wantAgent'; import wantAgent from '@ohos.app.ability.wantAgent';
import { WantAgent } from '@ohos.app.ability.wantAgent';
import Base from '@ohos.base';
``` ```
3. 创建WantAgentInfo信息。 3. 创建WantAgentInfo信息。
...@@ -37,10 +39,10 @@ ...@@ -37,10 +39,10 @@
场景一:创建拉起UIAbility的WantAgent的[WantAgentInfo](../reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md)信息。 场景一:创建拉起UIAbility的WantAgent的[WantAgentInfo](../reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md)信息。
```typescript ```typescript
let wantAgentObj = null; // 用于保存创建成功的wantAgent对象,后续使用其完成触发的动作。 let wantAgentObj:WantAgent = null; // 用于保存创建成功的wantAgent对象,后续使用其完成触发的动作。
// 通过WantAgentInfo的operationType设置动作类型 // 通过WantAgentInfo的operationType设置动作类型
let wantAgentInfo = { let wantAgentInfo:wantAgent.WantAgentInfo = {
wants: [ wants: [
{ {
deviceId: '', deviceId: '',
...@@ -61,10 +63,10 @@ ...@@ -61,10 +63,10 @@
场景二:创建发布[公共事件](../application-models/common-event-overview.md)的WantAgent的[WantAgentInfo](../reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md)信息。 场景二:创建发布[公共事件](../application-models/common-event-overview.md)的WantAgent的[WantAgentInfo](../reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md)信息。
```typescript ```typescript
let wantAgentObj = null; // 用于保存创建成功的WantAgent对象,后续使用其完成触发的动作。 let wantAgentObj:WantAgent = null; // 用于保存创建成功的WantAgent对象,后续使用其完成触发的动作。
// 通过WantAgentInfo的operationType设置动作类型 // 通过WantAgentInfo的operationType设置动作类型
let wantAgentInfo = { let wantAgentInfo:wantAgent.WantAgentInfo = {
wants: [ wants: [
{ {
action: 'event_name', // 设置事件名 action: 'event_name', // 设置事件名
...@@ -81,7 +83,7 @@ ...@@ -81,7 +83,7 @@
```typescript ```typescript
// 创建WantAgent // 创建WantAgent
wantAgent.getWantAgent(wantAgentInfo, (err, data) => { wantAgent.getWantAgent(wantAgentInfo, (err:Base.BusinessError, data:WantAgent) => {
if (err) { if (err) {
console.error(`Failed to get want agent. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to get want agent. Code is ${err.code}, message is ${err.message}`);
return; return;
...@@ -109,7 +111,7 @@ ...@@ -109,7 +111,7 @@
wantAgent: wantAgentObj, wantAgent: wantAgentObj,
} }
notificationManager.publish(notificationRequest, (err) => { notificationManager.publish(notificationRequest, (err:Base.BusinessError) => {
if (err) { if (err) {
console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
return; return;
......
...@@ -26,17 +26,18 @@ ...@@ -26,17 +26,18 @@
```ts ```ts
import notificationManager from '@ohos.notificationManager'; import notificationManager from '@ohos.notificationManager';
import Base from '@ohos.base';
``` ```
3. 查询系统是否支持进度条模板,查询结果为支持downloadTemplate模板类通知。 3. 查询系统是否支持进度条模板,查询结果为支持downloadTemplate模板类通知。
```ts ```ts
notificationManager.isSupportTemplate('downloadTemplate').then((data) => { notificationManager.isSupportTemplate('downloadTemplate').then((data:boolean) => {
console.info(`[ANS] isSupportTemplate success`); console.info(`[ANS] isSupportTemplate success`);
console.info('Succeeded in supporting download template notification.'); console.info('Succeeded in supporting download template notification.');
let isSupportTpl: boolean = data; // isSupportTpl的值为true表示支持支持downloadTemplate模板类通知,false表示不支持 let isSupportTpl: boolean = data; // isSupportTpl的值为true表示支持支持downloadTemplate模板类通知,false表示不支持
// ... // ...
}).catch((err) => { }).catch((err:Base.BusinessError) => {
console.error(`Failed to support download template notification. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to support download template notification. Code is ${err.code}, message is ${err.message}`);
}); });
``` ```
...@@ -65,7 +66,7 @@ ...@@ -65,7 +66,7 @@
} }
// 发布通知 // 发布通知
notificationManager.publish(notificationRequest, (err) => { notificationManager.publish(notificationRequest, (err:Base.BusinessError) => {
if (err) { if (err) {
console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
return; return;
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
```ts ```ts
import notificationManager from '@ohos.notificationManager'; import notificationManager from '@ohos.notificationManager';
import Base from '@ohos.base';
``` ```
3. 构造NotificationRequest对象,并发布通知。 3. 构造NotificationRequest对象,并发布通知。
...@@ -55,7 +56,7 @@ ...@@ -55,7 +56,7 @@
} }
}; };
notificationManager.publish(notificationRequest, (err) => { notificationManager.publish(notificationRequest, (err:Base.BusinessError) => {
if (err) { if (err) {
console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
return; return;
...@@ -85,7 +86,7 @@ ...@@ -85,7 +86,7 @@
}; };
// 发布通知 // 发布通知
notificationManager.publish(notificationRequest, (err) => { notificationManager.publish(notificationRequest, (err:Base.BusinessError) => {
if (err) { if (err) {
console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
return; return;
...@@ -114,7 +115,7 @@ ...@@ -114,7 +115,7 @@
}; };
// 发布通知 // 发布通知
notificationManager.publish(notificationRequest, (err) => { notificationManager.publish(notificationRequest, (err:Base.BusinessError) => {
if (err) { if (err) {
console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
return; return;
...@@ -145,7 +146,7 @@ ...@@ -145,7 +146,7 @@
}; };
// 发布通知 // 发布通知
notificationManager.publish(notificationRequest, (err) => { notificationManager.publish(notificationRequest, (err:Base.BusinessError) => {
if (err) { if (err) {
console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`); console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
return; return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册