“0e3a1d35b10e6cc48512a4848fe5f6da6fc7dfec”上不存在“...fluid/tests/git@gitcode.net:Crayonxin2000/Paddle.git”
未验证 提交 ceaadb4d 编写于 作者: O openharmony_ci 提交者: Gitee

!18367 【cherry-pick】Fix consistency issues & error code issues of Notification

Merge pull request !18367 from xuzhihao/OpenHarmony-3.2-Release
......@@ -18,17 +18,20 @@ import CommonEvent from '@ohos.commonEvent';
全部系统公共事件枚举定义请参见[系统公共事件定义](./commonEvent-definitions.md)
## CommonEvent.publish
## CommonEvent.publish<sup>(deprecated)</sup>
publish(event: string, callback: AsyncCallback\<void>): void
发布公共事件(callback形式)。
**系统能力:** SystemCapability.Notification.CommonEvent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[commonEventManager.publish](js-apis-commonEventManager.md#commoneventmanagerpublish)替代。
**系统能力:** `SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 名称 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ---------------------- |
| event | string | 是 | 表示要发送的公共事件。 |
| callback | AsyncCallback\<void> | 是 | 表示被指定的回调方法。 |
......@@ -49,23 +52,24 @@ function publishCallBack(err) {
CommonEvent.publish("event", publishCallBack);
```
## CommonEvent.publish
## CommonEvent.publish<sup>(deprecated)</sup>
publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\<void>): void
发布公共事件指定发布信息(callback形式)。
**系统能力:** SystemCapability.Notification.CommonEvent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[commonEventManager.publish](js-apis-commonEventManager.md#commoneventmanagerpublish-1)替代。
**系统能力:** `SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 名称 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ---------------------- |
| event | string | 是 | 表示要发布的公共事件。 |
| options | [CommonEventPublishData](./js-apis-inner-commonEvent-commonEventPublishData.md) | 是 | 表示发布公共事件的属性。 |
| callback | syncCallback\<void> | 是 | 表示被指定的回调方法。 |
| callback | AsyncCallback\<void> | 是 | 表示被指定的回调方法。 |
**示例:**
......@@ -91,21 +95,22 @@ function publishCallBack(err) {
CommonEvent.publish("event", options, publishCallBack);
```
## CommonEvent.publishAsUser<sup>8+</sup>
## CommonEvent.publishAsUser<sup>(deprecated)</sup>
publishAsUser(event: string, userId: number, callback: AsyncCallback\<void>): void
向指定用户发布公共事件(callback形式)。
**系统能力:** SystemCapability.Notification.CommonEvent
> **说明:**
> 从 API version 8开始支持,从API version 9开始废弃。建议使用[commonEventManager.publishAsUser](js-apis-commonEventManager.md#commoneventmanagerpublishasuser)替代。
**系统能力:** `SystemCapability.Notification.CommonEvent`
**系统API**:此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 名称 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ---------------------------------- |
| event | string | 是 | 表示要发送的公共事件。 |
| userId | number | 是 | 表示指定向该用户ID发送此公共事件。 |
......@@ -130,21 +135,22 @@ let userId = 100;
CommonEvent.publishAsUser("event", userId, publishAsUserCallBack);
```
## CommonEvent.publishAsUser<sup>8+</sup>
## CommonEvent.publishAsUser<sup>(deprecated)</sup>
publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback\<void>): void
向指定用户发布公共事件并指定发布信息(callback形式)。
**系统能力:** SystemCapability.Notification.CommonEvent
> **说明:**
> 从 API version 8开始支持,从API version 9开始废弃。建议使用[commonEventManager.publishAsUser](js-apis-commonEventManager.md#commoneventmanagerpublishasuser-1)替代。
**系统能力:** `SystemCapability.Notification.CommonEvent`
**系统API**:此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 名称 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ---------------------- |
| event | string | 是 | 表示要发布的公共事件。 |
| userId | number | 是 | 表示指定向该用户ID发送此公共事件。 |
......@@ -177,19 +183,20 @@ let userId = 100;
CommonEvent.publishAsUser("event", userId, options, publishAsUserCallBack);
```
## CommonEvent.createSubscriber<sup>(deprecated)</sup>
## CommonEvent.createSubscriber
createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback\<CommonEventSubscriber>): void
createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback<CommonEventSubscriber>): void
创建订阅者(callback形式)。
**系统能力:** SystemCapability.Notification.CommonEvent
> **说明:**
>从 API version 7开始支持,从API version 9开始废弃。建议使用[commonEventManager.createSubscriber](js-apis-commonEventManager.md#commoneventmanagercreatesubscriber)替代。
**系统能力:** `SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 名称 | 类型 | 必填 | 说明 |
| ------------- | ------------------------------------------------------------ | ---- | -------------------------- |
| subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | 是 | 表示订阅信息。 |
| callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | 是 | 表示创建订阅者的回调方法。 |
......@@ -219,19 +226,20 @@ function createSubscriberCallBack(err, commonEventSubscriber) {
CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack);
```
## CommonEvent.createSubscriber<sup>(deprecated)</sup>
## CommonEvent.createSubscriber
createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventSubscriber>
createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise<CommonEventSubscriber>
创建订阅者(Promise形式)。
**系统能力:** SystemCapability.Notification.CommonEvent
> **说明:**
>从 API version 7开始支持,从API version 9开始废弃。建议使用[commonEventManager.createSubscriber](js-apis-commonEventManager.md#commoneventmanagercreatesubscriber-1)替代。
**系统能力:** `SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 名称 | 类型 | 必填 | 说明 |
| ------------- | ----------------------------------------------------- | ---- | -------------- |
| subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | 是 | 表示订阅信息。 |
......@@ -259,19 +267,20 @@ CommonEvent.createSubscriber(subscribeInfo).then((commonEventSubscriber) => {
});
```
## CommonEvent.subscribe<sup>(deprecated)</sup>
## CommonEvent.subscribe
subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEventData>): void
subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback<CommonEventData>): void
订阅公共事件(callback形式)。
**系统能力:** SystemCapability.Notification.CommonEvent
> **说明:**
>从 API version 7开始支持,从API version 9开始废弃。建议使用[commonEventManager.subscribe](js-apis-commonEventManager.md#commoneventmanagersubscribe)替代。
**系统能力:** `SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 名称 | 类型 | 必填 | 说明 |
| ---------- | ---------------------------------------------------- | ---- | -------------------------------- |
| subscriber | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md) | 是 | 表示订阅者对象。 |
| callback | AsyncCallback\<[CommonEventData](./js-apis-inner-commonEvent-commonEventData.md)> | 是 | 表示接收公共事件数据的回调函数。 |
......@@ -311,19 +320,20 @@ function createSubscriberCallBack(err, commonEventSubscriber) {
CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack);
```
## CommonEvent.unsubscribe
## CommonEvent.unsubscribe<sup>(deprecated)</sup>
unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>): void
取消订阅公共事件(callback形式)。
**系统能力:** SystemCapability.Notification.CommonEvent
> **说明:**
>从 API version 7开始支持,从API version 9开始废弃。建议使用[commonEventManager.subscribe](js-apis-commonEventManager.md#commoneventmanagerunsubscribe)替代。
**系统能力:** `SystemCapability.Notification.CommonEvent`
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| 名称 | 类型 | 必填 | 说明 |
| ---------- | ----------------------------------------------- | ---- | ------------------------ |
| subscriber | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md) | 是 | 表示订阅者对象。 |
| callback | AsyncCallback\<void> | 否 | 表示取消订阅的回调方法。 |
......
......@@ -45,7 +45,6 @@ publish(event: string, callback: AsyncCallback\<void>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
......@@ -98,7 +97,6 @@ publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
......@@ -162,8 +160,6 @@ publishAsUser(event: string, userId: number, callback: AsyncCallback\<void>): vo
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 202 | not system app. |
| 401 | The parameter check failed. |
| 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
......@@ -223,9 +219,7 @@ publishAsUser(event: string, userId: number, options: CommonEventPublishData, ca
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 202 | not system app. |
| 401 | The parameter check failed. |
| 1500004 | not System services. |
| 1500004 | not System services or System app. |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
| 1500009 | error obtaining system parameters. |
......@@ -277,14 +271,6 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallbac
| subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | 是 | 表示订阅信息。 |
| callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | 是 | 表示创建订阅者的回调方法。 |
**错误码:**
错误码介绍请参考[@ohos.commonEventManager(事件)](../errorcodes/errorcode-CommonEventService.md)
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
**示例:**
......@@ -335,14 +321,6 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventS
| --------------------------------------------------------- | ---------------- |
| Promise\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | 返回订阅者对象。 |
**错误码:**
错误码介绍请参考[@ohos.commonEventManager(事件)](../errorcodes/errorcode-CommonEventService.md)
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
**示例:**
```ts
......@@ -390,7 +368,6 @@ subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEven
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 801 | capability not supported. |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
......@@ -462,7 +439,6 @@ unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>):
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 801 | capability not supported. |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
......@@ -521,737 +497,6 @@ try {
}
```
## CommonEventSubscriber
### getCode
getCode(callback: AsyncCallback\<number>): void
获取公共事件的结果代码(callback形式)。
**系统能力**:SystemCapability.Notification.CommonEvent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ------------------ |
| callback | AsyncCallback\<number> | 是 | 公共事件的结果代码。 |
**错误码:**
错误码介绍请参考[@ohos.commonEventManager(事件)](../errorcodes/errorcode-CommonEventService.md)
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | The application dose not have permission to call the interface. |
| 202 | not system app. |
| 401 | The parameter check failed. |
| 1500004 | not system service. |
| 1500007 | The message send error. |
| 1500008 | The CEMS error. |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
//获取有序公共事件的结果代码回调
function getCodeCallback(err, Code) {
if (err) {
console.error("getCode failed " + JSON.stringify(err));
} else {
console.info("getCode " + JSON.stringify(Code));
}
}
subscriber.getCode(getCodeCallback);
```
### getCode
getCode(): Promise\<number>
获取公共事件的结果代码(Promise形式)。
**系统能力**:SystemCapability.Notification.CommonEvent
**返回值:**
| 类型 | 说明 |
| ---------------- | -------------------- |
| Promise\<number> | 公共事件的结果代码。 |
**错误码:**
错误码介绍请参考[@ohos.commonEventManager(事件)](../errorcodes/errorcode-CommonEventService.md)
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | The application dose not have permission to call the interface. |
| 202 | not system app. |
| 401 | The parameter check failed. |
| 1500004 | not system service. |
| 1500007 | The message send error. |
| 1500008 | The CEMS error. |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
subscriber.getCode().then((Code) => {
console.info("getCode " + JSON.stringify(Code));
}).catch((err) => {
console.error("getCode failed " + JSON.stringify(err));
});
```
### setCode
setCode(code: number, callback: AsyncCallback\<void>): void
设置公共事件的结果代码(callback形式)。
**系统能力**:SystemCapability.Notification.CommonEvent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ---------------------- |
| code | number | 是 | 公共事件的结果代码。 |
| callback | AsyncCallback\<void> | 是 | 表示被指定的回调方法。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
//设置有序公共事件的结果代码回调
function setCodeCallback(err) {
if (err) {
console.error("setCode failed " + JSON.stringify(err));
} else {
console.info("setCode");
}
}
subscriber.setCode(1, setCodeCallback);
```
### setCode
setCode(code: number): Promise\<void>
设置公共事件的结果代码(Promise形式)。
**系统能力**:SystemCapability.Notification.CommonEvent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------ |
| code | number | 是 | 公共事件的结果代码。 |
**返回值:**
| 类型 | 说明 |
| ---------------- | -------------------- |
| Promise\<void> | 返回一个Promise的结果。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
subscriber.setCode(1).then(() => {
console.info("setCode");
}).catch((err) => {
console.error("setCode failed " + JSON.stringify(err));
});
```
### getData
getData(callback: AsyncCallback\<string>): void
获取公共事件的结果数据(callback形式)。
**系统能力**:SystemCapability.Notification.CommonEvent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | -------------------- |
| callback | AsyncCallback\<string> | 是 | 公共事件的结果数据。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
//获取有序公共事件的结果数据回调
function getDataCallback(err, Data) {
if (err) {
console.error("getData failed " + JSON.stringify(err));
} else {
console.info("getData " + JSON.stringify(Data));
}
}
subscriber.getData(getDataCallback);
```
### getData
getData(): Promise\<string>
获取公共事件的结果数据(Promise形式)。
**系统能力**:SystemCapability.Notification.CommonEvent
**返回值:**
| 类型 | 说明 |
| ---------------- | ------------------ |
| Promise\<string> | 公共事件的结果数据。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
subscriber.getData().then((Data) => {
console.info("getData " + JSON.stringify(Data));
}).catch((err) => {
console.error("getData failed " + JSON.stringify(err));
});
```
### setData
setData(data: string, callback: AsyncCallback\<void>): void
设置公共事件的结果数据(callback形式)。
**系统能力**:SystemCapability.Notification.CommonEvent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | -------------------- |
| data | string | 是 | 公共事件的结果数据。 |
| callback | AsyncCallback\<void> | 是 | 表示被指定的回调方法。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
//设置有序公共事件的结果数据回调
function setDataCallback(err) {
if (err) {
console.error("setData failed " + JSON.stringify(err));
} else {
console.info("setData");
}
}
subscriber.setData("publish_data_changed", setDataCallback);
```
### setData
setData(data: string): Promise\<void>
设置公共事件的结果数据(Promise形式)。
**系统能力**:SystemCapability.Notification.CommonEvent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | -------------------- |
| data | string | 是 | 公共事件的结果数据。 |
**返回值:**
| 类型 | 说明 |
| ---------------- | -------------------- |
| Promise\<void> | 返回一个Promise的结果。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
subscriber.setData("publish_data_changed").then(() => {
console.info("setData");
}).catch((err) => {
console.error("setData failed " + JSON.stringify(err));
});
```
### setCodeAndData
setCodeAndData(code: number, data: string, callback:AsyncCallback\<void>): void
设置公共事件的结果代码和结果数据(callback形式)。
**系统能力**:SystemCapability.Notification.CommonEvent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ---------------------- |
| code | number | 是 | 公共事件的结果代码。 |
| data | string | 是 | 公共事件的结果数据。 |
| callback | AsyncCallback\<void> | 是 | 表示被指定的回调方法。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
//设置有序公共事件的结果代码和结果数据回调
function setCodeDataCallback(err) {
if (err) {
console.error("setCodeAndData failed " + JSON.stringify(err));
} else {
console.info("setCodeDataCallback");
}
}
subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCallback);
```
### setCodeAndData
setCodeAndData(code: number, data: string): Promise\<void>
设置公共事件的结果代码和结果数据(Promise形式)。
**系统能力**:SystemCapability.Notification.CommonEvent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | -------------------- |
| code | number | 是 | 公共事件的结果代码。 |
| data | string | 是 | 公共事件的结果数据。 |
**返回值:**
| 类型 | 说明 |
| ---------------- | -------------------- |
| Promise\<void> | 返回一个Promise的结果。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
subscriber.setCodeAndData(1, "publish_data_changed").then(() => {
console.info("setCodeAndData");
}).catch((err) => {
console.info("setCodeAndData failed " + JSON.stringify(err));
});
```
### isOrderedCommonEvent
isOrderedCommonEvent(callback: AsyncCallback\<boolean>): void
查询当前公共事件的是否为有序公共事件(callback形式)。
返回true代表是有序公共事件,false代表不是有序公共事件。
**系统能力**:SystemCapability.Notification.CommonEvent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<boolean> | 是 | 当前公共事件的是否为有序公共事件。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
//获取当前公共事件是否为有序事件的回调
function isOrderedCallback(err, isOrdered) {
if (err) {
console.error("isOrderedCommonEvent failed " + JSON.stringify(err));
} else {
console.info("isOrdered " + JSON.stringify(isOrdered));
}
}
subscriber.isOrderedCommonEvent(isOrderedCallback);
```
### isOrderedCommonEvent
isOrderedCommonEvent(): Promise\<boolean>
查询当前公共事件的是否为有序公共事件(Promise形式)。
返回true代表是有序公共事件,false代表不是有序公共事件。
**系统能力**:SystemCapability.Notification.CommonEvent
**返回值:**
| 类型 | 说明 |
| ----------------- | -------------------------------- |
| Promise\<boolean> | 当前公共事件的是否为有序公共事件。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
subscriber.isOrderedCommonEvent().then((isOrdered) => {
console.info("isOrdered " + JSON.stringify(isOrdered));
}).catch((err) => {
console.error("isOrdered failed " + JSON.stringify(err));
});
```
### isStickyCommonEvent
isStickyCommonEvent(callback: AsyncCallback\<boolean>): void
检查当前公共事件是否为一个粘性事件(callback形式)。
返回true代表是粘性公共事件,false代表不是粘性公共事件。
**系统能力**:SystemCapability.Notification.CommonEvent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<boolean> | 是 | 当前公共事件的是否为粘性公共事件。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
//获取当前公共事件是否为粘性事件的回调
function isStickyCallback(err, isSticky) {
if (err) {
console.error("isStickyCommonEvent failed " + JSON.stringify(err));
} else {
console.info("isSticky " + JSON.stringify(isSticky));
}
}
subscriber.isStickyCommonEvent(isStickyCallback);
```
### isStickyCommonEvent
isStickyCommonEvent(): Promise\<boolean>
检查当前公共事件是否为一个粘性事件(Promise形式)。
返回true代表是粘性公共事件,false代表不是粘性公共事件。
**系统能力**:SystemCapability.Notification.CommonEvent
**返回值:**
| 类型 | 说明 |
| ----------------- | -------------------------------- |
| Promise\<boolean> | 当前公共事件的是否为粘性公共事件。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
subscriber.isStickyCommonEvent().then((isSticky) => {
console.info("isSticky " + JSON.stringify(isSticky));
}).catch((err) => {
console.error("isSticky failed " + JSON.stringify(err));
});
```
### abortCommonEvent
abortCommonEvent(callback: AsyncCallback\<void>): void
取消当前的公共事件,仅对有序公共事件有效,取消后,公共事件不再向下一个订阅者传递(callback形式)。
**系统能力**:SystemCapability.Notification.CommonEvent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void> | 是 | 取消当前的公共事件。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
//取消当前有序公共事件的回调
function abortCallback(err) {
if (err) {
console.error("abortCommonEvent failed " + JSON.stringify(err));
} else {
console.info("abortCommonEvent");
}
}
subscriber.abortCommonEvent(abortCallback);
```
### abortCommonEvent
abortCommonEvent(): Promise\<void>
取消当前的公共事件,仅对有序公共事件有效,取消后,公共事件不再向下一个订阅者传递(Promise形式)。
**系统能力**:SystemCapability.Notification.CommonEvent
**返回值:**
| 类型 | 说明 |
| ---------------- | -------------------- |
| Promise\<void> | 返回一个Promise的结果。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
subscriber.abortCommonEvent().then(() => {
console.info("abortCommonEvent");
}).catch((err) => {
console.error("abortCommonEvent failed " + JSON.stringify(err));
});
```
### clearAbortCommonEvent
clearAbortCommonEvent(callback: AsyncCallback\<void>): void
清除当前公共事件的取消状态,仅对有序公共事件有效(callback形式)。
**系统能力**:SystemCapability.Notification.CommonEvent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void> | 是 | 表示被指定的回调方法。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
//清除当前公共事件取消状态的回调
function clearAbortCallback(err) {
if (err) {
console.error("clearAbortCommonEvent failed " + JSON.stringify(err));
} else {
console.info("clearAbortCommonEvent");
}
}
subscriber.clearAbortCommonEvent(clearAbortCallback);
```
### clearAbortCommonEvent
clearAbortCommonEvent(): Promise\<void>
清除当前公共事件的取消状态,仅对有序公共事件有效(Promise形式)。
**系统能力**:SystemCapability.Notification.CommonEvent
**返回值:**
| 类型 | 说明 |
| ---------------- | -------------------- |
| Promise\<void> | 返回一个Promise的结果。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
subscriber.clearAbortCommonEvent().then(() => {
console.info("clearAbortCommonEvent");
}).catch((err) => {
console.error("clearAbortCommonEvent failed " + JSON.stringify(err));
});
```
### getAbortCommonEvent
getAbortCommonEvent(callback: AsyncCallback\<boolean>): void
获取当前有序公共事件是否取消的状态(callback形式)。
**系统能力**:SystemCapability.Notification.CommonEvent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<boolean> | 是 | 表示当前有序公共事件是否取消的状态。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
//获取当前有序公共事件是否取消的回调
function getAbortCallback(err, AbortCommonEvent) {
if (err) {
console.error("getAbortCommonEvent failed " + JSON.stringify(err));
} else {
console.info("AbortCommonEvent " + AbortCommonEvent)
}
}
subscriber.getAbortCommonEvent(getAbortCallback);
```
### getAbortCommonEvent
getAbortCommonEvent(): Promise\<boolean>
获取当前有序公共事件是否取消的状态(Promise形式)。
**系统能力**:SystemCapability.Notification.CommonEvent
**返回值:**
| 类型 | 说明 |
| ----------------- | ---------------------------------- |
| Promise\<boolean> | 表示当前有序公共事件是否取消的状态。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
subscriber.getAbortCommonEvent().then((AbortCommonEvent) => {
console.info("AbortCommonEvent " + JSON.stringify(AbortCommonEvent));
}).catch((err) => {
console.error("getAbortCommonEvent failed " + JSON.stringify(err));
});
```
### getSubscribeInfo
getSubscribeInfo(callback: AsyncCallback\<CommonEventSubscribeInfo>): void
获取订阅者的订阅信息(callback形式)。
**系统能力**:SystemCapability.Notification.CommonEvent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ---------------------- |
| callback | AsyncCallback\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | 是 | 表示订阅者的订阅信息。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
//获取订阅者信息回调
function getSubscribeInfoCallback(err, SubscribeInfo) {
if (err) {
console.error("getSubscribeInfo failed " + JSON.stringify(err));
} else {
console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo));
}
}
subscriber.getSubscribeInfo(getSubscribeInfoCallback);
```
### getSubscribeInfo
getSubscribeInfo(): Promise\<CommonEventSubscribeInfo>
获取订阅者的订阅信息(Promise形式)。
**系统能力**:SystemCapability.Notification.CommonEvent
**返回值:**
| 类型 | 说明 |
| ------------------------------------------------------------ | ---------------------- |
| Promise\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | 表示订阅者的订阅信息。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
subscriber.getSubscribeInfo().then((SubscribeInfo) => {
console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo));
}).catch((err) => {
console.error("getSubscribeInfo failed " + JSON.stringify(err));
});
```
### finishCommonEvent<sup>9+</sup>
finishCommonEvent(callback: AsyncCallback\<void\>): void
结束当前有序公共事件(callback形式)。
**系统能力**:SystemCapability.Notification.CommonEvent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | -------------------------------- |
| callback | AsyncCallback\<void> | 是 | 表示有序公共事件结束后的回调函数。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
//结束当前有序公共事件的回调
function finishCommonEventCallback(err) {
if (err) {
console.error("finishCommonEvent failed " + JSON.stringify(err));
} else {
console.info("FinishCommonEvent");
}
}
subscriber.finishCommonEvent(finishCommonEventCallback);
```
### finishCommonEvent<sup>9+</sup>
finishCommonEvent(): Promise\<void\>
结束当前有序公共事件(Promise形式)。
**系统能力**:SystemCapability.Notification.CommonEvent
**返回值:**
| 类型 | 说明 |
| ---------------- | -------------------- |
| Promise\<void> | 返回一个Promise的结果。 |
**示例:**
```ts
var subscriber; //创建成功的订阅者对象
subscriber.finishCommonEvent().then(() => {
console.info("FinishCommonEvent");
}).catch((err) => {
console.error("finishCommonEvent failed " + JSON.stringify(err));
});
```
## CommonEventData
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Notification.CommonEvent
......
# CommonEventData
> **说明:**
>
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
**系统能力:** `SystemCapability.Notification.CommonEvent`
| 名称 | 类型 | 可读 | 可写 | 说明 |
......
# CommonEventPublishData
> **说明:**
>
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
**系统能力:** `SystemCapability.Notification.CommonEvent`
| 名称 | 类型 | 可读 | 可写 | 说明 |
......
# CommonEventSubscribeInfo
> **说明:**
>
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
**系统能力:** `SystemCapability.Notification.CommonEvent`
| 名称 | 类型 | 可读 | 可写 | 说明 |
......
# CommonEventSubscriber
## getCode
> **说明:**
>
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 使用说明
在使用CommonEventSubscriber的功能前,需要通过CommonEvent.createSubscriber获取subscriber对象。
```ts
getCode(callback: AsyncCallback<number>): void
import CommonEvent from '@ohos.commonEvent';
let subscriber; // 用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作
// 订阅者信息
let subscribeInfo = {
events: ["event"]
};
// 创建订阅者回调
function createCB(err, commonEventSubscriber) {
if (err.code) {
console.error(`createSubscriber failed, code is ${err.code}`);
} else {
console.info("createSubscriber");
subscriber = commonEventSubscriber;
}
}
// 创建订阅者
CommonEvent.createSubscriber(subscribeInfo, createCB);
```
## getCode
getCode(callback: AsyncCallback\<number>): void
以回调形式获取公共事件代码。
**系统能力**`SystemCapability.Notification.CommonEvent`
......@@ -19,8 +48,6 @@ getCode(callback: AsyncCallback<number>): void
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
//获取有序公共事件代码回调
function getCodeCB(err, code) {
if (err.code) {
......@@ -34,9 +61,7 @@ subscriber.getCode(getCodeCB);
## getCode
```ts
getCode(): Promise<number>
```
getCode(): Promise\<number>
以Promise形式获取公共事件代码。
......@@ -51,8 +76,6 @@ getCode(): Promise<number>
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
subscriber.getCode().then((code) => {
console.info("getCode " + JSON.stringify(code));
}).catch((err) => {
......@@ -62,9 +85,7 @@ subscriber.getCode().then((code) => {
## setCode
```ts
setCode(code: number, callback: AsyncCallback<void>): void
```
setCode(code: number, callback: AsyncCallback\<void>): void
以回调形式设置公共事件的代码。
......@@ -80,8 +101,6 @@ setCode(code: number, callback: AsyncCallback<void>): void
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
//设置有序公共事件的代码回调
function setCodeCB(err) {
if (err.code) {
......@@ -95,9 +114,7 @@ subscriber.setCode(1, setCodeCB);
## setCode
```ts
setCode(code: number): Promise<void>
```
setCode(code: number): Promise\<void>
以Promise形式设置公共事件的代码。
......@@ -118,8 +135,6 @@ setCode(code: number): Promise<void>
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
subscriber.setCode(1).then(() => {
console.info("setCode");
}).catch((err) => {
......@@ -129,9 +144,7 @@ subscriber.setCode(1).then(() => {
## getData
```ts
getData(callback: AsyncCallback<string>): void
```
getData(callback: AsyncCallback\<string>): void
以回调形式获取公共事件的数据。
......@@ -146,8 +159,6 @@ getData(callback: AsyncCallback<string>): void
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
//获取有序公共事件代码数据回调
function getDataCB(err, data) {
if (err.code) {
......@@ -161,9 +172,7 @@ subscriber.getData(getDataCB);
## getData
```ts
getData(): Promise<string>
```
getData(): Promise\<string>
以Promise形式获取公共事件的数据。
......@@ -178,8 +187,6 @@ getData(): Promise<string>
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
subscriber.getData().then((data) => {
console.info("getData " + JSON.stringify(data));
}).catch((err) => {
......@@ -205,8 +212,6 @@ setData(data: string, callback: AsyncCallback\<void>): void
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
//设置有序公共事件的结果数据回调
function setDataCB(err) {
if (err.code) {
......@@ -220,9 +225,7 @@ subscriber.setData("publish_data_changed", setDataCB);
## setData
```ts
setData(data: string): Promise<void>
```
setData(data: string): Promise\<void>
以Promise形式设置公共事件的果数据。
......@@ -243,8 +246,6 @@ setData(data: string): Promise<void>
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
subscriber.setData("publish_data_changed").then(() => {
console.info("setData");
}).catch((err) => {
......@@ -254,9 +255,7 @@ subscriber.setData("publish_data_changed").then(() => {
## setCodeAndData
```ts
setCodeAndData(code: number, data: string, callback:AsyncCallback<void>): void
```
setCodeAndData(code: number, data: string, callback:AsyncCallback\<void>): void
以回调形式设置公共事件代码和数据。
......@@ -273,8 +272,6 @@ setCodeAndData(code: number, data: string, callback:AsyncCallback<void>): void
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
//设置有序公共事件的代码和数据回调
function setCodeDataCB(err) {
if (err.code) {
......@@ -288,9 +285,7 @@ subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCB);
## setCodeAndData
```ts
setCodeAndData(code: number, data: string): Promise<void>
```
setCodeAndData(code: number, data: string): Promise\<void>
以Promise形式设置公共事件的代码和数据。
......@@ -312,8 +307,6 @@ setCodeAndData(code: number, data: string): Promise<void>
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
subscriber.setCodeAndData(1, "publish_data_changed").then(() => {
console.info("setCodeAndData");
}).catch((err) => {
......@@ -323,9 +316,7 @@ subscriber.setCodeAndData(1, "publish_data_changed").then(() => {
## isOrderedCommonEvent
```ts
isOrderedCommonEvent(callback: AsyncCallback<boolean>): void
```
isOrderedCommonEvent(callback: AsyncCallback\<boolean>): void
以回调形式查询当前公共事件的是否为有序公共事件。
......@@ -342,8 +333,6 @@ isOrderedCommonEvent(callback: AsyncCallback<boolean>): void
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
//获取当前公共事件是否为有序事件的回调
function isOrderedCB(err, isOrdered) {
if (err.code) {
......@@ -357,9 +346,7 @@ subscriber.isOrderedCommonEvent(isOrderedCB);
## isOrderedCommonEvent
```ts
isOrderedCommonEvent(): Promise<boolean>
```
isOrderedCommonEvent(): Promise\<boolean>
以Promise形式查询当前公共事件的是否为有序公共事件。
......@@ -376,8 +363,6 @@ isOrderedCommonEvent(): Promise<boolean>
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
subscriber.isOrderedCommonEvent().then((isOrdered) => {
console.info("isOrdered " + JSON.stringify(isOrdered));
}).catch((err) => {
......@@ -387,9 +372,7 @@ subscriber.isOrderedCommonEvent().then((isOrdered) => {
## isStickyCommonEvent
```ts
isStickyCommonEvent(callback: AsyncCallback<boolean>): void
```
isStickyCommonEvent(callback: AsyncCallback\<boolean>): void
以回调形式检查当前公共事件是否为一个粘性事件。
......@@ -406,8 +389,6 @@ isStickyCommonEvent(callback: AsyncCallback<boolean>): void
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
//获取当前公共事件是否为粘性事件的回调
function isStickyCB(err, isSticky) {
if (err.code) {
......@@ -421,9 +402,7 @@ subscriber.isStickyCommonEvent(isStickyCB);
## isStickyCommonEvent
```ts
isStickyCommonEvent(): Promise<boolean>
```
isStickyCommonEvent(): Promise\<boolean>
以Promise形式检查当前公共事件是否为一个粘性事件。
......@@ -440,8 +419,6 @@ isStickyCommonEvent(): Promise<boolean>
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
subscriber.isStickyCommonEvent().then((isSticky) => {
console.info("isSticky " + JSON.stringify(isSticky));
}).catch((err) => {
......@@ -451,9 +428,7 @@ subscriber.isStickyCommonEvent().then((isSticky) => {
## abortCommonEvent
```ts
abortCommonEvent(callback: AsyncCallback<void>): void
```
abortCommonEvent(callback: AsyncCallback\<void>): void
以回调形式取消当前的有序公共事件,取消后,有序公共事件不再向下一个订阅者传递。
......@@ -468,8 +443,6 @@ abortCommonEvent(callback: AsyncCallback<void>): void
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
//取消当前有序公共事件的回调
function abortCB(err) {
if (err.code) {
......@@ -483,9 +456,7 @@ subscriber.abortCommonEvent(abortCB);
## abortCommonEvent
```ts
abortCommonEvent(): Promise<void>
```
abortCommonEvent(): Promise\<void>
以Promise形式取消当前的有序公共事件,取消后,公共事件不再向下一个订阅者传递。
......@@ -500,8 +471,6 @@ abortCommonEvent(): Promise<void>
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
subscriber.abortCommonEvent().then(() => {
console.info("abortCommonEvent");
}).catch((err) => {
......@@ -511,9 +480,7 @@ subscriber.abortCommonEvent().then(() => {
## clearAbortCommonEvent
```ts
clearAbortCommonEvent(callback: AsyncCallback<void>): void
```
clearAbortCommonEvent(callback: AsyncCallback\<void>): void
以回调形式清除当前有序公共事件。
......@@ -528,8 +495,6 @@ clearAbortCommonEvent(callback: AsyncCallback<void>): void
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
//清除当前公共事件取消状态的回调
function clearAbortCB(err) {
if (err.code) {
......@@ -543,9 +508,7 @@ subscriber.clearAbortCommonEvent(clearAbortCB);
## clearAbortCommonEvent
```ts
clearAbortCommonEvent(): Promise<void>
```
clearAbortCommonEvent(): Promise\<void>
以Promise形式清除当前有序公共事件。
......@@ -560,8 +523,6 @@ clearAbortCommonEvent(): Promise<void>
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
subscriber.clearAbortCommonEvent().then(() => {
console.info("clearAbortCommonEvent");
}).catch((err) => {
......@@ -571,9 +532,7 @@ subscriber.clearAbortCommonEvent().then(() => {
## getAbortCommonEvent
```ts
getAbortCommonEvent(callback: AsyncCallback<boolean>): void
```
getAbortCommonEvent(callback: AsyncCallback\<boolean>): void
以回调形式获取当前有序公共事件是否取消的状态。
......@@ -588,8 +547,6 @@ getAbortCommonEvent(callback: AsyncCallback<boolean>): void
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
//获取当前有序公共事件是否取消的回调
function getAbortCB(err, abortEvent) {
if (err.code) {
......@@ -603,9 +560,7 @@ subscriber.getAbortCommonEvent(getAbortCB);
## getAbortCommonEvent
```ts
getAbortCommonEvent(): Promise<boolean>
```
getAbortCommonEvent(): Promise\<boolean>
以Promise形式获取当前有序公共事件是否取消的状态。
......@@ -620,8 +575,6 @@ getAbortCommonEvent(): Promise<boolean>
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
subscriber.getAbortCommonEvent().then((abortEvent) => {
console.info("abortCommonEvent " + JSON.stringify(abortEvent));
}).catch((err) => {
......@@ -631,9 +584,7 @@ subscriber.getAbortCommonEvent().then((abortEvent) => {
## getSubscribeInfo
```ts
getSubscribeInfo(callback: AsyncCallback<CommonEventSubscribeInfo>): void
```
getSubscribeInfo(callback: AsyncCallback\<CommonEventSubscribeInfo>): void
以回调形式获取订阅者的订阅信息。
......@@ -648,8 +599,6 @@ getSubscribeInfo(callback: AsyncCallback<CommonEventSubscribeInfo>): void
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
//获取订阅者信息回调
function getCB(err, subscribeInfo) {
if (err.code) {
......@@ -663,9 +612,7 @@ subscriber.getSubscribeInfo(getCB);
## getSubscribeInfo
```ts
getSubscribeInfo(): Promise<CommonEventSubscribeInfo>
```
getSubscribeInfo(): Promise\<CommonEventSubscribeInfo>
以Promise形式获取订阅者的订阅信息。
......@@ -680,8 +627,6 @@ getSubscribeInfo(): Promise<CommonEventSubscribeInfo>
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
subscriber.getSubscribeInfo().then((subscribeInfo) => {
console.info("subscribeInfo " + JSON.stringify(subscribeInfo));
}).catch((err) => {
......@@ -691,9 +636,7 @@ subscriber.getSubscribeInfo().then((subscribeInfo) => {
## finishCommonEvent<sup>9+</sup>
```ts
finishCommonEvent(callback: AsyncCallback<void>): void
```
finishCommonEvent(callback: AsyncCallback\<void>): void
以回调形式结束当前有序公共事件。
......@@ -708,14 +651,13 @@ finishCommonEvent(callback: AsyncCallback<void>): void
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
//结束当前有序公共事件的回调
function finishCB(err) {
if (err.code) {
console.error(`finishCommonEvent failed, code is ${err.code}, message is ${err.message}`);
} else {
} else {
console.info("FinishCommonEvent");
}
}
subscriber.finishCommonEvent(finishCB);
......@@ -723,9 +665,7 @@ subscriber.finishCommonEvent(finishCB);
## finishCommonEvent<sup>9+</sup>
```ts
finishCommonEvent(): Promise<void\>
```
finishCommonEvent(): Promise\<void>
以Promise形式结束当前有序公共事件。
......@@ -740,8 +680,6 @@ finishCommonEvent(): Promise<void\>
**示例:**
```ts
let subscriber; //创建成功的订阅者对象
subscriber.finishCommonEvent().then(() => {
console.info("FinishCommonEvent");
}).catch((err) => {
......
......@@ -8,9 +8,9 @@
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 类型 | 可读 | 可写 | 说明 |
| 名称 | 类型 | 只读 | 必填 | 说明 |
| --------- | ----------------------------------------------- | --- | ---- | ------------------------- |
| title | string | | 是 | 按钮标题。 |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | | 是 | 点击按钮时触发的WantAgent。 |
| extras | { [key: string]: any } | 是 | 是 | 按钮扩展信息。 |
| userInput<sup>8+</sup> | [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md) | 是 | 是 | 用户输入对象实例。 |
| title | string | | 是 | 按钮标题。 |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | | 是 | 点击按钮时触发的WantAgent。 |
| extras | { [key: string]: any } | 否 | 否 | 按钮扩展信息。 |
| userInput<sup>8+</sup> | [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md) | 否 | 否 | 用户输入对象实例。 |
......@@ -10,7 +10,7 @@ BundleOption模块为指定应用的包信息。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 类型 | 必填 | 说明 |
| ------ | ------ |---- | ------ |
| bundle | string | 是 | 应用的包信息。 |
| uid | number | 否 | 用户ID。 |
| 名称 | 类型 | 只读 | 必填 | 说明 |
| ------ | ------ | ---- | ---- | ------ |
| bundle | string | 否 | 是 | 应用的包信息。 |
| uid | number | 否 | 否 | 用户ID。 |
......@@ -8,13 +8,13 @@
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 类型 | 可读 | 可写 | 说明 |
| 名称 | 类型 | 只读 | 必填 | 说明 |
| ----------- | ------------------------------------------------------------ | ---- | --- | ------------------ |
| contentType | [ContentType](./js-apis-notificationManager.md#contenttype) | 是 | 是 | 通知内容类型。 |
| normal | [NotificationBasicContent](#notificationbasiccontent) | 是 | 是 | 基本类型通知内容。 |
| longText | [NotificationLongTextContent](#notificationlongtextcontent) | 是 | 是 | 长文本类型通知内容。 |
| multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | 是 | 是 | 多行类型通知内容。 |
| picture | [NotificationPictureContent](#notificationpicturecontent) | 是 | 是 | 图片类型通知内容。 |
| contentType | [ContentType](./js-apis-notificationManager.md#contenttype) | 否 | 是 | 通知内容类型。 |
| normal | [NotificationBasicContent](#notificationbasiccontent) | 否 | 否 | 基本类型通知内容。 |
| longText | [NotificationLongTextContent](#notificationlongtextcontent) | 否 | 否 | 长文本类型通知内容。 |
| multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | 否 | 否 | 多行类型通知内容。 |
| picture | [NotificationPictureContent](#notificationpicturecontent) | 否 | 否 | 图片类型通知内容。 |
## NotificationBasicContent
......@@ -22,11 +22,11 @@
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 类型 | 可读 | 可写 | 说明 |
| 名称 | 类型 | 只读 | 必填 | 说明 |
| -------------- | ------ | ---- | ---- | ---------------------------------- |
| title | string | | 是 | 通知标题。 |
| text | string | | 是 | 通知内容。 |
| additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 |
| title | string | | 是 | 通知标题。 |
| text | string | | 是 | 通知内容。 |
| additionalText | string | 否 | 否 | 通知附加内容,是对通知内容的补充。 |
## NotificationLongTextContent
......@@ -35,14 +35,14 @@
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 类型 | 可读 | 可写 | 说明 |
| 名称 | 类型 | 只读 | 必填 | 说明 |
| -------------- | ------ | ---- | --- | -------------------------------- |
| title | string | | 是 | 通知标题。 |
| text | string | | 是 | 通知内容。 |
| additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 |
| longText | string | | 是 | 通知的长文本。 |
| briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 |
| expandedTitle | string | | 是 | 通知展开时的标题。 |
| title | string | | 是 | 通知标题。 |
| text | string | | 是 | 通知内容。 |
| additionalText | string | 否 | 否 | 通知附加内容,是对通知内容的补充。 |
| longText | string | | 是 | 通知的长文本。 |
| briefText | string | 否 | 是 | 通知概要内容,是对通知内容的总结。 |
| expandedTitle | string | | 是 | 通知展开时的标题。 |
## NotificationMultiLineContent
......@@ -53,12 +53,12 @@
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------------- | --------------- | --- | --- | -------------------------------- |
| title | string | | 是 | 通知标题。 |
| text | string | | 是 | 通知内容。 |
| additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 |
| briefText | string | | 是 | 通知概要内容,是对通知内容的总结。 |
| longTitle | string | | 是 | 通知展开时的标题。 |
| lines | Array\<string\> | | 是 | 通知的多行文本。 |
| title | string | | 是 | 通知标题。 |
| text | string | | 是 | 通知内容。 |
| additionalText | string | 否 | 否 | 通知附加内容,是对通知内容的补充。 |
| briefText | string | | 是 | 通知概要内容,是对通知内容的总结。 |
| longTitle | string | | 是 | 通知展开时的标题。 |
| lines | Array\<string\> | | 是 | 通知的多行文本。 |
## NotificationPictureContent
......@@ -69,9 +69,9 @@
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------------- | -------------- | ---- | --- | -------------------------------- |
| title | string | | 是 | 通知标题。 |
| text | string | | 是 | 通知内容。 |
| additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 |
| briefText | string | | 是 | 通知概要内容,是对通知内容的总结。 |
| expandedTitle | string | | 是 | 通知展开时的标题。 |
| picture | [image.PixelMap](js-apis-image.md#pixelmap7) | | 是 | 通知的图片内容。 |
| title | string | | 是 | 通知标题。 |
| text | string | | 是 | 通知内容。 |
| additionalText | string | 否 | 否 | 通知附加内容,是对通知内容的补充。 |
| briefText | string | | 是 | 通知概要内容,是对通知内容的总结。 |
| expandedTitle | string | | 是 | 通知展开时的标题。 |
| picture | [image.PixelMap](js-apis-image.md#pixelmap7) | | 是 | 通知的图片内容。 |
......@@ -8,7 +8,7 @@
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 类型 | 可读 | 可写 | 说明 |
| 名称 | 类型 | 只读 | 必填 | 说明 |
| ---------------- | ---------------------- | ---- | ---- | --------------------------------- |
| soundEnabled | [NotificationFlagStatus](#notificationflagstatus) | 是 | 否 | 是否启用声音提示。 |
| vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus) | 是 | 否 | 是否启用振动提醒功能。 |
......
......@@ -8,45 +8,45 @@
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 类型 | 可读 | 可写 | 说明 |
| 名称 | 类型 | 只读 | 必填 | 说明 |
| --------------------- | --------------------------------------------- | ---- | --- | -------------------------- |
| content | [NotificationContent](js-apis-inner-notification-notificationContent.md#notificationcontent) | | 是 | 通知内容。 |
| id | number | 是 | 是 | 通知ID。 |
| slotType | [SlotType](js-apis-notificationManager.md#slottype) | 是 | | 通道类型。 |
| isOngoing | boolean | 是 | 是 | 是否进行时通知。 |
| isUnremovable | boolean | 是 | 是 | 是否可移除。 |
| deliveryTime | number | 是 | 是 | 通知发送时间。 |
| tapDismissed | boolean | 是 | 是 | 通知是否自动清除。 |
| autoDeletedTime | number | 是 | 是 | 自动清除的时间。 |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | WantAgent封装了应用的行为意图,点击通知时触发该行为。 |
| extraInfo | {[key: string]: any} | 是 | 是 | 扩展参数。 |
| color | number | 是 | 是 | 通知背景颜色。预留能力,暂未支持。 |
| colorEnabled | boolean | 是 | 是 | 通知背景颜色是否使能。预留能力,暂未支持。 |
| isAlertOnce | boolean | 是 | 是 | 设置是否仅有一次此通知提醒。 |
| isStopwatch | boolean | 是 | 是 | 是否显示已用时间。 |
| isCountDown | boolean | 是 | 是 | 是否显示倒计时时间。 |
| isFloatingIcon | boolean | 是 | 是 | 是否显示状态栏图标。 |
| label | string | 是 | 是 | 通知标签。 |
| badgeIconStyle | number | 是 | 是 | 通知角标类型。 |
| showDeliveryTime | boolean | 是 | 是 | 是否显示分发时间。 |
| actionButtons | Array\<[NotificationActionButton](js-apis-inner-notification-notificationActionButton.md)\> | 是 | 是 | 通知按钮,最多三个按钮。 |
| smallIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 是 | 通知小图标。可选字段,大小不超过30KB。 |
| largeIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 是 | 通知大图标。可选字段,大小不超过30KB。 |
| content | [NotificationContent](js-apis-inner-notification-notificationContent.md#notificationcontent) | | 是 | 通知内容。 |
| id | number | 否 | 否 | 通知ID。 |
| slotType | [SlotType](js-apis-notificationManager.md#slottype) | 是 | | 通道类型。 |
| isOngoing | boolean | 否 | 否 | 是否进行时通知。 |
| isUnremovable | boolean | 否 | 否 | 是否可移除。 |
| deliveryTime | number | 否 | 否 | 通知发送时间。 |
| tapDismissed | boolean | 否 | 否 | 通知是否自动清除。 |
| autoDeletedTime | number | 否 | 否 | 自动清除的时间。 |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | 否 | 否 | WantAgent封装了应用的行为意图,点击通知时触发该行为。 |
| extraInfo | {[key: string]: any} | 否 | 否 | 扩展参数。 |
| color | number | 否 | 否 | 通知背景颜色。预留能力,暂未支持。 |
| colorEnabled | boolean | 否 | 否 | 通知背景颜色是否使能。预留能力,暂未支持。 |
| isAlertOnce | boolean | 否 | 否 | 设置是否仅有一次此通知提醒。 |
| isStopwatch | boolean | 否 | 否 | 是否显示已用时间。 |
| isCountDown | boolean | 否 | 否 | 是否显示倒计时时间。 |
| isFloatingIcon | boolean | 否 | 否 | 是否显示状态栏图标。 |
| label | string | 否 | 否 | 通知标签。 |
| badgeIconStyle | number | 否 | 否 | 通知角标类型。预留能力,暂未支持。 |
| showDeliveryTime | boolean | 否 | 否 | 是否显示分发时间。 |
| actionButtons | Array\<[NotificationActionButton](js-apis-inner-notification-notificationActionButton.md)\> | 否 | 否 | 通知按钮,最多三个按钮。 |
| smallIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | 否 | 否 | 通知小图标。可选字段,大小不超过30KB。 |
| largeIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | 否 | 否 | 通知大图标。可选字段,大小不超过30KB。 |
| creatorBundleName | string | 是 | 否 | 创建通知的包名。 |
| creatorUid<sup>8+<sup> | number | 是 | 否 | 创建通知的UID。 |
| creatorPid | number | 是 | 否 | 创建通知的PID。 |
| creatorUserId| number | 是 | 否 | 创建通知的UserId。 |
| creatorUserId | number | 是 | 否 | 创建通知的UserId。 |
| hashCode | string | 是 | 否 | 通知唯一标识。 |
| classification | string | 是 | 是 | 通知分类。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 |
| groupName<sup>8+<sup> | string | 是 | 是 | 组通知名称。 |
| template<sup>8+<sup> | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | 是 | 是 | 通知模板。 |
| classification | string | 否 | 否 | 通知分类。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 |
| groupName<sup>8+<sup> | string | 否 | 否 | 组通知名称。 |
| template<sup>8+<sup> | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | 否 | 否 | 通知模板。 |
| isRemoveAllowed<sup>8+<sup> | boolean | 是 | 否 | 通知是否能被移除。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 |
| source<sup>8+<sup> | number | 是 | 否 | 通知源。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 |
| distributedOption<sup>8+<sup> | [DistributedOptions](#distributedoptions) | 是 | 是 | 分布式通知的选项。 |
| distributedOption<sup>8+<sup> | [DistributedOptions](#distributedoptions) | 否 | 否 | 分布式通知的选项。 |
| deviceId<sup>8+<sup> | string | 是 | 否 | 通知源的deviceId。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 |
| notificationFlags<sup>8+<sup> | [NotificationFlags](js-apis-inner-notification-notificationflags#notificationFlags) | 是 | 否 | 获取NotificationFlags。 |
| removalWantAgent<sup>9+<sup> | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | 当移除通知时,通知将被重定向到的WantAgent实例。 |
| badgeNumber<sup>9+<sup> | number | 是 | 是 | 应用程序图标上显示的通知数。 |
| notificationFlags<sup>8+<sup> | [NotificationFlags](js-apis-inner-notification-notificationFlags.md#notificationflags) | 是 | 否 | 获取NotificationFlags。 |
| removalWantAgent<sup>9+<sup> | [WantAgent](js-apis-app-ability-wantAgent.md) | 否 | 否 | 当移除通知时,通知将被重定向到的WantAgent实例。 |
| badgeNumber<sup>9+<sup> | number | 否 | 否 | 应用程序图标上显示的通知数。 |
## DistributedOptions
......@@ -55,9 +55,9 @@
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 类型 | 可读 | 可写 | 说明 |
| 名称 | 类型 | 只读 | 必填 | 说明 |
| ---------------------- | -------------- | ---- | ---- | ---------------------------------- |
| isDistributed<sup>8+<sup> | boolean | 是 | 是 | 是否为分布式通知。 |
| supportDisplayDevices<sup>8+<sup> | Array\<string> | 是 | 是 | 可以同步通知到的设备列表。 |
| supportOperateDevices<sup>8+<sup> | Array\<string> | 是 | 是 | 可以打开通知的设备列表。 |
| isDistributed<sup>8+<sup> | boolean | 否 | 否 | 是否为分布式通知。 |
| supportDisplayDevices<sup>8+<sup> | Array\<string> | 否 | 否 | 可以同步通知到的设备列表。 |
| supportOperateDevices<sup>8+<sup> | Array\<string> | 否 | 否 | 可以打开通知的设备列表。 |
| remindType<sup>8+<sup> | number | 是 | 否 | 通知的提醒方式。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 |
......@@ -8,17 +8,17 @@
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 类型 | 可读 | 可写 | 说明 |
| 名称 | 类型 | 只读 | 必填 | 说明 |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| type | [SlotType](js-apis-notificationManager.md#slottype) | | 是 | 通道类型。 |
| level | number | 是 | 是 | 通知级别,不设置则根据通知渠道类型有默认值。 |
| desc | string | 是 | 是 | 通知渠道描述信息。 |
| badgeFlag | boolean | 是 | 是 | 是否显示角标。 |
| bypassDnd | boolean | 是 | 是 | 置是否在系统中绕过免打扰模式。 |
| lockscreenVisibility | number | 是 | 是 | 在锁定屏幕上显示通知的模式。 |
| vibrationEnabled | boolean | 是 | 是 | 是否可振动。 |
| sound | string | 是 | 是 | 通知提示音。 |
| lightEnabled | boolean | 是 | 是 | 是否闪灯。 |
| lightColor | number | 是 | 是 | 通知灯颜色。 |
| vibrationValues | Array\<number\> | 是 | 是 | 通知振动样式。 |
| type | [SlotType](js-apis-notificationManager.md#slottype) | | 是 | 通道类型。 |
| level | number | 否 | 否 | 通知级别,不设置则根据通知渠道类型有默认值。 |
| desc | string | 否 | 否 | 通知渠道描述信息。 |
| badgeFlag | boolean | 否 | 否 | 是否显示角标。 |
| bypassDnd | boolean | 否 | 否 | 置是否在系统中绕过免打扰模式。 |
| lockscreenVisibility | number | 否 | 否 | 在锁定屏幕上显示通知的模式。 |
| vibrationEnabled | boolean | 否 | 否 | 是否可振动。 |
| sound | string | 否 | 否 | 通知提示音。 |
| lightEnabled | boolean | 否 | 否 | 是否闪灯。 |
| lightColor | number | 否 | 否 | 通知灯颜色。 |
| vibrationValues | Array\<number\> | 否 | 否 | 通知振动样式。 |
| enabled<sup>9+</sup> | boolean | 是 | 否 | 此通知插槽中的启停状态。 |
# NotificationSorting
提供有关活动通知的排序信息。
> **说明:**
>
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
**系统接口**: 以下为系统接口,三方应用不支持调用。
| 名称 | 类型 | 只读 | 必填 | 说明 |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | 是 | 是 | 通道类型。 |
| level | number | 是 | 是 | 通知级别,不设置则根据通知渠道类型有默认值。 |
| desc | string | 是 | 是 | 通知渠道描述信息。 |
# NotificationSortingMap
提供有关已订阅的所有通知中的活动通知的排序信息。
> **说明:**
>
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
**系统接口**: 以下为系统接口,三方应用不支持调用。
| 名称 | 类型 | 只读 | 必填 | 说明 |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| sortings | { [key: string]: [NotificationSorting](js-apis-inner-notification-notificationSorting.md) } | 是 | 是 | 通知排序信息。 |
| sortedHashCode | Array<string> | 是 | 是 | 通知排序的HashCode。 |
# NotificationSubscribeInfo
通知发布者的信息。
> **说明:**
>
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
**系统接口**: 以下为系统接口,三方应用不支持调用。
| 名称 | 类型 | 只读 | 必填 | 说明 |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| bundleNames | Array<string> | 否 | 否 | 应用Bundle名称。 |
| userId | number | 否 | 否 | 用户ID。 |
......@@ -8,7 +8,7 @@
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 类型 | 可读 | 可写 | 说明 |
| 名称 | 类型 | 只读 | 必填 | 说明 |
| ---- | ---------------------- | ---- | ---- | ---------- |
| name | string | | 是 | 模板名称。 |
| data | {[key:string]: Object} | | 是 | 模板数据。 |
| name | string | | 是 | 模板名称。 |
| data | {[key:string]: Object} | | 是 | 模板数据。 |
......@@ -8,6 +8,6 @@
**系统能力**:SystemCapability.Notification.Notification
| 名称 | 类型 | 可读 | 可写 | 说明 |
| 名称 | 类型 | 只读 | 必填 | 说明 |
| -------- | ------ | --- | ---- | ----------------------------- |
| inputKey | string | | 是 | 用户输入时用于标识此输入的key。 |
| inputKey | string | | 是 | 用户输入时用于标识此输入的key。 |
......@@ -588,7 +588,7 @@ Notification.getSlot(slotType).then((data) => {
## Notification.getSlots
getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void
getSlots(callback: AsyncCallback\<Array\<NotificationSlot>>): void
获取此应用程序的所有通知通道(callback形式)。
......@@ -598,7 +598,7 @@ getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------- | ---- | -------------------- |
| callback | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)\>\> | 是 | 以callback形式返回获取此应用程序的所有通知通道的结果。 |
| callback | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)>> | 是 | 以callback形式返回获取此应用程序的所有通知通道的结果。 |
**示例:**
......@@ -1372,7 +1372,7 @@ Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
## Notification.getSlotsByBundle
getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<NotificationSlot\>>): void
getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback\<Array\<NotificationSlot>>): void
获取指定应用的所有通知通道(Callback形式)。
......@@ -1387,7 +1387,7 @@ getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<Notificati
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | -------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| callback | AsyncCallback<Array\<[NotificationSlot](#notificationslot)\>> | 是 | 获取通知通道回调函数。 |
| callback | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)>> | 是 | 获取通知通道回调函数。 |
**示例:**
......@@ -1409,7 +1409,7 @@ Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
## Notification.getSlotsByBundle
getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>>
getSlotsByBundle(bundle: BundleOption): Promise\<Array\<NotificationSlot>>
获取指定应用的所有通知通道(Promise形式)。
......@@ -1429,7 +1429,7 @@ getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>>
| 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise<Array\<[NotificationSlot](#notificationslot)\>> | 以Promise形式返回获取指定应用的通知通道。 |
| Promise\<Array\<[NotificationSlot](#notificationslot)>> | 以Promise形式返回获取指定应用的通知通道。 |
**示例:**
......@@ -1831,7 +1831,7 @@ Notification.removeAll(userId).then(() => {
## Notification.getAllActiveNotifications
getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void
getAllActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): void
获取当前未删除的所有通知(Callback形式)。
......@@ -1845,7 +1845,7 @@ getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>)
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | -------------------- |
| callback | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | 是 | 获取活动通知回调函数。 |
| callback | AsyncCallback\<Array\<[NotificationRequest](#notificationrequest)>> | 是 | 获取活动通知回调函数。 |
**示例:**
......@@ -1865,7 +1865,7 @@ Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
## Notification.getAllActiveNotifications
getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\>
getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)>>
获取当前未删除的所有通知(Promise形式)。
......@@ -1879,7 +1879,7 @@ getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notification
| 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | 以Promise形式返回获取活动通知。 |
| Promise\<Array\<[NotificationRequest](#notificationrequest)>> | 以Promise形式返回获取活动通知。 |
**示例:**
......@@ -2913,476 +2913,6 @@ Notification.getDeviceRemindType().then((data) => {
});
```
## Notification.publishAsBundle<sup>9+</sup>
publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void
发布代理通知(callback形式)。
**系统能力**:SystemCapability.Notification.Notification
**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER,ohos.permission.NOTIFICATION_AGENT_CONTROLLER
**系统API**: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------------- | ------------------------------------------- | ---- | ---------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 |
| representativeBundle | string | 是 | 被代理应用的包名。 |
| userId | number | 是 | 用户ID。 |
| callback | AsyncCallback | 是 | 发布代理通知的回调方法。 |
**示例:**
```js
// publishAsBundle回调
function callback(err) {
if (err.code) {
console.info("publishAsBundle failed " + JSON.stringify(err));
} else {
console.info("publishAsBundle success");
}
}
// 被代理应用的包名
let representativeBundle = "com.example.demo";
// 用户ID
let userId = 100;
// NotificationRequest对象
let request = {
id: 1,
content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
}
}
};
Notification.publishAsBundle(request, representativeBundle, userId, callback);
```
## Notification.publishAsBundle<sup>9+</sup>
publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number): Promise\<void\>
发布代理通知(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification
**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER,ohos.permission.NOTIFICATION_AGENT_CONTROLLER
**系统API**: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 |
| representativeBundle | string | 是 | 被代理应用的包名。 |
| userId | number | 是 | 用户ID。 |
**示例:**
```js
// 被代理应用的包名
let representativeBundle = "com.example.demo";
// 用户ID
let userId = 100;
// NotificationRequest对象
let request = {
id: 1,
content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
}
}
};
Notification.publishAsBundle(request, representativeBundle, userId).then(() => {
console.info("publishAsBundle success");
});
```
## Notification.cancelAsBundle<sup>9+</sup>
cancelAsBundle(id: number, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void
取消代理通知(callback形式)。
**系统能力**:SystemCapability.Notification.Notification
**系统API**:此接口为系统接口,三方应用不支持调用。
**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER,ohos.permission.NOTIFICATION_AGENT_CONTROLLER
**系统API**: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------------- | ------------- | ---- | ------------------------ |
| id | number | 是 | 通知ID。 |
| representativeBundle | string | 是 | 被代理应用的包名。 |
| userId | number | 是 | 用户ID。 |
| callback | AsyncCallback | 是 | 取消代理通知的回调方法。 |
**示例:**
```js
// cancelAsBundle
function cancelAsBundleCallback(err) {
if (err.code) {
console.info("cancelAsBundle failed " + JSON.stringify(err));
} else {
console.info("cancelAsBundle success");
}
}
// 被代理应用的包名
let representativeBundle = "com.example.demo";
// 用户ID
let userId = 100;
Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback);
```
## Notification.cancelAsBundle<sup>9+</sup>
cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\<void\>
取消代理通知(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification
**系统API**:此接口为系统接口,三方应用不支持调用。
**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER,ohos.permission.NOTIFICATION_AGENT_CONTROLLER
**系统API**: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------------- | ------ | ---- | ------------------ |
| id | number | 是 | 通知ID。 |
| representativeBundle | string | 是 | 被代理应用的包名。 |
| userId | number | 是 | 用户ID。 |
**示例:**
```js
// 被代理应用的包名
let representativeBundle = "com.example.demo";
// 用户ID
let userId = 100;
Notification.cancelAsBundle(0, representativeBundle, userId).then(() => {
console.info("cancelAsBundle success");
});
```
## Notification.enableNotificationSlot <sup>9+</sup>
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\<void>): void
设置指定应用的指定渠道类型的使能状态(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification
**系统API**:此接口为系统接口,三方应用不支持调用。
**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------- | ---- | ---------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 |
| type | [SlotType](#slottype) | 是 | 指定渠道类型。 |
| enable | boolean | 是 | 使能状态。 |
| callback | AsyncCallback\<void\> | 是 | 设置渠道使能回调函数。 |
**示例:**
```js
// enableNotificationSlot
function enableSlotCallback(err) {
if (err.code) {
console.info("enableNotificationSlot failed " + JSON.stringify(err));
} else {
console.info("enableNotificationSlot success");
}
};
Notification.enableNotificationSlot(
{ bundle: "ohos.samples.notification", },
Notification.SlotType.SOCIAL_COMMUNICATION,
true,
enableSlotCallback);
```
## Notification.enableNotificationSlot <sup>9+</sup>
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\<void>
设置指定应用的指定渠道类型的使能状态(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification
**系统API**:此接口为系统接口,三方应用不支持调用。
**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 |
| type | [SlotType](#slottype) | 是 | 渠道类型。 |
| enable | boolean | 是 | 使能状态。 |
**示例:**
```js
// enableNotificationSlot
Notification.enableNotificationSlot({ bundle: "ohos.samples.notification", },
Notification.SlotType.SOCIAL_COMMUNICATION,true).then(() => {
console.info("enableNotificationSlot success");
});
```
## Notification.isNotificationSlotEnabled <sup>9+</sup>
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\<boolean\>): void
获取指定应用的指定渠道类型的使能状态(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification
**系统API**:此接口为系统接口,三方应用不支持调用。
**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------- | ---- | ---------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 |
| type | [SlotType](#slottype) | 是 | 渠道类型。 |
| callback | AsyncCallback\<boolean\> | 是 | 获取渠道使能状态回调函数。 |
**示例:**
```js
// isNotificationSlotEnabled
function getEnableSlotCallback(err, data) {
if (err.code) {
console.info("isNotificationSlotEnabled failed " + JSON.stringify(err));
} else {
console.info("isNotificationSlotEnabled success");
}
};
Notification.isNotificationSlotEnabled(
{ bundle: "ohos.samples.notification", },
Notification.SlotType.SOCIAL_COMMUNICATION,
getEnableSlotCallback);
```
## Notification.isNotificationSlotEnabled <sup>9+</sup>
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolean\>
获取指定应用的指定渠道类型的使能状态(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification
**系统API**:此接口为系统接口,三方应用不支持调用。
**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 |
| type | [SlotType](#slottype) | 是 | 渠道类型。 |
**返回值:**
| 类型 | 说明 |
| ------------------ | ------------------------------- |
| Promise\<boolean\> | 以Promise形式返回渠道使能状态。 |
**示例:**
```js
// isNotificationSlotEnabled
Notification.isNotificationSlotEnabled({ bundle: "ohos.samples.notification", },
Notification.SlotType.SOCIAL_COMMUNICATION).then((data) => {
console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data));
});
```
## Notification.setSyncNotificationEnabledWithoutApp<sup>9+</sup>
setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: AsyncCallback\<void\>): void
设置是否将通知同步到未安装应用程序的设备(callback形式)。
**系统能力**:SystemCapability.Notification.Notification
**系统API**:此接口为系统接口,三方应用不支持调用。
**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | 是 | 用户ID。 |
| enable | boolean | 是 | 是否启用。 |
| callback | AsyncCallback\<void\> | 是 | 设置是否将通知同步到未安装应用程序的设备的回调函数。 |
**示例:**
```js
let userId = 100;
let enable = true;
function callback(err) {
if (err.code) {
console.info("setSyncNotificationEnabledWithoutApp failed " + JSON.stringify(err));
} else {
console.info("setSyncNotificationEnabledWithoutApp success");
}
}
Notification.setSyncNotificationEnabledWithoutApp(userId, enable, callback);
```
## Notification.setSyncNotificationEnabledWithoutApp<sup>9+</sup>
setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<void>
设置是否将通知同步到未安装应用程序的设备(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification
**系统API**:此接口为系统接口,三方应用不支持调用。
**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | 是 | 用户ID。 |
| enable | boolean | 是 | 是否启用。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<void\> | 以Promise形式返回设置是否将通知同步到未安装应用程序的设备的结果。 |
**示例:**
```js
let userId = 100;
let enable = true;
Notification.setSyncNotificationEnabledWithoutApp(userId, enable).then(() => {
console.info('setSyncNotificationEnabledWithoutApp success');
}).catch((err) => {
console.info('setSyncNotificationEnabledWithoutApp, err:' + JSON.stringify(err));
});
```
## Notification.getSyncNotificationEnabledWithoutApp<sup>9+</sup>
getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<boolean>): void
获取同步通知到未安装应用程序设备的开关是否开启(callback形式)。
**系统能力**:SystemCapability.Notification.Notification
**系统API**:此接口为系统接口,三方应用不支持调用。
**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | 是 | 用户ID。 |
| callback | AsyncCallback\<boolean\> | 是 | 获取同步通知到未安装应用程序设备的开关是否开启的回调函数。 |
**示例:**
```js
let userId = 100;
function getSyncNotificationEnabledWithoutAppCallback(err, data) {
if (err) {
console.info('getSyncNotificationEnabledWithoutAppCallback, err:' + err);
} else {
console.info('getSyncNotificationEnabledWithoutAppCallback, data:' + data);
}
}
Notification.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEnabledWithoutAppCallback);
```
## Notification.getSyncNotificationEnabledWithoutApp<sup>9+</sup>
getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>
获取同步通知到未安装应用程序设备的开关是否开启(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification
**系统API**:此接口为系统接口,三方应用不支持调用。
**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | 是 | 用户ID。 |
**返回值:**
| 类型 | 说明 |
| ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | 以Promise形式返回获取同步通知到未安装应用程序设备的开关是否开启的结果。 |
**示例:**
```js
let userId = 100;
Notification.getSyncNotificationEnabledWithoutApp(userId).then((data) => {
console.info('getSyncNotificationEnabledWithoutApp, data:' + data);
}).catch((err) => {
console.info('getSyncNotificationEnabledWithoutApp, err:' + err);
});
```
## NotificationSubscriber
作为订阅通知接口[subscribe](#notificationsubscribe)的入参,提供订阅者接收到新通知、取消通知等的回调方法。
......@@ -4121,5 +3651,5 @@ Notification.enableNotification(bundle, false).then(() => {
| 名称 | 值 | 说明 |
| -------------------- | --- | -------------------- |
| CLICK_REASON_REMOVE | 1 | 点击通知后删除通知。 |
| CANCEL_REASON_REMOVE | 2 | 用户删除通知。 |
\ No newline at end of file
| CLICK_REASON_REMOVE<sup>9+</sup> | 1 | 点击通知后删除通知。 |
| CANCEL_REASON_REMOVE<sup>9+</sup> | 2 | 用户删除通知。 |
\ No newline at end of file
......@@ -33,7 +33,6 @@ publish(request: NotificationRequest, callback: AsyncCallback\<void\>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -89,8 +88,6 @@ publish(request: NotificationRequest): Promise\<void\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------------- |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -145,8 +142,6 @@ publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<v
| 错误码ID | 错误信息 |
| -------- | ----------------------------------------- |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -208,8 +203,6 @@ publish(request: NotificationRequest, userId: number): Promise\<void\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------------- |
| 201 | Permission denied. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -263,7 +256,6 @@ cancel(id: number, label: string, callback: AsyncCallback\<void\>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -306,7 +298,6 @@ cancel(id: number, label?: string): Promise\<void\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -343,7 +334,6 @@ cancel(id: number, callback: AsyncCallback\<void\>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -379,7 +369,6 @@ cancelAll(callback: AsyncCallback\<void\>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -420,7 +409,6 @@ cancelAll(): Promise\<void\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -460,9 +448,6 @@ addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -511,9 +496,6 @@ addSlot(slot: NotificationSlot): Promise\<void\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -553,7 +535,6 @@ addSlot(type: SlotType, callback: AsyncCallback\<void\>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -594,7 +575,6 @@ addSlot(type: SlotType): Promise\<void\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -634,9 +614,6 @@ addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): voi
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -689,9 +666,6 @@ addSlots(slots: Array\<NotificationSlot\>): Promise\<void\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -735,7 +709,6 @@ getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -783,7 +756,6 @@ getSlot(slotType: SlotType): Promise\<NotificationSlot\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -801,7 +773,7 @@ Notification.getSlot(slotType).then((data) => {
## Notification.getSlots
getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void
getSlots(callback: AsyncCallback\<Array\<NotificationSlot>>): void
获取此应用程序的所有通知通道(callback形式)。
......@@ -819,7 +791,6 @@ getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -842,7 +813,7 @@ Notification.getSlots(getSlotsCallback);
## Notification.getSlots
getSlots(): Promise\<Array\<NotificationSlot\>>
getSlots(): Promise\<Array\<NotificationSlot>>
获取此应用程序的所有通知通道(Promise形式)。
......@@ -860,7 +831,6 @@ getSlots(): Promise\<Array\<NotificationSlot\>>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -896,7 +866,6 @@ removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -938,7 +907,6 @@ removeSlot(slotType: SlotType): Promise\<void\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -974,7 +942,6 @@ removeAllSlots(callback: AsyncCallback\<void\>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -1008,7 +975,6 @@ removeAllSlots(): Promise\<void\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -1049,9 +1015,6 @@ setNotificationEnable(bundle: BundleOption, enable: boolean, callback: AsyncCall
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -1100,9 +1063,6 @@ setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\<void\>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -1146,9 +1106,6 @@ isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>):
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -1202,9 +1159,6 @@ isNotificationEnabled(bundle: BundleOption): Promise\<boolean\>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -1247,9 +1201,6 @@ isNotificationEnabled(callback: AsyncCallback\<boolean\>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -1282,11 +1233,93 @@ isNotificationEnabled(): Promise\<boolean\>
**系统API**: 此接口为系统接口,三方应用不支持调用。
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | 以Promise形式返回获取通知使能状态的结果。 |
**错误码:**
错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
**示例:**
```ts
notificationManager.isNotificationEnabled().then((data) => {
console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
});
```
## notificationManager.isNotificationEnabled
isNotificationEnabled(userId: number, callback: AsyncCallback\<boolean\>): void
获取制定用户ID下的通知使能状态(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification
**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
**系统API**: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------------ |
| userId | number | 是 | 指定的用户ID。 |
| callback | AsyncCallback\<void\> | 是 | 获取通知使能状态回调函数。 |
**错误码:**
错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
| 1600008 | The user is not exist. |
**示例:**
```ts
function isNotificationEnabledCallback(err, data) {
if (err) {
console.error(`isNotificationEnabled failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("isNotificationEnabled success");
}
}
let userId = 1;
notificationManager.isNotificationEnabled(userId, isNotificationEnabledCallback);
```
## notificationManager.isNotificationEnabled
isNotificationEnabled(userId: number): Promise\<boolean\>
获取制定用户下的通知使能状态(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification
**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
**系统API**: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是 | 指定应用的包信息。 |
| userId | number | 是 | 指定的用户ID。 |
**返回值:**
......@@ -1300,18 +1333,17 @@ isNotificationEnabled(): Promise\<boolean\>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
| 17700001 | The specified bundle name was not found. |
| 1600008 | The user is not exist.. |
**示例:**
```js
Notification.isNotificationEnabled().then((data) => {
```ts
let userId = 1;
notificationManager.isNotificationEnabled(userId).then((data) => {
console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
});
```
......@@ -1344,9 +1376,6 @@ displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<voi
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -1395,9 +1424,6 @@ displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -1441,9 +1467,6 @@ isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -1497,9 +1520,6 @@ isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -1542,9 +1562,6 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCal
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -1598,9 +1615,6 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -1624,7 +1638,7 @@ Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
## Notification.getSlotsByBundle
getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<NotificationSlot\>>): void
getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback\<Array\<NotificationSlot>>): void
获取指定应用的所有通知通道(Callback形式)。
......@@ -1639,7 +1653,7 @@ getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<Notificati
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | -------------------- |
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是 | 指定应用的包信息。 |
| callback | AsyncCallback<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\>> | 是 | 获取通知通道回调函数。 |
| callback | AsyncCallback\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)>> | 是 | 获取通知通道回调函数。 |
**错误码:**
......@@ -1647,9 +1661,6 @@ getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<Notificati
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -1675,7 +1686,7 @@ Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
## Notification.getSlotsByBundle
getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>>
getSlotsByBundle(bundle: BundleOption): Promise\<Array\<NotificationSlot>>
获取指定应用的所有通知通道(Promise形式)。
......@@ -1695,7 +1706,7 @@ getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>>
| 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\>> | 以Promise形式返回获取指定应用的通知通道。 |
| Promise\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)>> | 以Promise形式返回获取指定应用的通知通道。 |
**错误码:**
......@@ -1703,9 +1714,6 @@ getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -1749,9 +1757,6 @@ getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): voi
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -1805,9 +1810,6 @@ getSlotNumByBundle(bundle: BundleOption): Promise\<number\>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -1829,7 +1831,7 @@ Notification.getSlotNumByBundle(bundle).then((data) => {
## Notification.getAllActiveNotifications
getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void
getAllActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): void
获取当前未删除的所有通知(Callback形式)。
......@@ -1843,7 +1845,7 @@ getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>)
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | -------------------- |
| callback | AsyncCallback<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>> | 是 | 获取活动通知回调函数。 |
| callback | AsyncCallback\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)>> | 是 | 获取活动通知回调函数。 |
**错误码:**
......@@ -1851,9 +1853,6 @@ getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>)
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -1898,9 +1897,6 @@ getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](js-apis-inner
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -1935,7 +1931,6 @@ getActiveNotificationCount(callback: AsyncCallback\<number\>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -1976,7 +1971,6 @@ getActiveNotificationCount(): Promise\<number\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -1993,7 +1987,7 @@ Notification.getActiveNotificationCount().then((data) => {
## Notification.getActiveNotifications
getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void
getActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): void
获取当前应用未删除的通知列表(Callback形式)。
......@@ -2003,7 +1997,7 @@ getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): v
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------ |
| callback | AsyncCallback<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>> | 是 | 获取当前应用通知列表回调函数。 |
| callback | AsyncCallback\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)>> | 是 | 获取当前应用通知列表回调函数。 |
**错误码:**
......@@ -2011,7 +2005,6 @@ getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): v
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -2052,7 +2045,6 @@ getActiveNotifications(): Promise\<Array\<[NotificationRequest](js-apis-inner-no
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -2088,7 +2080,6 @@ cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -2131,7 +2122,6 @@ cancelGroup(groupName: string): Promise\<void\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -2173,9 +2163,6 @@ removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCall
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -2225,9 +2212,6 @@ removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -2270,9 +2254,6 @@ setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\<void\>): vo
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -2323,9 +2304,6 @@ setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -2370,9 +2348,6 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallb
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -2427,9 +2402,6 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -2476,9 +2448,6 @@ getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -2523,9 +2492,6 @@ getDoNotDisturbDate(): Promise\<DoNotDisturbDate\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -2564,9 +2530,6 @@ getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>)
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -2620,9 +2583,6 @@ getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -2663,9 +2623,6 @@ isSupportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -2710,9 +2667,6 @@ isSupportDoNotDisturbMode(): Promise\<boolean\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -2748,11 +2702,9 @@ isSupportTemplate(templateName: string, callback: AsyncCallback\<boolean\>): voi
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
| 1600011 | Read template config failed. |
**示例:**
......@@ -2797,11 +2749,9 @@ isSupportTemplate(templateName: string): Promise\<boolean\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
| 1600011 | Read template config failed. |
**示例:**
......@@ -2835,7 +2785,6 @@ requestEnableNotification(callback: AsyncCallback\<void\>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -2870,7 +2819,6 @@ requestEnableNotification(): Promise\<void\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -2910,9 +2858,6 @@ setDistributedEnable(enable: boolean, callback: AsyncCallback\<void\>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -2960,9 +2905,6 @@ setDistributedEnable(enable: boolean): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -2999,7 +2941,6 @@ isDistributedEnabled(callback: AsyncCallback\<boolean>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -3041,7 +2982,6 @@ isDistributedEnabled(): Promise\<boolean>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -3083,9 +3023,6 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean, callback: As
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -3139,9 +3076,6 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean): Promise\<vo
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -3187,9 +3121,6 @@ isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<bool
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -3246,9 +3177,6 @@ isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -3292,9 +3220,6 @@ getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -3339,9 +3264,6 @@ getDeviceRemindType(): Promise\<DeviceRemindType\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -3382,9 +3304,6 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user
| 错误码ID | 错误信息 |
| -------- | ----------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -3451,9 +3370,6 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user
| 错误码ID | 错误信息 |
| -------- | ----------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -3516,9 +3432,6 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number, callbac
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -3572,9 +3485,6 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number): Promis
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -3621,9 +3531,6 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean,
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -3674,9 +3581,6 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean)
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -3720,9 +3624,6 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncC
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -3777,9 +3678,6 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolea
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -3822,9 +3720,6 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback:
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -3879,9 +3774,6 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -3926,9 +3818,6 @@ getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<bo
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -3981,9 +3870,6 @@ getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......
......@@ -40,9 +40,6 @@ subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, c
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -95,9 +92,6 @@ subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>):
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -148,9 +142,6 @@ subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo):
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -196,9 +187,6 @@ unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>)
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -246,9 +234,6 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\<void\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -294,9 +279,6 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -352,9 +334,6 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -371,7 +350,7 @@ let notificationKey = {
id: 0,
label: "label",
};
let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
let reason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
notificationSubscribe.remove(bundle, notificationKey, reason).then(() => {
console.info("remove success");
});
......@@ -393,7 +372,7 @@ remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>):
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------- |
| hashCode | string | 是 | 通知唯一ID。可以通过[onConsume](#onconsume)回调的入参[SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)获取其内部[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)对象中的hashCode。 |
| hashCode | string | 是 | 通知唯一ID。可以通过[onConsume](js-apis-notification.md#onconsume)回调的入参[SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)获取其内部[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)对象中的hashCode。 |
| reason | [RemoveReason](#removereason) | 是 | 通知删除原因。 |
| callback | AsyncCallback\<void\> | 是 | 删除指定通知回调函数。 |
......@@ -403,9 +382,6 @@ remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>):
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -423,7 +399,7 @@ function removeCallback(err) {
console.info("remove success");
}
}
let reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE;
let reason = notificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE;
notificationSubscribe.remove(hashCode, reason, removeCallback);
```
......@@ -452,9 +428,6 @@ remove(hashCode: string, reason: RemoveReason): Promise\<void\>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -495,9 +468,6 @@ removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -516,7 +486,7 @@ function removeAllCallback(err) {
let bundle = {
bundle: "bundleName1",
};
NotificationSubscribe.removeAll(bundle, removeAllCallback);
notificationSubscribe.removeAll(bundle, removeAllCallback);
```
## NotificationSubscribe.removeAll
......@@ -543,9 +513,6 @@ removeAll(callback: AsyncCallback\<void\>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -588,9 +555,6 @@ removeAll(bundle?: BundleOption): Promise\<void\>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -630,9 +594,6 @@ removeAll(userId: number, callback: AsyncCallback\<void>): void
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -678,9 +639,6 @@ removeAll(userId: number): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
......@@ -702,319 +660,6 @@ let userId = 1;
notificationSubscribe.removeAll(userId, removeAllCallback);
```
## NotificationSubscriber
作为订阅通知接口[subscribe](#notificationsubscribe)的入参,提供订阅者接收到新通知、取消通知等的回调方法。
**系统API**:此接口为系统接口,三方应用不支持调用。
### onConsume
onConsume?: (data: [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)) => void
接收到新通知的回调函数。
**系统能力**:SystemCapability.Notification.Notification
**系统接口**: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) | 是 | 新接收到的通知信息。 |
**示例:**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onConsumeCallback(data) {
console.info('===> onConsume in test');
let req = data.request;
console.info('===> onConsume callback req.id:' + req.id);
};
let subscriber = {
onConsume: onConsumeCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onCancel
onCancel?:(data: [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)) => void
取消通知的回调函数。
**系统能力**:SystemCapability.Notification.Notification
**系统API**: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) | 是 | 需要取消的通知信息。 |
**示例:**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onCancelCallback(data) {
console.info('===> onCancel in test');
let req = data.request;
console.info('===> onCancel callback req.id:' + req.id);
}
let subscriber = {
onCancel: onCancelCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onUpdate
onUpdate?:(data: [NotificationSortingMap](js-apis-notification.md#notificationsortingmap)) => void
更新通知排序的回调函数。
**系统能力**:SystemCapability.Notification.Notification
**系统API**: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [NotificationSortingMap](js-apis-notification.md#notificationsortingmap)) | 是 | 最新的通知排序列表。 |
**示例:**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onUpdateCallback(map) {
console.info('===> onUpdateCallback map:' + JSON.stringify(map));
}
let subscriber = {
onUpdate: onUpdateCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onConnect
onConnect?:() => void
订阅完成的回调函数。
**系统能力**:SystemCapability.Notification.Notification
**系统API**: 此接口为系统接口,三方应用不支持调用。
**示例:**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onConnectCallback() {
console.info('===> onConnect in test');
}
let subscriber = {
onConnect: onConnectCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onDisconnect
onDisconnect?:() => void
取消订阅的回调函数。
**系统能力**:SystemCapability.Notification.Notification
**系统API**: 此接口为系统接口,三方应用不支持调用。
**示例:**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function unsubscribeCallback(err) {
if (err.code) {
console.error(`unsubscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("unsubscribeCallback");
}
};
function onConnectCallback() {
console.info('===> onConnect in test');
}
function onDisconnectCallback() {
console.info('===> onDisconnect in test');
}
let subscriber = {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback
};
// 订阅通知后会收到onConnect回调
notificationSubscribe.subscribe(subscriber, subscribeCallback);
// 取消订阅后会收到onDisconnect回调
notificationSubscribe.unsubscribe(subscriber, unsubscribeCallback);
```
### onDestroy
onDestroy?:() => void
服务失联回调函数。
**系统能力**:SystemCapability.Notification.Notification
**系统API**: 此接口为系统接口,三方应用不支持调用。
**示例:**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onDestroyCallback() {
console.info('===> onDestroy in test');
}
let subscriber = {
onDestroy: onDestroyCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onDoNotDisturbDateChange
onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](js-apis-notificationManager.md#donotdisturbdate)) => void
免打扰时间选项发生变更时的回调函数。
**系统能力**:SystemCapability.Notification.Notification
**系统API**: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------ | ---- | -------------------------- |
| mode | notification.[DoNotDisturbDate](js-apis-notificationManager.md#DoNotDisturbDate) | 是 | 回调返回免打扰时间选项变更。 |
**示例:**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onDoNotDisturbDateChangeCallback(mode) {
console.info('===> onDoNotDisturbDateChange:' + mode);
}
let subscriber = {
onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onEnabledNotificationChanged
onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](js-apis-notification.md#enablednotificationcallbackdata)) => void
监听应用通知使能变化。
**系统能力**:SystemCapability.Notification.Notification
**系统API**: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<[EnabledNotificationCallbackData](js-apis-notification.md#enablednotificationcallbackdata)\> | 是 | 回调返回监听到的应用信息。 |
**示例:**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onEnabledNotificationChangedCallback(callbackData) {
console.info("bundle: ", callbackData.bundle);
console.info("uid: ", callbackData.uid);
console.info("enable: ", callbackData.enable);
};
let subscriber = {
onEnabledNotificationChanged: onEnabledNotificationChangedCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
## RemoveReason
**系统能力**:SystemCapability.Notification.Notification
......
......@@ -18,13 +18,16 @@ import reminderAgent from'@ohos.reminderAgent';
```
## reminderAgent.publishReminder
## reminderAgent.publishReminder<sup>(deprecated)</sup>
publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback&lt;number&gt;): void
发布一个后台代理提醒,使用callback方式实现异步调用,该方法需要申请通知弹窗[Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8)后才能调用。
**需要权限**: ohos.permission.PUBLISH_AGENT_REMINDER
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.publishReminder](js-apis-reminderAgentManager.md#reminderagentmanagerpublishreminder)替代。
**需要权限**`ohos.permission.PUBLISH_AGENT_REMINDER`
**系统能力**: SystemCapability.Notification.ReminderAgent
......@@ -47,13 +50,16 @@ publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback&lt;number&
```
## reminderAgent.publishReminder
## reminderAgent.publishReminder<sup>(deprecated)</sup>
publishReminder(reminderReq: ReminderRequest): Promise&lt;number&gt;
发布一个后台代理提醒,使用Promise方式实现异步调用,该方法需要申请通知弹窗[Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8)后才能调用。
**需要权限**: ohos.permission.PUBLISH_AGENT_REMINDER
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.publishReminder](js-apis-reminderAgentManager.md#reminderagentmanagerpublishreminder-1)替代。
**需要权限**`ohos.permission.PUBLISH_AGENT_REMINDER`
**系统能力**: SystemCapability.Notification.ReminderAgent
......@@ -79,13 +85,16 @@ publishReminder(reminderReq: ReminderRequest): Promise&lt;number&gt;
```
## reminderAgent.cancelReminder
## reminderAgent.cancelReminder<sup>(deprecated)</sup>
cancelReminder(reminderId: number, callback: AsyncCallback&lt;void&gt;): void
取消指定id的提醒,使用callback方式实现异步调用。
**系统能力**: SystemCapability.Notification.ReminderAgent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.cancelReminder](js-apis-reminderAgentManager.md#reminderagentmanagercancelreminder)替代。
**系统能力**`SystemCapability.Notification.ReminderAgent`
**参数**
......@@ -103,13 +112,16 @@ reminderAgent.cancelReminder(1, (err, data) => {
```
## reminderAgent.cancelReminder
## reminderAgent.cancelReminder<sup>(deprecated)</sup>
cancelReminder(reminderId: number): Promise&lt;void&gt;
cancelReminder(reminderId: number): Promise\<void>
取消指定id的提醒,使用Promise方式实现异步调用。
**系统能力**: SystemCapability.Notification.ReminderAgent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.cancelReminder](js-apis-reminderAgentManager.md#reminderagentmanagercancelreminder-1)替代。
**系统能力**`SystemCapability.Notification.ReminderAgent`
**参数**
......@@ -131,14 +143,16 @@ reminderAgent.cancelReminder(1).then(() => {
});
```
## reminderAgent.getValidReminders<sup>(deprecated)</sup>
## reminderAgent.getValidReminders
getValidReminders(callback: AsyncCallback&lt;Array&lt;ReminderRequest&gt;&gt;): void
getValidReminders(callback: AsyncCallback\<Array\<ReminderRequest>>): void
获取当前应用已设置的所有有效(未过期)的提醒,使用callback方式实现异步调用。
**系统能力**: SystemCapability.Notification.ReminderAgent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.getValidReminders](js-apis-reminderAgentManager.md#reminderagentmanagergetvalidreminders)替代。
**系统能力**`SystemCapability.Notification.ReminderAgent`
**参数**
......@@ -176,13 +190,16 @@ reminderAgent.getValidReminders((err, reminders) => {
```
## reminderAgent.getValidReminders
## reminderAgent.getValidReminders<sup>(deprecated)</sup>
getValidReminders(): Promise&lt;Array&lt;ReminderRequest&gt;&gt;
getValidReminders(): Promise\<Array\<ReminderRequest>>
获取当前应用已设置的所有有效(未过期)的提醒,使用Promise方式实现异步调用。
**系统能力**: SystemCapability.Notification.ReminderAgent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.getValidReminders](js-apis-reminderAgentManager.md#reminderagentmanagergetvalidreminders-1)替代。
**系统能力**`SystemCapability.Notification.ReminderAgent`
**返回值**
......@@ -220,13 +237,16 @@ reminderAgent.getValidReminders().then((reminders) => {
```
## reminderAgent.cancelAllReminders
## reminderAgent.cancelAllReminders<sup>(deprecated)</sup>
cancelAllReminders(callback: AsyncCallback&lt;void&gt;): void
取消当前应用所有的提醒,使用callback方式实现异步调用。
**系统能力**: SystemCapability.Notification.ReminderAgent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.cancelAllReminders](js-apis-reminderAgentManager.md#reminderagentmanagercancelallreminders)替代。
**系统能力**`SystemCapability.Notification.ReminderAgent`
**参数**
......@@ -243,13 +263,16 @@ reminderAgent.cancelAllReminders((err, data) =>{
```
## reminderAgent.cancelAllReminders
## reminderAgent.cancelAllReminders<sup>(deprecated)</sup>
cancelAllReminders(): Promise&lt;void&gt;
cancelAllReminders(): Promise\<void>
取消当前应用所有的提醒,使用Promise方式实现异步调用。
**系统能力**: SystemCapability.Notification.ReminderAgent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.cancelAllReminders](js-apis-reminderAgentManager.md#reminderagentmanagercancelallreminders-1)替代。
**系统能力**`SystemCapability.Notification.ReminderAgent`
**返回值**
......@@ -272,7 +295,10 @@ addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback&lt;void&gt;)
添加一个NotificationSlot,使用callback方式实现异步调用。
**系统能力**: SystemCapability.Notification.ReminderAgent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.addNotificationSlot](js-apis-reminderAgentManager.md#reminderagentmanageraddnotificationslot)替代。
**系统能力**`SystemCapability.Notification.ReminderAgent`
**参数**
......@@ -295,13 +321,16 @@ reminderAgent.addNotificationSlot(mySlot, (err, data) => {
```
## reminderAgent.addNotificationSlot
## reminderAgent.addNotificationSlot<sup>(deprecated)</sup>
addNotificationSlot(slot: NotificationSlot): Promise&lt;void&gt;
addNotificationSlot(slot: NotificationSlot): Promise\<void>
添加一个NotificationSlot,使用Promise方式实现异步调用。
**系统能力**: SystemCapability.Notification.ReminderAgent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.addNotificationSlot](js-apis-reminderAgentManager.md#reminderagentmanageraddnotificationslot-1)替代。
**系统能力**`SystemCapability.Notification.ReminderAgent`
**参数**
......@@ -329,13 +358,16 @@ reminderAgent.addNotificationSlot(mySlot).then(() => {
```
## reminderAgent.removeNotificationSlot
## reminderAgent.removeNotificationSlot<sup>(deprecated)</sup>
removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback&lt;void&gt;): void
删除目标NotificationSlot,使用callback方式实现异步调用。
**系统能力**: SystemCapability.Notification.ReminderAgent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.removeNotificationSlot](js-apis-reminderAgentManager.md#reminderagentmanagerremovenotificationslot)替代。
**系统能力**`SystemCapability.Notification.ReminderAgent`
**参数**
......@@ -355,13 +387,16 @@ reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION,
```
## reminderAgent.removeNotificationSlot
## reminderAgent.removeNotificationSlot<sup>(deprecated)</sup>
removeNotificationSlot(slotType: notification.SlotType): Promise&lt;void&gt;
删除目标NotificationSlot,使用Promise方式实现异步调用。
**系统能力**: SystemCapability.Notification.ReminderAgent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.removeNotificationSlot](js-apis-reminderAgentManager.md#reminderagentmanagerremovenotificationslot-1)替代。
**系统能力**`SystemCapability.Notification.ReminderAgent`
**参数**
......@@ -386,11 +421,14 @@ reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION).
```
## ActionButtonType
## ActionButtonType<sup>(deprecated)</sup>
按钮的类型。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.ReminderAgent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.ActionButtonType](js-apis-reminderAgentManager.md#ActionButtonType)替代。
**系统能力**`SystemCapability.Notification.ReminderAgent`
| 名称 | 值 | 说明 |
| -------- | -------- | -------- |
......@@ -398,11 +436,14 @@ reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION).
| ACTION_BUTTON_TYPE_SNOOZE | 1 | 表示延迟提醒的按钮。 |
## ReminderType
## ReminderType<sup>(deprecated)</sup>
提醒的类型。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.ReminderAgent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.ReminderType](js-apis-reminderAgentManager.md#ReminderType)替代。
**系统能力**`SystemCapability.Notification.ReminderAgent`
| 名称 | 值 | 说明 |
| -------- | -------- | -------- |
......@@ -411,11 +452,14 @@ reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION).
| REMINDER_TYPE_ALARM | 2 | 表示提醒类型:闹钟。 |
## ActionButton
## ActionButton<sup>(deprecated)</sup>
用于设置弹出的提醒通知信息上显示的按钮类型和标题。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.ReminderAgent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.ActionButton](js-apis-reminderAgentManager.md#ActionButton)替代。
**系统能力**`SystemCapability.Notification.ReminderAgent`
| 名称 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
......@@ -423,11 +467,14 @@ reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION).
| type | [ActionButtonType](#actionbuttontype) | 是 | 按钮的类型。 |
## WantAgent
## WantAgent<sup>(deprecated)</sup>
点击提醒通知后跳转的目标ability信息。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.ReminderAgent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.WantAgent](js-apis-reminderAgentManager.md#WantAgent)替代。
**系统能力**`SystemCapability.Notification.ReminderAgent`
| 名称 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
......@@ -435,11 +482,14 @@ reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION).
| abilityName | string | 是 | 指明点击提醒通知栏后跳转的目标ability名称。 |
## MaxScreenWantAgent
## MaxScreenWantAgent<sup>(deprecated)</sup>
全屏显示提醒到达时自动拉起的目标ability信息,该接口预留。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.ReminderAgent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.MaxScreenWantAgent](js-apis-reminderAgentManager.md#MaxScreenWantAgent)替代。
**系统能力**`SystemCapability.Notification.ReminderAgent`
| 名称 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
......@@ -447,11 +497,14 @@ reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION).
| abilityName | string | 是 | 指明提醒到达时自动拉起的目标ability名(如果设备在使用中,则只弹出通知横幅框)。 |
## ReminderRequest
## ReminderRequest<sup>(deprecated)</sup>
提醒实例对象,用于设置提醒类型、响铃时长等具体信息。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.ReminderAgent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.ReminderRequest](js-apis-reminderAgentManager.md#ReminderRequest)替代。
**系统能力**`SystemCapability.Notification.ReminderAgent`
| 名称 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
......@@ -470,13 +523,16 @@ reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION).
| slotType | [notification.SlotType](js-apis-notification.md#slottype) | 否 | 指明提醒的slot类型。 |
## ReminderRequestCalendar
## ReminderRequestCalendar<sup>(deprecated)</sup>
ReminderRequestCalendar extends ReminderRequest
日历实例对象,用于设置提醒的时间。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.ReminderAgent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.ReminderRequestCalendar](js-apis-reminderAgentManager.md#ReminderRequestCalendar)替代。
**系统能力**`SystemCapability.Notification.ReminderAgent`
| 名称 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
......@@ -485,13 +541,16 @@ ReminderRequestCalendar extends ReminderRequest
| repeatDays | Array&lt;number&gt; | 否 | 指明重复提醒的日期。 |
## ReminderRequestAlarm
## ReminderRequestAlarm<sup>(deprecated)</sup>
ReminderRequestAlarm extends ReminderRequest
闹钟实例对象,用于设置提醒的时间。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.ReminderAgent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.ReminderRequestAlarm](js-apis-reminderAgentManager.md#ReminderRequestAlarm)替代。
**系统能力**`SystemCapability.Notification.ReminderAgent`
| 名称 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
......@@ -500,24 +559,30 @@ ReminderRequestAlarm extends ReminderRequest
| daysOfWeek | Array&lt;number&gt; | 否 | 指明每周哪几天需要重复提醒。范围为周一到周末,对应数字为1到7。 |
## ReminderRequestTimer
## ReminderRequestTimer<sup>(deprecated)</sup>
ReminderRequestTimer extends ReminderRequest
倒计时实例对象,用于设置提醒的时间。
**系统能力**:SystemCapability.Notification.ReminderAgent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.ReminderRequestTimer](js-apis-reminderAgentManager.md#ReminderRequestTimer)替代。
**系统能力**`SystemCapability.Notification.ReminderAgent`
| 名称 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| triggerTimeInSeconds | number | 是 | 指明倒计时的秒数。 |
## LocalDateTime
## LocalDateTime<sup>(deprecated)</sup>
用于日历类提醒设置时指定时间信息。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.ReminderAgent
> **说明:**
> 从 API version 7开始支持,从API version 9开始废弃。建议使用[reminderAgentManager.LocalDateTime](js-apis-reminderAgentManager.md#LocalDateTime)替代。
**系统能力**`SystemCapability.Notification.ReminderAgent`
| 名称 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
......
......@@ -564,7 +564,7 @@ try {
用于设置弹出的提醒通知信息上显示的按钮类型和标题。
**系统能力**以下各项对应的系统能力均为SystemCapability.Notification.ReminderAgent
**系统能力**`SystemCapability.Notification.ReminderAgent`
| 名称 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
......@@ -580,8 +580,9 @@ try {
| 名称 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| pkgName | string | 是 | 指明点击提醒通知栏后跳转的目标hap包名。 |
| abilityName | string | 是 | 指明点击提醒通知栏后跳转的目标ability名称。 |
| pkgName | string | 是 | 指明跳转的目标包名。 |
| abilityName | string | 是 | 指明跳转的目标ability名称。 |
| uri | string | 否 | 指明跳转目标的uri信息。(系统接口) |
## MaxScreenWantAgent
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册