diff --git a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md index 7021e14af331825f3b7c0c0fe94ccd355a921a4a..5f81b82701b12d352f4178cfba5b5c61df64c496 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md @@ -1,6 +1,6 @@ # 公共事件模块 -> **说明:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## 权限列表 @@ -208,7 +208,7 @@ publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\ | 名称 | 读写属性 | 类型 | 必填 | 描述 | | -------- | -------- | ---------------------- | ---- | ---------------------- | | event | 只读 | string | 是 | 表示要发布的公共事件。 | -| options | 只读 | [CommonEventPublishData](./js-apis-commonEventPublishData.md) | 是 | 表示发布公共事件的属性。 | +| options | 只读 | [CommonEventPublishData](#commoneventpublishdata) | 是 | 表示发布公共事件的属性。 | | callback | 只读 | AsyncCallback\ | 是 | 表示被指定的回调方法。 | **示例:** @@ -288,7 +288,7 @@ publishAsUser(event: string, userId: number, options: CommonEventPublishData, ca | -------- | -------- | ---------------------- | ---- | ---------------------- | | event | 只读 | string | 是 | 表示要发布的公共事件。 | | userId | 只读 | number | 是 | 表示指定向该用户ID发送此公共事件。 | -| options | 只读 | [CommonEventPublishData](./js-apis-commonEventPublishData.md) | 是 | 表示发布公共事件的属性。 | +| options | 只读 | [CommonEventPublishData](#commoneventpublishdata) | 是 | 表示发布公共事件的属性。 | | callback | 只读 | AsyncCallback\ | 是 | 表示被指定的回调方法。 | **示例:** @@ -331,8 +331,8 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallbac | 名称 | 读写属性 | 类型 | 必填 | 描述 | | ------------- | -------- | ------------------------------------------------------------ | ---- | -------------------------- | -| subscribeInfo | 只读 | [CommonEventSubscribeInfo](./js-apis-commonEventSubscribeInfo.md) | 是 | 表示订阅信息。 | -| callback | 只读 | AsyncCallback\<[CommonEventSubscriber](./js-apis-commonEventSubscriber.md)> | 是 | 表示创建订阅者的回调方法。 | +| subscribeInfo | 只读 | [CommonEventSubscribeInfo](#commoneventsubscribeinfo) | 是 | 表示订阅信息。 | +| callback | 只读 | AsyncCallback\<[CommonEventSubscriber](#commoneventsubscriber)> | 是 | 表示创建订阅者的回调方法。 | **示例:** @@ -373,12 +373,12 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\ | 返回订阅者对象。 | +| Promise\<[CommonEventSubscriber](#commoneventsubscriber)> | 返回订阅者对象。 | **示例:** @@ -413,8 +413,8 @@ subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\ | 是 | 表示接收公共事件数据的回调函数。 | +| subscriber | 只读 | [CommonEventSubscriber](#commoneventsubscriber) | 是 | 表示订阅者对象。 | +| callback | 只读 | AsyncCallback\<[CommonEventData](#commoneventdata)> | 是 | 表示接收公共事件数据的回调函数。 | **示例:** @@ -451,7 +451,7 @@ function CreateSubscriberCallBack(err, commonEventSubscriber) { CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); ``` - + ## CommonEvent.unsubscribe @@ -463,10 +463,10 @@ unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\): **参数:** -| 名称 | 读写属性 | 类型 | 必填 | 描述 | -| ---------- | -------- | --------------------- | ---- | ------------------------ | -| subscriber | 只读 | CommonEventSubscriber | 是 | 表示订阅者对象。 | -| callback | 只读 | AsyncCallback\ | 否 | 表示取消订阅的回调方法。 | +| 名称 | 读写属性 | 类型 | 必填 | 描述 | +| ---------- | -------- | ----------------------------------------------- | ---- | ------------------------ | +| subscriber | 只读 | [CommonEventSubscriber](#commoneventsubscriber) | 是 | 表示订阅者对象。 | +| callback | 只读 | AsyncCallback\ | 否 | 表示取消订阅的回调方法。 | **示例:** @@ -514,3 +514,742 @@ CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); //取消订阅公共事件 CommonEvent.unsubscribe(subscriber, UnsubscribeCallBack); ``` + +## CommonEventSubscriber + +### getCode + +getCode(callback: AsyncCallback\): void + +获取公共事件的结果代码(callback形式)。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| -------- | ---------------------- | ---- | ------------------ | +| callback | AsyncCallback\ | 是 | 公共事件的结果代码。 | + +**示例:** + +```js +var subscriber; //创建成功的订阅者对象 + +//设置有序公共事件的结果数据回调 +function getCodeCallback(err, Code) { + if (err.code) { + console.error("getCode failed " + JSON.stringify(err)); + } else { + console.info("getCode " + JSON.stringify(Code)); + } +} +subscriber.getCode(getCodeCallback); +``` + +### getCode + +getCode(): Promise\ + +获取公共事件的结果代码(Promise形式)。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**返回值:** + +| 类型 | 说明 | +| ---------------- | -------------------- | +| Promise\ | 公共事件的结果代码。 | + +**示例:** + +```js +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 + +设置公共事件的结果代码(callback形式)。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| -------- | -------------------- | ---- | ---------------------- | +| code | number | 是 | 公共事件的结果代码。 | +| callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | + +**示例:** + +```js +var subscriber; //创建成功的订阅者对象 + +//设置有序公共事件的结果数据回调 +function setCodeCallback(err) { + if (err.code) { + console.error("setCode failed " + JSON.stringify(err)); + } else { + console.info("setCode"); + } +} +subscriber.setCode(1, setCodeCallback); +``` + +### setCode + +setCode(code: number): Promise\ + +设置公共事件的结果代码(Promise形式)。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| ------ | ------ | ---- | ------------------ | +| code | number | 是 | 公共事件的结果代码。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------- | -------------------- | +| Promise\ | 返回一个Promise的结果。 | + +**示例:** + +```js +var subscriber; //创建成功的订阅者对象 + +subscriber.setCode(1).then(() => { + console.info("setCode"); +}).catch((err) => { + console.error("setCode failed " + JSON.stringify(err)); +}); +``` + +### getData + +getData(callback: AsyncCallback\): void + +获取公共事件的结果数据(callback形式)。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| -------- | ---------------------- | ---- | -------------------- | +| callback | AsyncCallback\ | 是 | 公共事件的结果数据。 | + +**示例:** + +```js +var subscriber; //创建成功的订阅者对象 + +//设置有序公共事件的结果数据回调 +function getDataCallback(err, Data) { + if (err.code) { + console.error("getData failed " + JSON.stringify(err)); + } else { + console.info("getData " + JSON.stringify(Data)); + } +} +subscriber.getData(getDataCallback); +``` + +### getData + +getData(): Promise\ + +获取公共事件的结果数据(Promise形式)。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**返回值:** + +| 类型 | 说明 | +| ---------------- | ------------------ | +| Promise\ | 公共事件的结果数据。 | + +**示例:** + +```js +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 + +设置公共事件的结果数据(callback形式)。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| -------- | -------------------- | ---- | -------------------- | +| data | string | 是 | 公共事件的结果数据。 | +| callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | + +**示例:** + +```js +var subscriber; //创建成功的订阅者对象 + +//设置有序公共事件的结果数据回调 +function setDataCallback(err) { + if (err.code) { + console.error("setData failed " + JSON.stringify(err)); + } else { + console.info("setData"); + } +} +subscriber.setData("publish_data_changed", setDataCallback); +``` + +### setData + +setData(data: string): Promise\ + +设置公共事件的结果数据(Promise形式)。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| ------ | ------ | ---- | -------------------- | +| data | string | 是 | 公共事件的结果数据。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------- | -------------------- | +| Promise\ | 返回一个Promise的结果。 | + +**示例:** + +```js +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 + +设置公共事件的结果代码和结果数据(callback形式)。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| -------- | -------------------- | ---- | ---------------------- | +| code | number | 是 | 公共事件的结果代码。 | +| data | string | 是 | 公共事件的结果数据。 | +| callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | + +**示例:** + +```js +var subscriber; //创建成功的订阅者对象 + +//设置有序公共事件的结果数据回调 +function setCodeDataCallback(err) { + if (err.code) { + 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\ + +设置公共事件的结果代码和结果数据(Promise形式)。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| ------ | ------ | ---- | -------------------- | +| code | number | 是 | 公共事件的结果代码。 | +| data | string | 是 | 公共事件的结果数据。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------- | -------------------- | +| Promise\ | 返回一个Promise的结果。 | + +**示例:** + +```js +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\): void + +查询当前公共事件的是否为有序公共事件(callback形式)。 + +返回true代表是有序公共事件,false代表不是有序公共事件。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| -------- | ----------------------- | ---- | ---------------------------------- | +| callback | AsyncCallback\ | 是 | 当前公共事件的是否为有序公共事件。 | + +**示例:** + +```js +var subscriber; //创建成功的订阅者对象 + +//设置有序公共事件的结果数据回调 +function isOrderedCallback(err, isOrdered) { + if (err.code) { + console.error("isOrderedCommonEvent failed " + JSON.stringify(err)); + } else { + console.info("isOrdered " + JSON.stringify(isOrdered)); + } +} +subscriber.isOrderedCommonEvent(isOrderedCallback); +``` + +### isOrderedCommonEvent + +isOrderedCommonEvent(): Promise\ + +查询当前公共事件的是否为有序公共事件(Promise形式)。 + +返回true代表是有序公共事件,false代表不是有序公共事件。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**返回值:** + +| 类型 | 说明 | +| ----------------- | -------------------------------- | +| Promise\ | 当前公共事件的是否为有序公共事件。 | + +**示例:** + +```js +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\): void + +检查当前公共事件是否为一个粘性事件(callback形式)。 + +返回true代表是粘性公共事件,false代表不是粘性公共事件。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| -------- | ----------------------- | ---- | ---------------------------------- | +| callback | AsyncCallback\ | 是 | 当前公共事件的是否为粘性公共事件。 | + +**示例:** + +```js +var subscriber; //创建成功的订阅者对象 + +//设置有序公共事件的结果数据回调 +function isStickyCallback(err, isSticky) { + if (err.code) { + console.error("isStickyCommonEvent failed " + JSON.stringify(err)); + } else { + console.info("isSticky " + JSON.stringify(isSticky)); + } +} +subscriber.isStickyCommonEvent(isStickyCallback); +``` + +### isStickyCommonEvent + +isStickyCommonEvent(): Promise\ + +检查当前公共事件是否为一个粘性事件(callback形式)。 + +返回true代表是粘性公共事件,false代表不是粘性公共事件。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**返回值:** + +| 类型 | 说明 | +| ----------------- | -------------------------------- | +| Promise\ | 当前公共事件的是否为粘性公共事件。 | + +**示例:** + +```js +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 + +取消当前的公共事件,仅对有序公共事件有效,取消后,公共事件不再向下一个订阅者传递(callback形式)。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| -------- | -------------------- | ---- | -------------------- | +| callback | AsyncCallback\ | 是 | 取消当前的公共事件。 | + +**示例:** + +```js +var subscriber; //创建成功的订阅者对象 + +//设置有序公共事件的结果数据回调 +function abortCallback(err) { + if (err.code) { + console.error("abortCommonEvent failed " + JSON.stringify(err)); + } else { + console.info("abortCommonEvent"); + } +} +subscriber.abortCommonEvent(abortCallback); +``` + +### abortCommonEvent + +abortCommonEvent(): Promise\ + +取消当前的公共事件,仅对有序公共事件有效,取消后,公共事件不再向下一个订阅者传递(Promise形式)。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**返回值:** + +| 类型 | 说明 | +| ---------------- | -------------------- | +| Promise\ | 返回一个Promise的结果。 | + +**示例:** + +```js +var subscriber; //创建成功的订阅者对象 + +subscriber.abortCommonEvent().then(() => { + console.info("abortCommonEvent"); +}).catch((err) => { + console.error("abortCommonEvent failed " + JSON.stringify(err)); +}); +``` + +### clearAbortCommonEvent + +clearAbortCommonEvent(callback: AsyncCallback\): void + +清除当前公共事件的取消状态,仅对有序公共事件有效(callback形式)。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| -------- | -------------------- | ---- | -------------------- | +| callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | + +**示例:** + +```js +var subscriber; //创建成功的订阅者对象 + +//设置有序公共事件的结果数据回调 +function clearAbortCallback(err) { + if (err.code) { + console.error("clearAbortCommonEvent failed " + JSON.stringify(err)); + } else { + console.info("clearAbortCommonEvent"); + } +} +subscriber.clearAbortCommonEvent(clearAbortCallback); +``` + +### clearAbortCommonEvent + +clearAbortCommonEvent(): Promise\ + +清除当前公共事件的取消状态,仅对有序公共事件有效(Promise形式)。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**返回值:** + +| 类型 | 说明 | +| ---------------- | -------------------- | +| Promise\ | 返回一个Promise的结果。 | + +**示例:** + +```js +var subscriber; //创建成功的订阅者对象 + +subscriber.clearAbortCommonEvent().then(() => { + console.info("clearAbortCommonEvent"); +}).catch((err) => { + console.error("clearAbortCommonEvent failed " + JSON.stringify(err)); +}); +``` + +### getAbortCommonEvent + +getAbortCommonEvent(callback: AsyncCallback\): void + +获取当前有序公共事件是否取消的状态(callback形式)。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| -------- | ----------------------- | ---- | ---------------------------------- | +| callback | AsyncCallback\ | 是 | 表示当前有序公共事件是否取消的状态。 | + +**示例:** + +```js +var subscriber; //创建成功的订阅者对象 + +//设置有序公共事件的结果数据回调 +function getAbortCallback(err, AbortCommonEvent) { + if (err.code) { + console.error("getAbortCommonEvent failed " + JSON.stringify(err)); + } else { + console.info("AbortCommonEvent " + AbortCommonEvent) + } +} +subscriber.getAbortCommonEvent(getAbortCallback); +``` + +### getAbortCommonEvent + +getAbortCommonEvent(): Promise\ + +获取当前有序公共事件是否取消的状态(Promise形式)。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**返回值:** + +| 类型 | 说明 | +| ----------------- | ---------------------------------- | +| Promise\ | 表示当前有序公共事件是否取消的状态。 | + +**示例:** + +```js +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\): void + +获取订阅者的订阅信息(callback形式)。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| -------- | ------------------------------------------------------------ | ---- | ---------------------- | +| callback | AsyncCallback\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | 是 | 表示订阅者的订阅信息。 | + +**示例:** + +```js +var subscriber; //创建成功的订阅者对象 + +//设置有序公共事件的结果数据回调 +function getSubscribeInfoCallback(err, SubscribeInfo) { + if (err.code) { + console.error("getSubscribeInfo failed " + JSON.stringify(err)); + } else { + console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo)); + } +} +subscriber.getSubscribeInfo(getSubscribeInfoCallback); +``` + +### getSubscribeInfo + +getSubscribeInfo(): Promise\ + +获取订阅者的订阅信息(Promise形式)。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------------ | ---------------------- | +| Promise\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | 表示订阅者的订阅信息。 | + +**示例:** + +```js +var subscriber; //创建成功的订阅者对象 + +subscriber.getSubscribeInfo().then((SubscribeInfo) => { + console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo)); +}).catch((err) => { + console.error("getSubscribeInfo failed " + JSON.stringify(err)); +}); +``` + +### finishCommonEvent + +finishCommonEvent(callback: AsyncCallback\): void + +结束当前已排序的公共事件(callback形式)。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| -------- | -------------------- | ---- | -------------------------------- | +| callback | AsyncCallback\ | 是 | 表示排序的公共事件结束后的回调函数。 | + +**示例:** + +```js +var subscriber; //创建成功的订阅者对象 + +function finishCommonEventCallback() { + console.log("--------- finishCommonEventCallback ----------"); +} + +subscriber.finishCommonEvent(finishCommonEventCallback); +``` + +### finishCommonEvent + +finishCommonEvent(): Promise\ + +结束当前已排序的公共事件(Promise形式)。 + +**系统能力**:SystemCapability.Notification.CommonEvent + +**返回值:** + +| 类型 | 说明 | +| ---------------- | -------------------- | +| Promise\ | 返回一个Promise的结果。 | + +**示例:** + +```js +var subscriber; //创建成功的订阅者对象 + +subscriber.finishCommonEvent() + .then(() => { + console.info("--------- finishCommonEventCallback ----------"); + }) +``` + +## CommonEventData + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Notification.CommonEvent + +| 名称 | 读写属性 | 类型 | 必填 | 描述 | +| ---------- | -------- | -------------------- | ---- | ------------------------------------------------------- | +| event | 只读 | string | 是 | 表示当前接收的公共事件名称。 | +| bundleName | 只读 | string | 否 | 表示包名称。 | +| code | 只读 | number | 否 | 表示公共事件的结果代码,用于传递int类型的数据。 | +| data | 只读 | string | 否 | 表示公共事件的自定义结果数据,用于传递string类型的数据。 | +| parameters | 只读 | {[key: string]: any} | 否 | 表示公共事件的附加信息。 | + + +## CommonEventPublishData + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Notification.CommonEvent + +| 名称 | 读写属性 | 类型 | 必填 | 描述 | +| --------------------- | -------- | -------------------- | ---- | ---------------------------- | +| bundleName | 只读 | string | 否 | 表示包名称。 | +| code | 只读 | number | 否 | 表示公共事件的结果代码。 | +| data | 只读 | string | 否 | 表示公共事件的自定义结果数据。 | +| subscriberPermissions | 只读 | Array\ | 否 | 表示订阅者的权限。 | +| isOrdered | 只读 | boolean | 否 | 表示是否是有序事件。 | +| isSticky | 只读 | boolean | 否 | 表示是否是粘性事件。 | +| parameters | 只读 | {[key: string]: any} | 否 | 表示公共事件的附加信息。 | + +## CommonEventSubscribeInfo + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Notification.CommonEvent + +| 名称 | 读写属性 | 类型 | 必填 | 描述 | +| ------------------- | -------- | -------------- | ---- | ------------------------------------------------------------ | +| events | 只读 | Array\ | 是 | 表示要发送的公共事件。 | +| publisherPermission | 只读 | string | 否 | 表示发布者的权限。 | +| publisherDeviceId | 只读 | string | 否 | 表示设备ID,该值必须是同一ohos网络上的现有设备ID。 | +| userId | 只读 | number | 否 | 表示用户ID。此参数是可选的,默认值当前用户的ID。如果指定了此参数,则该值必须是系统中现有的用户ID。 | +| priority | 只读 | number | 否 | 表示订阅者的优先级。值的范围是-100到1000。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-commonEventData.md b/zh-cn/application-dev/reference/apis/js-apis-commonEventData.md deleted file mode 100644 index bbead21038153a0d76f90f9d4ddfe8cb7a2a1b9c..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-commonEventData.md +++ /dev/null @@ -1,16 +0,0 @@ -# 公共事件数据 - -> **说明:** -> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - -## CommonEventData - -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Notification.CommonEvent - -| 名称 | 读写属性 | 类型 | 必填 | 描述 | -| ---------- | -------- | -------------------- | ---- | ------------------------------------------------------- | -| event | 只读 | string | 是 | 表示当前接收的公共事件名称。 | -| bundleName | 只读 | string | 否 | 表示包名称。 | -| code | 只读 | number | 否 | 表示公共事件的结果代码,用于传递int类型的数据。 | -| data | 只读 | string | 否 | 表示公共事件的自定义结果数据,用于传递string类型的数据。 | -| parameters | 只读 | {[key: string]: any} | 否 | 表示公共事件的附加信息。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-commonEventPublishData.md b/zh-cn/application-dev/reference/apis/js-apis-commonEventPublishData.md deleted file mode 100644 index ee39ba0876019444183614f241490531217f6f6b..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-commonEventPublishData.md +++ /dev/null @@ -1,19 +0,0 @@ -# 公共事件内容和属性 - -> **说明:** -> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - -## CommonEventPublishData - -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Notification.CommonEvent - -| 名称 | 读写属性 | 类型 | 必填 | 描述 | -| --------------------- | -------- | -------------------- | ---- | ---------------------------- | -| bundleName | 只读 | string | 否 | 表示包名称。 | -| code | 只读 | number | 否 | 表示公共事件的结果代码。 | -| data | 只读 | string | 否 | 表示公共事件的自定义结果数据。 | -| subscriberPermissions | 只读 | Array\ | 否 | 表示订阅者的权限。 | -| isOrdered | 只读 | boolean | 否 | 表示是否是有序事件。 | -| isSticky | 只读 | boolean | 否 | 表示是否是粘性事件。 | -| parameters | 只读 | {[key: string]: any} | 否 | 表示公共事件的附加信息。 | - diff --git a/zh-cn/application-dev/reference/apis/js-apis-commonEventSubscribeInfo.md b/zh-cn/application-dev/reference/apis/js-apis-commonEventSubscribeInfo.md deleted file mode 100644 index 45fa02c374125ae5ab7b2b8ebff9f9c5cdbb2d09..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-commonEventSubscribeInfo.md +++ /dev/null @@ -1,16 +0,0 @@ -# 订阅者的信息 - -> **说明:** -> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - -## CommonEventSubscribeInfo - -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Notification.CommonEvent - -| 名称 | 读写属性 | 类型 | 必填 | 描述 | -| ------------------- | -------- | -------------- | ---- | ------------------------------------------------------------ | -| events | 只读 | Array\ | 是 | 表示要发送的公共事件。 | -| publisherPermission | 只读 | string | 否 | 表示发布者的权限。 | -| publisherDeviceId | 只读 | string | 否 | 表示设备ID,该值必须是同一ohos网络上的现有设备ID。 | -| userId | 只读 | number | 否 | 表示用户ID。此参数是可选的,默认值当前用户的ID。如果指定了此参数,则该值必须是系统中现有的用户ID。 | -| priority | 只读 | number | 否 | 表示订阅者的优先级。值的范围是-100到1000。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-commonEventSubscriber.md b/zh-cn/application-dev/reference/apis/js-apis-commonEventSubscriber.md deleted file mode 100644 index bd9fa5fa8d68e66047faade516617e3ac0668bfa..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-commonEventSubscriber.md +++ /dev/null @@ -1,668 +0,0 @@ -# 公共事件的订阅者 - -> **说明:** -> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - -## CommonEventSubscriber - -### getCode - -getCode(callback: AsyncCallback\): void - -获取公共事件的结果代码(callback形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**参数:** - -| 参数名 | 类型 | 必填 | 描述 | -| -------- | ---------------------- | ---- | ------------------ | -| callback | AsyncCallback\ | 是 | 公共事件的结果代码。 | - -**示例:** - -```js -var subscriber; //创建成功的订阅者对象 - -//设置有序公共事件的结果数据回调 -function getCodeCallback(err, Code) { - if (err.code) { - console.error("getCode failed " + JSON.stringify(err)); - } else { - console.info("getCode " + JSON.stringify(Code)); - } -} -subscriber.getCode(getCodeCallback); -``` - -### getCode - -getCode(): Promise\ - -获取公共事件的结果代码(Promise形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**返回值:** - -| 类型 | 说明 | -| ---------------- | -------------------- | -| Promise\ | 公共事件的结果代码。 | - -**示例:** - -```js -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 - -设置公共事件的结果代码(callback形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**参数:** - -| 参数名 | 类型 | 必填 | 描述 | -| -------- | -------------------- | ---- | ---------------------- | -| code | number | 是 | 公共事件的结果代码。 | -| callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | - -**示例:** - -```js -var subscriber; //创建成功的订阅者对象 - -//设置有序公共事件的结果数据回调 -function setCodeCallback(err) { - if (err.code) { - console.error("setCode failed " + JSON.stringify(err)); - } else { - console.info("setCode"); - } -} -subscriber.setCode(1, setCodeCallback); -``` - -### setCode - -setCode(code: number): Promise\ - -设置公共事件的结果代码(Promise形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**参数:** - -| 参数名 | 类型 | 必填 | 描述 | -| ------ | ------ | ---- | ------------------ | -| code | number | 是 | 公共事件的结果代码。 | - -**示例:** - -```js -var subscriber; //创建成功的订阅者对象 - -subscriber.setCode(1).then(() => { - console.info("setCode"); -}).catch((err) => { - console.error("setCode failed " + JSON.stringify(err)); -}); -``` - -### getData - -getData(callback: AsyncCallback\): void - -获取公共事件的结果数据(callback形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**参数:** - -| 参数名 | 类型 | 必填 | 描述 | -| -------- | ---------------------- | ---- | -------------------- | -| callback | AsyncCallback\ | 是 | 公共事件的结果数据。 | - -**示例:** - -```js -var subscriber; //创建成功的订阅者对象 - -//设置有序公共事件的结果数据回调 -function getDataCallback(err, Data) { - if (err.code) { - console.error("getData failed " + JSON.stringify(err)); - } else { - console.info("getData " + JSON.stringify(Data)); - } -} -subscriber.getData(getDataCallback); -``` - -### getData - -getData(): Promise\ - -获取公共事件的结果数据(Promise形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**返回值:** - -| 类型 | 说明 | -| ---------------- | ------------------ | -| Promise\ | 公共事件的结果数据。 | - -**示例:** - -```js -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 - -设置公共事件的结果数据(callback形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**参数:** - -| 参数名 | 类型 | 必填 | 描述 | -| -------- | -------------------- | ---- | -------------------- | -| data | string | 是 | 公共事件的结果数据。 | -| callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | - -**示例:** - -```js -var subscriber; //创建成功的订阅者对象 - -//设置有序公共事件的结果数据回调 -function setDataCallback(err) { - if (err.code) { - console.error("setData failed " + JSON.stringify(err)); - } else { - console.info("setData"); - } -} -subscriber.setData("publish_data_changed", setDataCallback); -``` - -### setData - -setData(data: string): Promise\ - -设置公共事件的结果数据(Promise形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**参数:** - -| 参数名 | 类型 | 必填 | 描述 | -| ------ | ------ | ---- | -------------------- | -| data | string | 是 | 公共事件的结果数据。 | - -**示例:** - -```js -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 - -设置公共事件的结果代码和结果数据(callback形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**参数:** - -| 参数名 | 类型 | 必填 | 描述 | -| -------- | -------------------- | ---- | ---------------------- | -| code | number | 是 | 公共事件的结果代码。 | -| data | string | 是 | 公共事件的结果数据。 | -| callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | - -**示例:** - -```js -var subscriber; //创建成功的订阅者对象 - -//设置有序公共事件的结果数据回调 -function setCodeDataCallback(err) { - if (err.code) { - 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\ - -设置公共事件的结果代码和结果数据(Promise形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**参数:** - -| 参数名 | 类型 | 必填 | 描述 | -| ------ | ------ | ---- | -------------------- | -| code | number | 是 | 公共事件的结果代码。 | -| data | string | 是 | 公共事件的结果数据。 | - -**示例:** - -```js -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\): void - -查询当前公共事件的是否为有序公共事件(callback形式)。 - -返回true代表是有序公共事件,false代表不是有序公共事件。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**参数:** - -| 参数名 | 类型 | 必填 | 描述 | -| -------- | ----------------------- | ---- | ---------------------------------- | -| callback | AsyncCallback\ | 是 | 当前公共事件的是否为有序公共事件。 | - -**示例:** - -```js -var subscriber; //创建成功的订阅者对象 - -//设置有序公共事件的结果数据回调 -function isOrderedCallback(err, isOrdered) { - if (err.code) { - console.error("isOrderedCommonEvent failed " + JSON.stringify(err)); - } else { - console.info("isOrdered " + JSON.stringify(isOrdered)); - } -} -subscriber.isOrderedCommonEvent(isOrderedCallback); -``` - -### isOrderedCommonEvent - -isOrderedCommonEvent(): Promise\ - -查询当前公共事件的是否为有序公共事件(Promise形式)。 - -返回true代表是有序公共事件,false代表不是有序公共事件。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**返回值:** - -| 类型 | 说明 | -| ----------------- | -------------------------------- | -| Promise\ | 当前公共事件的是否为有序公共事件。 | - -**示例:** - -```js -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\): void - -检查当前公共事件是否为一个粘性事件(callback形式)。 - -返回true代表是粘性公共事件,false代表不是粘性公共事件。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**参数:** - -| 参数名 | 类型 | 必填 | 描述 | -| -------- | ----------------------- | ---- | ---------------------------------- | -| callback | AsyncCallback\ | 是 | 当前公共事件的是否为粘性公共事件。 | - -**示例:** - -```js -var subscriber; //创建成功的订阅者对象 - -//设置有序公共事件的结果数据回调 -function isStickyCallback(err, isSticky) { - if (err.code) { - console.error("isStickyCommonEvent failed " + JSON.stringify(err)); - } else { - console.info("isSticky " + JSON.stringify(isSticky)); - } -} -subscriber.isStickyCommonEvent(isStickyCallback); -``` - -### isStickyCommonEvent - -isStickyCommonEvent(): Promise\ - -检查当前公共事件是否为一个粘性事件(callback形式)。 - -返回true代表是粘性公共事件,false代表不是粘性公共事件。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**返回值:** - -| 类型 | 说明 | -| ----------------- | -------------------------------- | -| Promise\ | 当前公共事件的是否为粘性公共事件。 | - -**示例:** - -```js -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 - -取消当前的公共事件,仅对有序公共事件有效,取消后,公共事件不再向下一个订阅者传递(callback形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**参数:** - -| 参数名 | 类型 | 必填 | 描述 | -| -------- | -------------------- | ---- | -------------------- | -| callback | AsyncCallback\ | 是 | 取消当前的公共事件。 | - -**示例:** - -```js -var subscriber; //创建成功的订阅者对象 - -//设置有序公共事件的结果数据回调 -function abortCallback(err) { - if (err.code) { - console.error("abortCommonEvent failed " + JSON.stringify(err)); - } else { - console.info("abortCommonEvent"); - } -} -subscriber.abortCommonEvent(abortCallback); -``` - -### abortCommonEvent - -abortCommonEvent(): Promise\ - -取消当前的公共事件,仅对有序公共事件有效,取消后,公共事件不再向下一个订阅者传递(Promise形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**示例:** - -```js -var subscriber; //创建成功的订阅者对象 - -subscriber.abortCommonEvent().then(() => { - console.info("abortCommonEvent"); -}).catch((err) => { - console.error("abortCommonEvent failed " + JSON.stringify(err)); -}); -``` - -### clearAbortCommonEvent - -clearAbortCommonEvent(callback: AsyncCallback\): void - -清除当前公共事件的取消状态,仅对有序公共事件有效(callback形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**参数:** - -| 参数名 | 类型 | 必填 | 描述 | -| -------- | -------------------- | ---- | -------------------- | -| callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | - -**示例:** - -```js -var subscriber; //创建成功的订阅者对象 - -//设置有序公共事件的结果数据回调 -function clearAbortCallback(err) { - if (err.code) { - console.error("clearAbortCommonEvent failed " + JSON.stringify(err)); - } else { - console.info("clearAbortCommonEvent"); - } -} -subscriber.clearAbortCommonEvent(clearAbortCallback); -``` - -### clearAbortCommonEvent - -clearAbortCommonEvent(): Promise\ - -清除当前公共事件的取消状态,仅对有序公共事件有效(Promise形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**示例:** - -```js -var subscriber; //创建成功的订阅者对象 - -subscriber.clearAbortCommonEvent().then(() => { - console.info("clearAbortCommonEvent"); -}).catch((err) => { - console.error("clearAbortCommonEvent failed " + JSON.stringify(err)); -}); -``` - -### getAbortCommonEvent - -getAbortCommonEvent(callback: AsyncCallback\): void - -获取当前有序公共事件是否取消的状态(callback形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**参数:** - -| 参数名 | 类型 | 必填 | 描述 | -| -------- | ----------------------- | ---- | ---------------------------------- | -| callback | AsyncCallback\ | 是 | 表示当前有序公共事件是否取消的状态。 | - -**示例:** - -```js -var subscriber; //创建成功的订阅者对象 - -//设置有序公共事件的结果数据回调 -function getAbortCallback(err, AbortCommonEvent) { - if (err.code) { - console.error("getAbortCommonEvent failed " + JSON.stringify(err)); - } else { - console.info("AbortCommonEvent " + AbortCommonEvent) - } -} -subscriber.getAbortCommonEvent(getAbortCallback); -``` - -### getAbortCommonEvent - -getAbortCommonEvent(): Promise\ - -获取当前有序公共事件是否取消的状态(Promise形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**返回值:** - -| 类型 | 说明 | -| ----------------- | ---------------------------------- | -| Promise\ | 表示当前有序公共事件是否取消的状态。 | - -**示例:** - -```js -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\): void - -获取订阅者的订阅信息(callback形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**参数:** - -| 参数名 | 类型 | 必填 | 描述 | -| -------- | ------------------------------------------------------------ | ---- | ---------------------- | -| callback | AsyncCallback\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | 是 | 表示订阅者的订阅信息。 | - -**示例:** - -```js -var subscriber; //创建成功的订阅者对象 - -//设置有序公共事件的结果数据回调 -function getSubscribeInfoCallback(err, SubscribeInfo) { - if (err.code) { - console.error("getSubscribeInfo failed " + JSON.stringify(err)); - } else { - console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo)); - } -} -subscriber.getSubscribeInfo(getSubscribeInfoCallback); -``` - -### getSubscribeInfo - -getSubscribeInfo(): Promise\ - -获取订阅者的订阅信息(Promise形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**返回值:** - -| 类型 | 说明 | -| ------------------------------------------------------------ | ---------------------- | -| Promise\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | 表示订阅者的订阅信息。 | - -**示例:** - -```js -var subscriber; //创建成功的订阅者对象 - -subscriber.getSubscribeInfo().then((SubscribeInfo) => { - console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo)); -}).catch((err) => { - console.error("getSubscribeInfo failed " + JSON.stringify(err)); -}); -``` - -### finishCommonEvent - -finishCommonEvent(callback: AsyncCallback\): void - -结束当前已排序的公共事件(callback形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**参数:** - -| 参数名 | 类型 | 必填 | 描述 | -| -------- | -------------------- | ---- | -------------------------------- | -| callback | AsyncCallback\ | 是 | 表示排序的公共事件结束后的回调函数。 | - -**示例:** - -```js -var subscriber; //创建成功的订阅者对象 - -function finishCommonEventCallback() { - console.log("--------- finishCommonEventCallback ----------"); -} - -subscriber.finishCommonEvent(finishCommonEventCallback); -``` - -### finishCommonEvent - -finishCommonEvent(): Promise\ - -结束当前已排序的公共事件(Promise形式)。 - -**系统能力**:SystemCapability.Notification.CommonEvent - -**示例:** - -```js -var subscriber; //创建成功的订阅者对象 - -subscriber.finishCommonEvent() - .then(() => { - console.info("--------- finishCommonEventCallback ----------"); - }) -``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-notification.md b/zh-cn/application-dev/reference/apis/js-apis-notification.md index 0698d98326dca5ecf0eaf129c1cfeb0397da85e3..b4cae9b30cec783dd4ae362f52311c30ed48c29a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-notification.md +++ b/zh-cn/application-dev/reference/apis/js-apis-notification.md @@ -1,8 +1,7 @@ # Notification模块 ->**说明:** -> ->本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## 导入模块 @@ -292,7 +291,7 @@ addSlot(slot: NotificationSlot, callback: AsyncCallback\): void | 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | | -------- | ---- | --- | --------------------- | ---- | -------------------- | -| slot | 是 | 否 | NotificationSlot | 是 | 要创建的通知通道对象。 | +| slot | 是 | 否 | [NotificationSlot](#notificationslot) | 是 | 要创建的通知通道对象。 | | callback | 是 | 否 | AsyncCallback\ | 是 | 表示被指定的回调方法。 | **示例:** @@ -323,7 +322,7 @@ addSlot(slot: NotificationSlot): Promise\ | 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | | ---- | ---- | --- | ---------------- | ---- | -------------------- | -| slot | 是 | 否 | NotificationSlot | 是 | 要创建的通知通道对象。 | +| slot | 是 | 否 | [NotificationSlot](#notificationslot) | 是 | 要创建的通知通道对象。 | **示例:** @@ -402,7 +401,7 @@ addSlots(slots: Array\, callback: AsyncCallback\): voi | 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | | -------- | ---- | --- | ------------------------- | ---- | ------------------------ | -| slots | 是 | 否 | Array\ | 是 | 要创建的通知通道对象数组。 | +| slots | 是 | 否 | Array\<[NotificationSlot](#notificationslot)\> | 是 | 要创建的通知通道对象数组。 | | callback | 是 | 否 | AsyncCallback\ | 是 | 表示被指定的回调方法。 | **示例:** @@ -437,7 +436,7 @@ addSlots(slots: Array\): Promise\ | 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | | ----- | ---- | --- | ------------------------- | ---- | ------------------------ | -| slots | 是 | 否 | Array\ | 是 | 要创建的通知通道对象数组。 | +| slots | 是 | 否 | Array\<[NotificationSlot](#notificationslot)\> | 是 | 要创建的通知通道对象数组。 | **示例:** @@ -470,7 +469,7 @@ getSlot(slotType: SlotType, callback: AsyncCallback\): void | 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | | -------- | ---- | --- | --------------------------------- | ---- | ----------------------------------------------------------- | | slotType | 是 | 否 | [SlotType](#slottype) | 是 | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 | -| callback | 是 | 否 | AsyncCallback\ | 是 | 表示被指定的回调方法。 | +| callback | 是 | 否 | AsyncCallback\<[NotificationSlot](#notificationslot)\> | 是 | 表示被指定的回调方法。 | **示例:** @@ -528,7 +527,7 @@ getSlots(callback: AsyncCallback>): void | 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | | -------- | ---- | --- | --------------------------------- | ---- | -------------------- | -| callback | 是 | 否 | AsyncCallback\ | 是 | 表示被指定的回调方法。 | +| callback | 是 | 否 | AsyncCallback\<[NotificationSlot](#notificationslot)\> | 是 | 表示被指定的回调方法。 | **示例:** @@ -554,7 +553,7 @@ getSlots(): Promise\> | 类型 | 说明 | | ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\\> | 以Promise形式返回获取此应用程序的所有通知通道的结果。 | +| Promise\\> | 以Promise形式返回获取此应用程序的所有通知通道的结果。 | **示例:** @@ -1133,7 +1132,7 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCal | 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | | -------- | ---- | --- | --------------------- | ---- | -------------------- | | bundle | 是 | 否 | [BundleOption](#bundleoption) | 是 | 指定包信息。 | -| slot | 是 | 否 | NotificationSlot | 是 | 通知通道。 | +| slot | 是 | 否 | [NotificationSlot](#notificationslot) | 是 | 通知通道。 | | callback | 是 | 否 | AsyncCallback\ | 是 | 设定通知通道回调函数。 | **示例:** @@ -1166,7 +1165,7 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\ | 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | | ------ | ---- | --- | ------------ | ---- | ---------- | | bundle | 是 | 否 | [BundleOption](#bundleoption) | 是 | 指定包信息。 | -| enable | 是 | 否 | boolean | 是 | 使能状态。 | +| slot | 是 | 否 | [NotificationSlot](#notificationslot) | 是 | 使能状态。 | **示例:** @@ -1197,7 +1196,7 @@ getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback> | 是 | 获取通知通道回调函数。 | +| callback | 是 | 否 | AsyncCallback> | 是 | 获取通知通道回调函数。 | **示例:** @@ -1231,7 +1230,7 @@ getSlotsByBundle(bundle: BundleOption): Promise> | 类型 | 说明 | | ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise> | 以Promise形式返回获取指定包的通知通道。 | +| Promise> | 以Promise形式返回获取指定包的通知通道。 | **示例:** @@ -1830,7 +1829,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\): vo | 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | | -------- | ---- | --- | --------------------- | ---- | ---------------------- | -| date | 是 | 否 | DoNotDisturbDate | 是 | 免打扰时间选项。 | +| date | 是 | 否 | [DoNotDisturbDate](#donotdisturbdate8) | 是 | 免打扰时间选项。 | | callback | 是 | 否 | AsyncCallback\ | 是 | 设置免打扰时间回调函数。 | **示例:** @@ -1863,7 +1862,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate): Promise\ | 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | | ---- | ---- | --- | ---------------- | ---- | -------------- | -| date | 是 | 否 | DoNotDisturbDate | 是 | 免打扰时间选项。 | +| date | 是 | 否 | [DoNotDisturbDate](#donotdisturbdate8) | 是 | 免打扰时间选项。 | **示例:** @@ -1891,7 +1890,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallb | 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | | -------- | ---- | --- | --------------------- | ---- | ---------------------- | -| date | 是 | 否 | DoNotDisturbDate | 是 | 免打扰时间选项。 | +| date | 是 | 否 | [DoNotDisturbDate](#donotdisturbdate8) | 是 | 免打扰时间选项。 | | userId | 是 | 否 | number | 是 | 设置免打扰事件的用户ID。 | | callback | 是 | 否 | AsyncCallback\ | 是 | 设置免打扰时间回调函数。 | @@ -1927,7 +1926,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\ | 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | | ------ | ---- | --- | ---------------- | ---- | -------------- | -| date | 是 | 否 | DoNotDisturbDate | 是 | 免打扰时间选项。 | +| date | 是 | 否 | [DoNotDisturbDate](#donotdisturbdate8) | 是 | 免打扰时间选项。 | | userId | 是 | 否 | number | 是 | 设置免打扰事件的用户ID。 | **示例:** @@ -1959,7 +1958,7 @@ getDoNotDisturbDate(callback: AsyncCallback\): void | 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | | -------- | ---- | --- | --------------------------------- | ---- | ---------------------- | -| callback | 是 | 否 | AsyncCallback\ | 是 | 查询免打扰时间回调函数。 | +| callback | 是 | 否 | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8)\> | 是 | 查询免打扰时间回调函数。 | **示例:** @@ -1985,7 +1984,7 @@ getDoNotDisturbDate(): Promise\ | 类型 | 说明 | | ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\ | 以Promise形式返回获取查询免打扰时间接口。 | +| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | 以Promise形式返回获取查询免打扰时间接口。 | **示例:** @@ -2008,7 +2007,7 @@ getDoNotDisturbDate(userId: number, callback: AsyncCallback\) | 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | | -------- | ---- | --- | --------------------------------- | ---- | ---------------------- | -| callback | 是 | 否 | AsyncCallback\ | 是 | 查询免打扰时间回调函数。 | +| callback | 是 | 否 | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8)\> | 是 | 查询免打扰时间回调函数。 | | userId | 是 | 否 | number | 是 | 设置免打扰事件的用户ID。 | **示例:** @@ -2043,7 +2042,7 @@ getDoNotDisturbDate(userId: number): Promise\ | 类型 | 说明 | | ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\ | 以Promise形式返回获取查询免打扰时间接口。 | +| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | 以Promise形式返回获取查询免打扰时间接口。 | **示例:** @@ -2327,7 +2326,7 @@ enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: Async | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------ | ---- | -------------------------- | -| bundle | BundleOption | 是 | 应用的包。 | +| bundle | [BundleOption](#bundleoption) | 是 | 应用的包。 | | enable | boolean | 是 | 是否支持。 | | callback | AsyncCallback\ | 是 | 应用程序是否支持分布式通知的回调函数。 | @@ -2361,7 +2360,7 @@ Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundle | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------ | ---- | -------------------------- | -| bundle | BundleOption | 是 | 应用的包。 | +| bundle | [BundleOption](#bundleoption) | 是 | 应用的包。 | | enable | boolean | 是 | 是否支持。 | **示例:** @@ -2391,7 +2390,7 @@ isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\ | 是 | 应用程序是否支持分布式通知的回调函数。 | **示例:** @@ -2422,7 +2421,7 @@ isDistributedEnabledByBundle(bundle: BundleOption): Promise\ | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------ | ---- | -------------------------- | -| bundle | BundleOption | 是 | 应用的包。 | +| bundle | [BundleOption](#bundleoption) | 是 | 应用的包。 | **返回值:** @@ -2456,7 +2455,7 @@ getDeviceRemindType(callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------- | ---- | -------------------------- | -| callback | AsyncCallback\ | 是 | 获取通知的提醒方式的回调函数。 | +| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtypesup8sup)\> | 是 | 获取通知的提醒方式的回调函数。 | **示例:** @@ -2482,7 +2481,7 @@ getDeviceRemindType(): Promise\ | 类型 | 说明 | | ------------------ | --------------- | -| Promise\ | Promise方式返回通知的提醒方式的结果。 | +| Promise\<[DeviceRemindType](#deviceremindtypesup8sup)\> | Promise方式返回通知的提醒方式的结果。 | **示例:** @@ -2493,6 +2492,320 @@ Notification.getDeviceRemindType() }); ``` +## NotificationSubscriber + +### onConsume + +onConsume?:(data: [SubscribeCallbackData](#subscribecallbackdata)) + +接收通知回调函数。 + +**系统能力**:SystemCapability.Notification.Notification + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | ------------------------ | ---- | -------------------------- | +| data | AsyncCallback\<[SubscribeCallbackData](#subscribecallbackdata)\> | 是 | 回调返回接收到的通知信息。 | + +**示例:** + +```javascript +function subscribeCallback(err) { + if (err.code) { + console.info("subscribe failed " + JSON.stringify(err)); + } 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 wantAgent = data.wantAgent; + wantAgent .getWant(wantAgent) + .then((data1) => { + console.log('===> getWant success want:' + JSON.stringfy(data1)); + }) + .catch((err) => { + console.error('===> getWant failed because' + JSON.stringfy(err)); + }); + console.info('===> onConsume callback req.wantAgent:' + JSON.stringfy(req.wantAgent)); +}; + +var subscriber = { + onConsume: onConsumeCallback +}; + +Notification.subscribe(subscriber, subscribeCallback); +``` + +### onCancel + +onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) + +删除通知回调函数。 + +**系统能力**:SystemCapability.Notification.Notification + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | ------------------------ | ---- | -------------------------- | +| data | AsyncCallback\<[SubscribeCallbackData](#subscribecallbackdata)\> | 是 | 回调返回接收到的通知信息。 | + +**示例:** + +```javascript +function subscribeCallback(err) { + if (err.code) { + console.info("subscribe failed " + JSON.stringify(err)); + } else { + console.info("subscribeCallback"); + } +}; + +function onCancelCallback(data) { + console.info('===> onCancel in test'); + let req = data.request; + console.info('===> onCancel callback req.id:' + req.id); +} + +var subscriber = { + onCancel: onCancelCallback +}; + +Notification.subscribe(subscriber, subscribeCallback); +``` + +### onUpdate + +onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) + +更新通知排序回调函数。 + +**系统能力**:SystemCapability.Notification.Notification + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | ------------------------ | ---- | -------------------------- | +| data | [NotificationSortingMap](#notificationsortingmap) | 是 | 回调返回接收到的通知信息。 | + +**示例:** + +```javascript +function subscribeCallback(err) { + if (err.code) { + console.info("subscribe failed " + JSON.stringify(err)); + } else { + console.info("subscribeCallback"); + } +}; + +function onUpdateCallback() { + console.info('===> onUpdate in test'); +} + +var subscriber = { + onUpdate: onUpdateCallback +}; + +Notification.subscribe(subscriber, subscribeCallback); +``` + +### onConnect + +onConnect?:void + +注册订阅回调函数。 + +**系统能力**:SystemCapability.Notification.Notification + +**示例:** + +```javascript +function subscribeCallback(err) { + if (err.code) { + console.info("subscribe failed " + JSON.stringify(err)); + } else { + console.info("subscribeCallback"); + } +}; + +function onConnectCallback() { + console.info('===> onConnect in test'); +} + +var subscriber = { + onConnect: onConnectCallback +}; + +Notification.subscribe(subscriber, subscribeCallback); +``` + +### onDisconnect + +onDisconnect?:void + +取消订阅回调函数。 + +**系统能力**:SystemCapability.Notification.Notification + +**示例:** + +```javascript +function subscribeCallback(err) { + if (err.code) { + console.info("subscribe failed " + JSON.stringify(err)); + } else { + console.info("subscribeCallback"); + } +}; + +function onDisconnectCallback() { + console.info('===> onDisconnect in test'); +} + +var subscriber = { + onDisconnect: onDisconnectCallback +}; + +Notification.subscribe(subscriber, subscribeCallback); +``` + +### onDestroy + +onDestroy?:void + +服务失联回调函数。 + +**系统能力**:SystemCapability.Notification.Notification + +**示例:** + +```javascript +function subscribeCallback(err) { + if (err.code) { + console.info("subscribe failed " + JSON.stringify(err)); + } else { + console.info("subscribeCallback"); + } +}; + +function onDestroyCallback() { + console.info('===> onDestroy in test'); +} + +var subscriber = { + onDestroy: onDestroyCallback +}; + +Notification.subscribe(subscriber, subscribeCallback); +``` + +### onDoNotDisturbDateChange8+ + +onDoNotDisturbDateChange?:(mode: Notification.[DoNotDisturbDate](#donotdisturbdate8)) + +免打扰时间选项变更回调函数。 + +**系统能力**:SystemCapability.Notification.Notification + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | ------------------------ | ---- | -------------------------- | +| mode | Notification.[DoNotDisturbDate](#donotdisturbdate8) | 是 | 回调返回免打扰时间选项变更。 | + +**示例:** +```javascript +function subscribeCallback(err) { + if (err.code) { + console.info("subscribe failed " + JSON.stringify(err)); + } else { + console.info("subscribeCallback"); + } +}; + +function onDoNotDisturbDateChangeCallback() { + console.info('===> onDoNotDisturbDateChange in test'); +} + +var subscriber = { + onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback +}; + +Notification.subscribe(subscriber, subscribeCallback); +``` + + +### onEnabledNotificationChanged8+ + +onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](#enablednotificationcallbackdatasup8sup)) + +监听应用通知使能变化。 + +**系统能力**:SystemCapability.Notification.Notification + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | ------------------------ | ---- | -------------------------- | +| callback | AsyncCallback\<[EnabledNotificationCallbackData](#enablednotificationcallbackdatasup8sup)\> | 是 | 回调返回监听到的应用信息。 | + +**示例:** + +```javascript +function subscribeCallback(err) { + if (err.code) { + console.info("subscribe failed " + JSON.stringify(err)); + } else { + console.info("subscribeCallback"); + } +}; + +function onEnabledNotificationChangedCallback(err, callbackData) { + if (err.code) { + console.info("subscribe failed " + JSON.stringify(err)); + } else { + console.info("bundle: ", callbackData.bundle); + console.info("uid: ", callbackData.uid); + console.info("enable: ", callbackData.enable); + } +}; + +var subscriber = { + onEnabledNotificationChanged: onEnabledNotificationChangedCallback +}; + +Notification.subscribe(subscriber, subscribeCallback); +``` + +## SubscribeCallbackData + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| --------------- | ---- | --- | ------------------------------------------------- | ---- | -------- | +| request | 是 | 否 | [NotificationRequest](#notificationrequest) | 是 | 通知内容。 | +| sortingMap | 是 | 否 | [NotificationSortingMap](#notificationsortingmap) | 否 | 排序信息。 | +| reason | 是 | 否 | number | 否 | 删除原因。 | +| sound | 是 | 否 | string | 否 | 通知声音。 | +| vibrationValues | 是 | 否 | Array\ | 否 | 通知震动。 | + + +## EnabledNotificationCallbackData8+ + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| ------ | ---- | --- | ------- | ---- | ---------------- | +| bundle | 是 | 否 | string | 是 | 应用的包名。 | +| uid | 是 | 否 | number | 是 | 应用的uid。 | +| enable | 是 | 否 | boolean | 是 | 应用通知使能状态。 | + ## DoNotDisturbDate8+ @@ -2500,7 +2813,7 @@ Notification.getDeviceRemindType() | 名称 | 可读 | 可写 | 类型 | 描述 | | ----- | ---- | --- | ------------------------------------- | ------------------------ | -| type | 是 | 否 | [DoNotDisturbType](#donotdisturbtype) | 指定免打扰设置的时间类型。 | +| type | 是 | 否 | [DoNotDisturbType](#donotdisturbtype8) | 指定免打扰设置的时间类型。 | | begin | 是 | 否 | Date | 指定免打扰设置的起点时间。 | | end | 是 | 否 | Date | 指定免打扰设置的终点时间。 | @@ -2575,4 +2888,241 @@ Notification.getDeviceRemindType() | SOCIAL_COMMUNICATION | SlotType | 社交类型。 | | SERVICE_INFORMATION | SlotType | 服务类型。 | | CONTENT_INFORMATION | SlotType | 内容类型。 | -| OTHER_TYPES | SlotType | 其他类型。 | \ No newline at end of file +| OTHER_TYPES | SlotType | 其他类型。 | + + +## NotificationActionButton + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| --------- | --- | ---- | ----------------------------------------------- | ---- | ------------------------- | +| title | 是 | 是 | string | 是 | 按钮标题。 | +| wantAgent | 是 | 是 | WantAgent | 是 | 点击按钮时触发的WantAgent。 | +| extras | 是 | 是 | { [key: string]: any } | 否 | 按钮扩展信息。 | +| userInput9+ | 是 | 是 | [NotificationUserInput](#notificationuserinputsup8sup) | 否 | 用户输入对象实例。 | + + +## NotificationBasicContent + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| -------------- | ---- | ---- | ------ | ---- | ---------------------------------- | +| title | 是 | 是 | string | 是 | 通知标题。 | +| text | 是 | 是 | string | 是 | 通知内容。 | +| additionalText | 是 | 是 | string | 否 | 通知次要内容,是对通知内容的补充。 | + + +## NotificationLongTextContent + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| -------------- | ---- | --- | ------ | ---- | -------------------------------- | +| title | 是 | 是 | string | 是 | 通知标题。 | +| text | 是 | 是 | string | 是 | 通知内容。 | +| additionalText | 是 | 是 | string | 否 | 通知次要内容,是对通知内容的补充。 | +| longText | 是 | 是 | string | 是 | 通知的长文本。 | +| briefText | 是 | 是 | string | 是 | 通知概要内容,是对通知内容的总结。 | +| expandedTitle | 是 | 是 | string | 是 | 通知展开时的标题。 | + + +## NotificationMultiLineContent + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| -------------- | --- | --- | --------------- | ---- | -------------------------------- | +| title | 是 | 是 | string | 是 | 通知标题。 | +| text | 是 | 是 | string | 是 | 通知内容。 | +| additionalText | 是 | 是 | string | 否 | 通知次要内容,是对通知内容的补充。 | +| briefText | 是 | 是 | string | 是 | 通知概要内容,是对通知内容的总结。 | +| longTitle | 是 | 是 | string | 是 | 通知展开时的标题。 | +| lines | 是 | 是 | Array\ | 是 | 通知的多行文本。 | + + +## NotificationPictureContent + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| -------------- | ---- | --- | -------------- | ---- | -------------------------------- | +| title | 是 | 是 | string | 是 | 通知标题。 | +| text | 是 | 是 | string | 是 | 通知内容。 | +| additionalText | 是 | 是 | string | 否 | 通知次要内容,是对通知内容的补充。 | +| briefText | 是 | 是 | string | 是 | 通知概要内容,是对通知内容的总结。 | +| expandedTitle | 是 | 是 | string | 是 | 通知展开时的标题。 | +| picture | 是 | 是 | image.PixelMap | 是 | 通知的图片内容。 | + + +## NotificationContent + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| ----------- | ---- | --- | ------------------------------------------------------------ | ---- | ------------------ | +| contentType | 是 | 是 | [ContentType](#contenttype) | 是 | 通知内容类型。 | +| normal | 是 | 是 | [NotificationBasicContent](#notificationbasiccontent) | 否 | 基本类型通知内容。 | +| longText | 是 | 是 | [NotificationLongTextContent](#notificationlongtextcontent) | 否 | 长文本类型通知内容。 | +| multiLine | 是 | 是 | [NotificationMultiLineContent](#notificationmultilinecontent) | 否 | 多行类型通知内容。 | +| picture | 是 | 是 | [NotificationPictureContent](#notificationpicturecontent) | 否 | 图片类型通知内容。 | + + +## NotificationFlagStatus8+ + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 值 | 描述 | +| -------------- | --- | --------------------------------- | +| TYPE_NONE | 0 | 默认标志。 | +| TYPE_OPEN | 1 | 通知标志打开。 | +| TYPE_CLOSE | 2 | 通知标志关闭。 | + + +## NotificationFlags8+ + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| ---------------- | ---- | ---- | ---------------------- | ---- | --------------------------------- | +| soundEnabled | 是 | 否 | NotificationFlagStatus | 否 | 是否启用声音提示。 | +| vibrationEnabled | 是 | 否 | NotificationFlagStatus | 否 | 是否启用振动提醒功能。 | + + +## NotificationRequest + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| --------------------- | ---- | --- | --------------------------------------------- | ---- | -------------------------- | +| content | 是 | 是 | [NotificationContent](#notificationcontent) | 是 | 通知内容。 | +| id | 是 | 是 | number | 否 | 通知ID。 | +| slotType | 是 | 是 | [SlotType](#slottype) | 否 | 通道类型。 | +| isOngoing | 是 | 是 | boolean | 否 | 是否进行时通知。 | +| isUnremovable | 是 | 是 | boolean | 否 | 是否可移除。 | +| deliveryTime | 是 | 是 | number | 否 | 通知发送时间。 | +| tapDismissed | 是 | 是 | boolean | 否 | 通知是否自动清除。 | +| autoDeletedTime | 是 | 是 | number | 否 | 自动清除的时间。 | +| wantAgent | 是 | 是 | WantAgent | 否 | 点击跳转的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](#notificationactionbutton)\> | 否 | 通知按钮,最多两个按钮。 | +| smallIcon | 是 | 是 | PixelMap | 否 | 通知小图标。 | +| largeIcon | 是 | 是 | PixelMap | 否 | 通知大图标。 | +| creatorBundleName | 是 | 否 | string | 否 | 创建通知的包名。 | +| creatorUid | 是 | 否 | number | 否 | 创建通知的UID。 | +| creatorPid | 是 | 否 | number | 否 | 创建通知的PID。 | +| creatorUserId8+| 是 | 否 | number | 否 | 创建通知的UserId。 | +| hashCode | 是 | 否 | string | 否 | 通知唯一标识。 | +| classification | 是 | 是 | string | 否 | 通知分类。 | +| groupName8+| 是 | 是 | string | 否 | 组通知名称。 | +| template8+ | 是 | 是 | [NotificationTemplate](#notificationtemplatesup8sup) | 否 | 通知模板。 | +| isRemoveAllowed8+ | 是 | 否 | boolean | 否 | 通知是否能被移除。 | +| source8+ | 是 | 否 | number | 否 | 通知源。 | +| distributedOption8+ | 是 | 是 | [DistributedOptions](#distributedoptionssup8sup) | 否 | 分布式通知的选项。 | +| deviceId8+ | 是 | 否 | string | 否 | 通知源的deviceId。 | +| notificationFlags8+ | 是 | 否 | [NotificationFlags](#notificationflagssup8sup) | 否 | 获取NotificationFlags。 | + + +## DistributedOptions8+ + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| ---------------------- | ---- | ---- | -------------- | ---- | ---------------------------------- | +| isDistributed | 是 | 是 | boolean | 否 | 是否为分布式通知。 | +| supportDisplayDevices | 是 | 是 | Array\ | 是 | 可以同步通知到的设备类型。 | +| supportOperateDevices | 是 | 是 | Array\ | 否 | 可以打开通知的设备。 | +| remindType | 是 | 否 | number | 否 | 通知的提醒方式。 | + + +## NotificationSlot + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| -------------------- | ---- | --- | --------------------- | ---- | ------------------------------------------ | +| type | 是 | 是 | [SlotType](#slottype) | 是 | 通道类型。 | +| level | 是 | 是 | number | 否 | 通知级别,不设置则根据通知渠道类型有默认值。 | +| desc | 是 | 是 | string | 否 | 通知渠道描述信息。 | +| badgeFlag | 是 | 是 | boolean | 否 | 是否显示角标。 | +| bypassDnd | 是 | 是 | boolean | 否 | 置是否在系统中绕过免打扰模式。 | +| lockscreenVisibility | 是 | 是 | boolean | 否 | 在锁定屏幕上显示通知的模式。 | +| vibrationEnabled | 是 | 是 | boolean | 否 | 是否可振动。 | +| sound | 是 | 是 | string | 否 | 通知提示音。 | +| lightEnabled | 是 | 是 | boolean | 否 | 是否闪灯。 | +| lightColor | 是 | 是 | number | 否 | 通知灯颜色。 | +| vibrationValues | 是 | 是 | Array\ | 否 | 通知振动样式。 | + + +## NotificationSorting + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| -------- | ---- | --- | ------------------------------------- | ---- | ------------ | +| slot | 是 | 否 | [NotificationSlot](#notificationslot) | 是 | 通知通道内容。 | +| hashCode | 是 | 否 | string | 是 | 通知唯一标识。 | +| ranking | 是 | 否 | number | 是 | 通知排序序号。 | + + +## NotificationSortingMap + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| -------------- | ---- | --- | ------------------------------------------------------------ | ---- | ---------------- | +| sortings | 是 | 否 | {[key: string]: [NotificationSorting](#notificationsorting)} | 是 | 通知排序信息数组。 | +| sortedHashCode | 是 | 否 | Array\ | 是 | 通知唯一标识数组。 | + + +## NotificationSubscribeInfo + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| ----------- | --- | ---- | --------------- | ---- | ------------------------------- | +| bundleNames | 是 | 是 | Array\ | 否 | 指定订阅哪些包名的APP发来的通知。 | +| userId | 是 | 是 | number | 否 | 指定订阅哪个用户下发来的通知。 | + + +## NotificationTemplate8+ + +模板信息 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---- | ---------------------- | ---- | ---- | ---------- | +| name | string | 是 | 是 | 模板名称。 | +| data | {[key:string]: Object} | 是 | 是 | 模板数据。 | + + +## NotificationUserInput8+ + +**系统能力**:SystemCapability.Notification.Notification + +| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | +| -------- | --- | ---- | ------ | ---- | ----------------------------- | +| inputKey | 是 | 是 | string | 是 | 用户输入时用于标识此输入的key。 | + + +## DeviceRemindType8+ + +**系统能力**:SystemCapability.Notification.Notification + +| 名称 | 值 | 描述 | +| -------------------- | --- | --------------------------------- | +| IDLE_DONOT_REMIND | 0 | 设备未被使用,无需提醒。 | +| IDLE_REMIND | 1 | 提醒设备未被使用。 | +| ACTIVE_DONOT_REMIND | 2 | 设备正在使用,无需提醒。 | +| ACTIVE_REMIND | 3 | 提醒设备正在使用。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-notificationActionButton.md b/zh-cn/application-dev/reference/apis/js-apis-notificationActionButton.md deleted file mode 100644 index 1b1e5a52b628d1f7563eb4c92295f82390106dc2..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-notificationActionButton.md +++ /dev/null @@ -1,17 +0,0 @@ -# 通知按钮 - -> **说明:** -> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - -在通知中显示的操作按钮。 - -## NotificationActionButton - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | -| --------- | --- | ---- | ----------------------------------------------- | ---- | ------------------------- | -| title | 是 | 是 | string | 是 | 按钮标题。 | -| wantAgent | 是 | 是 | WantAgent | 是 | 点击按钮时触发的WantAgent。 | -| extras | 是 | 是 | { [key: string]: any } | 否 | 按钮扩展信息。 | -| userInput\9+ | 是 | 是 | [NotificationUserInput](#notificationuserinput) | 否 | 用户输入对象实例。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-notificationContent.md b/zh-cn/application-dev/reference/apis/js-apis-notificationContent.md deleted file mode 100644 index 071b55a2ca7d549f43b09e174143e31b61419737..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-notificationContent.md +++ /dev/null @@ -1,71 +0,0 @@ -# 通知内容 - -> **说明:** -> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - -用于表示通知内容。 - -## NotificationBasicContent - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | -| -------------- | ---- | ---- | ------ | ---- | ---------------------------------- | -| title | 是 | 是 | string | 是 | 通知标题。 | -| text | 是 | 是 | string | 是 | 通知内容。 | -| additionalText | 是 | 是 | string | 否 | 通知次要内容,是对通知内容的补充。 | - - -## NotificationLongTextContent - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | -| -------------- | ---- | --- | ------ | ---- | -------------------------------- | -| title | 是 | 是 | string | 是 | 通知标题。 | -| text | 是 | 是 | string | 是 | 通知内容。 | -| additionalText | 是 | 是 | string | 否 | 通知次要内容,是对通知内容的补充。 | -| longText | 是 | 是 | string | 是 | 通知的长文本。 | -| briefText | 是 | 是 | string | 是 | 通知概要内容,是对通知内容的总结。 | -| expandedTitle | 是 | 是 | string | 是 | 通知展开时的标题。 | - - -## NotificationMultiLineContent - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | -| -------------- | --- | --- | --------------- | ---- | -------------------------------- | -| title | 是 | 是 | string | 是 | 通知标题。 | -| text | 是 | 是 | string | 是 | 通知内容。 | -| additionalText | 是 | 是 | string | 否 | 通知次要内容,是对通知内容的补充。 | -| briefText | 是 | 是 | string | 是 | 通知概要内容,是对通知内容的总结。 | -| longTitle | 是 | 是 | string | 是 | 通知展开时的标题。 | -| lines | 是 | 是 | Array\ | 是 | 通知的多行文本。 | - - -## NotificationPictureContent - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | -| -------------- | ---- | --- | -------------- | ---- | -------------------------------- | -| title | 是 | 是 | string | 是 | 通知标题。 | -| text | 是 | 是 | string | 是 | 通知内容。 | -| additionalText | 是 | 是 | string | 否 | 通知次要内容,是对通知内容的补充。 | -| briefText | 是 | 是 | string | 是 | 通知概要内容,是对通知内容的总结。 | -| expandedTitle | 是 | 是 | string | 是 | 通知展开时的标题。 | -| picture | 是 | 是 | image.PixelMap | 是 | 通知的图片内容。 | - - -## NotificationContent - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | -| ----------- | ---- | --- | ------------------------------------------------------------ | ---- | ------------------ | -| contentType | 是 | 是 | [ContentType](#contenttype) | 是 | 通知内容类型。 | -| normal | 是 | 是 | [NotificationBasicContent](#notificationbasiccontent) | 否 | 基本类型通知内容。 | -| longText | 是 | 是 | [NotificationLongTextContent](#notificationlongtextcontent) | 否 | 长文本类型通知内容。 | -| multiLine | 是 | 是 | [NotificationMultiLineContent](#notificationmultilinecontent) | 否 | 多行类型通知内容。 | -| picture | 是 | 是 | [NotificationPictureContent](#notificationpicturecontent) | 否 | 图片类型通知内容。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-notificationFlags.md b/zh-cn/application-dev/reference/apis/js-apis-notificationFlags.md deleted file mode 100644 index 69a81dd513e502edae30a48615a9b7c984072c6d..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-notificationFlags.md +++ /dev/null @@ -1,28 +0,0 @@ -# 通知标志 - -> **说明:** -> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - -## NotificationFlagStatus - -通知标志的状态。 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 值 | 描述 | -| -------------- | --- | --------------------------------- | -| TYPE_NONE | 0 | 默认标志。 | -| TYPE_OPEN | 1 | 通知标志打开。 | -| TYPE_CLOSE | 2 | 通知标志关闭。 | - - -## NotificationFlags - -NotificationFlags实例。 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | -| ---------------- | ---- | ---- | ---------------------- | ---- | --------------------------------- | -| soundEnabled | 是 | 否 | NotificationFlagStatus | 否 | 是否启用声音提示。 | -| vibrationEnabled | 是 | 否 | NotificationFlagStatus | 否 | 是否启用振动提醒功能。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-notificationRequest.md b/zh-cn/application-dev/reference/apis/js-apis-notificationRequest.md deleted file mode 100644 index c45301601dd4d9892ad68fda7ec03bdef2f87516..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-notificationRequest.md +++ /dev/null @@ -1,58 +0,0 @@ -# NotificationRequest - -> **说明:** -> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - -## NotificationRequest - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | -| --------------------- | ---- | --- | --------------------------------------------- | ---- | -------------------------- | -| content | 是 | 是 | [NotificationContent](#notificationcontent) | 是 | 通知内容。 | -| id | 是 | 是 | number | 否 | 通知ID。 | -| slotType | 是 | 是 | [SlotType](#slottype) | 否 | 通道类型。 | -| isOngoing | 是 | 是 | boolean | 否 | 是否进行时通知。 | -| isUnremovable | 是 | 是 | boolean | 否 | 是否可移除。 | -| deliveryTime | 是 | 是 | number | 否 | 通知发送时间。 | -| tapDismissed | 是 | 是 | boolean | 否 | 通知是否自动清除。 | -| autoDeletedTime | 是 | 是 | number | 否 | 自动清除的时间。 | -| wantAgent | 是 | 是 | WantAgent | 否 | 点击跳转的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](#notificationactionbutton)\> | 否 | 通知按钮,最多两个按钮。 | -| smallIcon | 是 | 是 | PixelMap | 否 | 通知小图标。 | -| largeIcon | 是 | 是 | PixelMap | 否 | 通知大图标。 | -| creatorBundleName | 是 | 否 | string | 否 | 创建通知的包名。 | -| creatorUid | 是 | 否 | number | 否 | 创建通知的UID。 | -| creatorPid | 是 | 否 | number | 否 | 创建通知的PID。 | -| creatorUserId8+| 是 | 否 | number | 否 | 创建通知的UserId。 | -| hashCode | 是 | 否 | string | 否 | 通知唯一标识。 | -| classification | 是 | 是 | string | 否 | 通知分类。 | -| groupName8+| 是 | 是 | string | 否 | 组通知名称。 | -| template8+ | 是 | 是 | [NotificationTemplate](#notificationtemplate) | 否 | 通知模板。 | -| isRemoveAllowed8+ | 是 | 否 | boolean | 否 | 通知是否能被移除。 | -| source8+ | 是 | 否 | number | 否 | 通知源。 | -| distributedOption8+ | 是 | 是 | DistributedOptions | 否 | 分布式通知的选项。 | -| deviceId8+ | 是 | 否 | string | 否 | 通知源的deviceId。 | -| notificationFlags8+ | 是 | 否 | NotificationFlags | 否 | 获取NotificationFlags。 | - - -## DistributedOptions8+ - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | -| ---------------------- | ---- | ---- | -------------- | ---- | ---------------------------------- | -| isDistributed | 是 | 是 | boolean | 否 | 是否为分布式通知。 | -| supportDisplayDevices | 是 | 是 | Array\ | 是 | 可以同步通知到的设备类型。 | -| supportOperateDevices | 是 | 是 | Array\ | 否 | 可以打开通知的设备。 | -| remindType | 是 | 否 | number | 否 | 通知的提醒方式。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-notificationSlot.md b/zh-cn/application-dev/reference/apis/js-apis-notificationSlot.md deleted file mode 100644 index d9fdc4cbc9e49340e1cd9b8b1ab8b8b3af437579..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-notificationSlot.md +++ /dev/null @@ -1,23 +0,0 @@ -# NotificationSlot - -> **说明:** -> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - -## NotificationSlot - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | -| -------------------- | ---- | --- | --------------------- | ---- | ------------------------------------------ | -| type | 是 | 是 | [SlotType](#slottype) | 是 | 通道类型。 | -| level | 是 | 是 | number | 否 | 通知级别,不设置则根据通知渠道类型有默认值。 | -| desc | 是 | 是 | string | 否 | 通知渠道描述信息。 | -| badgeFlag | 是 | 是 | boolean | 否 | 是否显示角标。 | -| bypassDnd | 是 | 是 | boolean | 否 | 置是否在系统中绕过免打扰模式。 | -| lockscreenVisibility | 是 | 是 | boolean | 否 | 在锁定屏幕上显示通知的模式。 | -| vibrationEnabled | 是 | 是 | boolean | 否 | 是否可振动。 | -| sound | 是 | 是 | string | 否 | 通知提示音。 | -| lightEnabled | 是 | 是 | boolean | 否 | 是否闪灯。 | -| lightColor | 是 | 是 | number | 否 | 通知灯颜色。 | -| vibrationValues | 是 | 是 | Array\ | 否 | 通知振动样式。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-notificationSorting.md b/zh-cn/application-dev/reference/apis/js-apis-notificationSorting.md deleted file mode 100644 index 8f2d2d2f895d933dc7ab76fba8411cf7bc76a636..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-notificationSorting.md +++ /dev/null @@ -1,16 +0,0 @@ -# 活跃通知排序 - -> **说明:** -> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - -活跃通知的排序信息。 - -## NotificationSorting - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | -| -------- | ---- | --- | ------------------------------------- | ---- | ------------ | -| slot | 是 | 否 | [NotificationSlot](#notificationslot) | 是 | 通知通道内容。 | -| hashCode | 是 | 否 | string | 是 | 通知唯一标识。 | -| ranking | 是 | 否 | number | 是 | 通知排序序号。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-notificationSortingMap.md b/zh-cn/application-dev/reference/apis/js-apis-notificationSortingMap.md deleted file mode 100644 index f5766a4956cbbfb76881a002cee945983199b44c..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-notificationSortingMap.md +++ /dev/null @@ -1,15 +0,0 @@ -# 通知排序 - -> **说明:** -> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - -已订阅的所有通知中的活动通知的排序信息。 - -## NotificationSortingMap - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | -| -------------- | ---- | --- | ------------------------------------------------------------ | ---- | ---------------- | -| sortings | 是 | 否 | {[key: string]: [NotificationSorting](#notificationsorting)} | 是 | 通知排序信息数组。 | -| sortedHashCode | 是 | 否 | Array\ | 是 | 通知唯一标识数组。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-notificationSubscribeInfo.md b/zh-cn/application-dev/reference/apis/js-apis-notificationSubscribeInfo.md deleted file mode 100644 index 93e837bcfe9d1e76463b7a8322250bfcc8aa46cf..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-notificationSubscribeInfo.md +++ /dev/null @@ -1,15 +0,0 @@ -# 订阅通知的过滤条件 - -> **说明:** -> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - -设置发布者订阅所需通知的过滤条件。 - -## NotificationSubscribeInfo - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | -| ----------- | --- | ---- | --------------- | ---- | ------------------------------- | -| bundleNames | 是 | 是 | Array\ | 否 | 指定订阅哪些包名的APP发来的通知。 | -| userId | 是 | 是 | number | 否 | 指定订阅哪个用户下发来的通知。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-notificationSubscriber.md b/zh-cn/application-dev/reference/apis/js-apis-notificationSubscriber.md deleted file mode 100644 index 4e2f5bbbe777f5ce9d1098c929530061edbd3149..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-notificationSubscriber.md +++ /dev/null @@ -1,320 +0,0 @@ -# 通知回调 - -> **说明:** -> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - -提供在订阅者收到新通知或取消通知时将回调的方法。 - -## NotificationSubscriber - -### onConsume - -onConsume?:(data: [SubscribeCallbackData](#subscribecallbackdata)) - -接收通知回调函数。 - -**系统能力**:SystemCapability.Notification.Notification - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------------ | ------------------------ | ---- | -------------------------- | -| data | AsyncCallback\<[SubscribeCallbackData](#subscribecallbackdata)\> | 是 | 回调返回接收到的通知信息。 | - -**示例:** - -```javascript -function subscribeCallback(err) { - if (err.code) { - console.info("subscribe failed " + JSON.stringify(err)); - } 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 wantAgent = data.wantAgent; - wantAgent .getWant(wantAgent) - .then((data1) => { - console.log('===> getWant success want:' + JSON.stringfy(data1)); - }) - .catch((err) => { - console.error('===> getWant failed because' + JSON.stringfy(err)); - }); - console.info('===> onConsume callback req.wantAgent:' + JSON.stringfy(req.wantAgent)); -}; - -var subscriber = { - onConsume: onConsumeCallback -}; - -Notification.subscribe(subscriber, subscribeCallback); -``` - -### onCancel - -onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) - -删除通知回调函数。 - -**系统能力**:SystemCapability.Notification.Notification - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------------ | ------------------------ | ---- | -------------------------- | -| data | AsyncCallback\<[SubscribeCallbackData](#subscribecallbackdata)\> | 是 | 回调返回接收到的通知信息。 | - -**示例:** - -```javascript -function subscribeCallback(err) { - if (err.code) { - console.info("subscribe failed " + JSON.stringify(err)); - } else { - console.info("subscribeCallback"); - } -}; - -function onCancelCallback(data) { - console.info('===> onCancel in test'); - let req = data.request; - console.info('===> onCancel callback req.id:' + req.id); -} - -var subscriber = { - onCancel: onCancelCallback -}; - -Notification.subscribe(subscriber, subscribeCallback); -``` - -### onUpdate - -onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) - -更新通知排序回调函数。 - -**系统能力**:SystemCapability.Notification.Notification - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------------ | ------------------------ | ---- | -------------------------- | -| data | [NotificationSortingMap](#notificationsortingmap) | 是 | 回调返回接收到的通知信息。 | - -**示例:** - -```javascript -function subscribeCallback(err) { - if (err.code) { - console.info("subscribe failed " + JSON.stringify(err)); - } else { - console.info("subscribeCallback"); - } -}; - -function onUpdateCallback() { - console.info('===> onUpdate in test'); -} - -var subscriber = { - onUpdate: onUpdateCallback -}; - -Notification.subscribe(subscriber, subscribeCallback); -``` - -### onConnect - -onConnect?:void - -注册订阅回调函数。 - -**系统能力**:SystemCapability.Notification.Notification - -**示例:** - -```javascript -function subscribeCallback(err) { - if (err.code) { - console.info("subscribe failed " + JSON.stringify(err)); - } else { - console.info("subscribeCallback"); - } -}; - -function onConnectCallback() { - console.info('===> onConnect in test'); -} - -var subscriber = { - onConnect: onConnectCallback -}; - -Notification.subscribe(subscriber, subscribeCallback); -``` - -### onDisconnect - -onDisconnect?:void - -取消订阅回调函数。 - -**系统能力**:SystemCapability.Notification.Notification - -**示例:** - -```javascript -function subscribeCallback(err) { - if (err.code) { - console.info("subscribe failed " + JSON.stringify(err)); - } else { - console.info("subscribeCallback"); - } -}; - -function onDisconnectCallback() { - console.info('===> onDisconnect in test'); -} - -var subscriber = { - onDisconnect: onDisconnectCallback -}; - -Notification.subscribe(subscriber, subscribeCallback); -``` - -### onDestroy - -onDestroy?:void - -服务失联回调函数。 - -**系统能力**:SystemCapability.Notification.Notification - -**示例:** - -```javascript -function subscribeCallback(err) { - if (err.code) { - console.info("subscribe failed " + JSON.stringify(err)); - } else { - console.info("subscribeCallback"); - } -}; - -function onDestroyCallback() { - console.info('===> onDestroy in test'); -} - -var subscriber = { - onDestroy: onDestroyCallback -}; - -Notification.subscribe(subscriber, subscribeCallback); -``` - -### onDoNotDisturbDateChange8+ - -onDoNotDisturbDateChange?:(mode: Notification.[DoNotDisturbDate](#donotdisturbdate)) - -免打扰时间选项变更回调函数。 - -**系统能力**:SystemCapability.Notification.Notification - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------------ | ------------------------ | ---- | -------------------------- | -| mode | Notification.[DoNotDisturbDate](#donotdisturbdate) | 是 | 回调返回免打扰时间选项变更。 | - -**示例:** -```javascript -function subscribeCallback(err) { - if (err.code) { - console.info("subscribe failed " + JSON.stringify(err)); - } else { - console.info("subscribeCallback"); - } -}; - -function onDoNotDisturbDateChangeCallback() { - console.info('===> onDoNotDisturbDateChange in test'); -} - -var subscriber = { - onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback -}; - -Notification.subscribe(subscriber, subscribeCallback); -``` - - -### onEnabledNotificationChanged8+ - -onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](#enablednotificationcallbackdata)) - -监听应用通知使能变化。 - -**系统能力**:SystemCapability.Notification.Notification - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ------------ | ------------------------ | ---- | -------------------------- | -| callback | AsyncCallback\<[EnabledNotificationCallbackData](#enablednotificationcallbackdata)\> | 是 | 回调返回监听到的应用信息。 | - -**示例:** - -```javascript -function subscribeCallback(err) { - if (err.code) { - console.info("subscribe failed " + JSON.stringify(err)); - } else { - console.info("subscribeCallback"); - } -}; - -function onEnabledNotificationChangedCallback(err, callbackData) { - if (err.code) { - console.info("subscribe failed " + JSON.stringify(err)); - } else { - console.info("bundle: ", callbackData.bundle); - console.info("uid: ", callbackData.uid); - console.info("enable: ", callbackData.enable); - } -}; - -var subscriber = { - onEnabledNotificationChanged: onEnabledNotificationChangedCallback -}; - -Notification.subscribe(subscriber, subscribeCallback); -``` - -## SubscribeCallbackData - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | -| --------------- | ---- | --- | ------------------------------------------------- | ---- | -------- | -| request | 是 | 否 | [NotificationRequest](#notificationrequest) | 是 | 通知内容。 | -| sortingMap | 是 | 否 | [NotificationSortingMap](#notificationsortingmap) | 否 | 排序信息。 | -| reason | 是 | 否 | number | 否 | 删除原因。 | -| sound | 是 | 否 | string | 否 | 通知声音。 | -| vibrationValues | 是 | 否 | Array\ | 否 | 通知震动。 | - - -## EnabledNotificationCallbackData8+ - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | -| ------ | ---- | --- | ------- | ---- | ---------------- | -| bundle | 是 | 否 | string | 是 | 应用的包名。 | -| uid | 是 | 否 | number | 是 | 应用的uid。 | -| enable | 是 | 否 | boolean | 是 | 应用通知使能状态。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-notificationTemplate.md b/zh-cn/application-dev/reference/apis/js-apis-notificationTemplate.md deleted file mode 100644 index 5796b5ecdbcaa5b4dbf40b7d56c9982c98e762cf..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-notificationTemplate.md +++ /dev/null @@ -1,15 +0,0 @@ -# 通知模板 - -> **说明:** -> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - -## NotificationTemplate - -模板信息 - -**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification - -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ---- | ---------------------- | ---- | ---- | ---------- | -| name | string | 是 | 是 | 模板名称。 | -| data | {[key:string]: Object} | 是 | 是 | 模板数据。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-notificationUserInput.md b/zh-cn/application-dev/reference/apis/js-apis-notificationUserInput.md deleted file mode 100644 index 6c5262fe077b35b1c62766a06f97a525093be992..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-notificationUserInput.md +++ /dev/null @@ -1,12 +0,0 @@ -# NotificationUserInput - -> **说明:** -> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - -## NotificationUserInput - -**系统能力**:SystemCapability.Notification.Notification - -| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | -| -------- | --- | ---- | ------ | ---- | ----------------------------- | -| inputKey | 是 | 是 | string | 是 | 用户输入时用于标识此输入的key。 | \ No newline at end of file