diff --git a/zh-cn/application-dev/reference/apis/js-apis-reminderAgent.md b/zh-cn/application-dev/reference/apis/js-apis-reminderAgent.md index 302ec50fe59579adac4133cd9f5e41df1ce37536..3ece7e955fa6b4cc45141b212733f4f13284f42f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-reminderAgent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-reminderAgent.md @@ -11,6 +11,11 @@ import reminderAgent from'@ohos.reminderAgent'; ``` +## 系统能力 + +SystemCapability.Notification.ReminderAgent + + ## 权限 ohos.permission.PUBLISH_AGENT_REMINDER @@ -23,10 +28,10 @@ publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback<number& 发布一个后台代理提醒,使用callback方式实现异步调用。 - 参数 - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | reminderReq | [ReminderRequest](#reminderrequest) | 是 | 需要发布的提醒实例。 | - | callback | AsyncCallback<number> | 是 | 异步回调,返回当前发布的提醒的reminderId。 | + | reminderReq | [ReminderRequest](#reminderrequest) | 是 | 需要发布的提醒实例。 | + | callback | AsyncCallback<number> | 是 | 异步回调,返回当前发布的提醒的reminderId。 | - 示例: ``` @@ -50,14 +55,14 @@ publishReminder(reminderReq: ReminderRequest): Promise<number> 发布一个后台代理提醒,使用Promise方式实现异步调用。 - 参数 - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | reminderReq | [ReminderRequest](#reminderrequest) | 是 | 需要发布的提醒实例。 | + | reminderReq | [ReminderRequest](#reminderrequest) | 是 | 需要发布的提醒实例。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<number> | 返回提醒的reminderId。 | + | Promise<number> | 返回提醒的reminderId。 | - 示例 ``` @@ -83,10 +88,10 @@ cancelReminder(reminderId: number, callback: AsyncCallback<void>): void - 参数 -| 参数名 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| reminderId | number | 是 | 目标reminder的id号。 | -| callback | AsyncCallback<void> | 是 | 异步回调。 | +| reminderId | number | 是 | 目标reminder的id号。 | +| callback | AsyncCallback<void> | 是 | 异步回调。 | - 示例 @@ -108,15 +113,15 @@ cancelReminder(reminderId: number): Promise<void> - 参数 -| 参数名 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| reminderId | number | 是 | 目标reminder的id号。 | +| reminderId | number | 是 | 目标reminder的id号。 | - 返回值 -| 类型 | 说明 | +| 类型 | 说明 | | -------- | -------- | -| Promise<void> | Promise类型异步回调。 | +| Promise<void> | Promise类型异步回调。 | - 示例 @@ -139,9 +144,9 @@ getValidReminders(callback: AsyncCallback<Array<ReminderRequest>>): - 参数 -| 参数名 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| callback | AsyncCallback<Array<[ReminderRequest](#reminderrequest)>> | 是 | 异步回调,返回当前应用已设置的所有有效(未过期)的提醒。 | +| callback | AsyncCallback<Array<[ReminderRequest](#reminderrequest)>> | 是 | 异步回调,返回当前应用已设置的所有有效(未过期)的提醒。 | - 示例 @@ -180,14 +185,14 @@ getValidReminders(): Promise<Array<ReminderRequest>> - 返回值 -| 类型 | 说明 | +| 类型 | 说明 | | -------- | -------- | -| Promise<Array<[ReminderRequest](#reminderrequest)>> | 返回当前应用已设置的所有有效(未过期)的提醒。 | +| Promise<Array<[ReminderRequest](#reminderrequest)>> | 返回当前应用已设置的所有有效(未过期)的提醒。 | - 示例 ``` -reminderAgent.getValidReminders().then((reminders) => { +reminderAgent.getValidReminders().then((reminders) => { for (let i = 0; i < reminders.length; i++) { console.log("getValidReminders = " + reminders[i]); console.log("getValidReminders, reminderType = " + reminders[i].reminderType); @@ -221,14 +226,14 @@ cancelAllReminders(callback: AsyncCallback<void>): void - 参数 -| 参数名 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| callback | AsyncCallback<void> | 是 | 异步回调。 | +| callback | AsyncCallback<void> | 是 | 异步回调。 | - 示例 ``` -reminderAgent.cancelAllReminders((err, data) =>{ +reminderAgent.cancelAllReminders((err, data) =>{ console.log("do next")}) ``` @@ -241,9 +246,9 @@ cancelAllReminders(): Promise<void> - 返回值 -| 类型 | 说明 | +| 类型 | 说明 | | -------- | -------- | -| Promise<void> | Promise类型异步回调。 | +| Promise<void> | Promise类型异步回调。 | - 示例 @@ -261,10 +266,10 @@ addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback<void>) - 参数 -| 参数名 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| slot | [ERROR:Invalid link:zh-cn_topic_0000001158696346.xml#xref1954171018915,link:zh-cn_topic_0000001180018813.xml#section1382174172015](zh-cn_topic_0000001180018813.xml#section1382174172015) | 是 | notification slot实例。 | -| callback | AsyncCallback<void> | 是 | 异步回调。 | +| slot | [ERROR:Invalid link:zh-cn_topic_0000001158696346.xml#xref1954171018915,link:zh-cn_topic_0000001180018813.xml#section1382174172015](zh-cn_topic_0000001180018813.xml#section1382174172015) | 是 | notification slot实例。 | +| callback | AsyncCallback<void> | 是 | 异步回调。 | - 示例 @@ -290,15 +295,15 @@ addNotificationSlot(slot: NotificationSlot): Promise<void> - 参数 -| 参数名 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| slot | [ERROR:Invalid link:zh-cn_topic_0000001158696346.xml#xref2049924012917,link:zh-cn_topic_0000001180018813.xml#section1382174172015](zh-cn_topic_0000001180018813.xml#section1382174172015) | 是 | notification slot实例。 | +| slot | [ERROR:Invalid link:zh-cn_topic_0000001158696346.xml#xref2049924012917,link:zh-cn_topic_0000001180018813.xml#section1382174172015](zh-cn_topic_0000001180018813.xml#section1382174172015) | 是 | notification slot实例。 | - 返回值 -| 类型 | 说明 | +| 类型 | 说明 | | -------- | -------- | -| Promise<void> | Promise类型异步回调。 | +| Promise<void> | Promise类型异步回调。 | - 示例 @@ -324,10 +329,10 @@ removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback& - 参数 -| 参数名 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| slotType | [ERROR:Invalid link:zh-cn_topic_0000001158696346.xml#xref11228182975217,link:zh-cn_topic_0000001180018813.xml#section072355105110](zh-cn_topic_0000001180018813.xml#section072355105110) | 是 | 目标notification slot的类型。 | -| callback | AsyncCallback<void> | 是 | 异步回调。 | +| slotType | [ERROR:Invalid link:zh-cn_topic_0000001158696346.xml#xref11228182975217,link:zh-cn_topic_0000001180018813.xml#section072355105110](zh-cn_topic_0000001180018813.xml#section072355105110) | 是 | 目标notification slot的类型。 | +| callback | AsyncCallback<void> | 是 | 异步回调。 | - 示例 @@ -349,15 +354,15 @@ removeNotificationSlot(slotType: notification.SlotType): Promise<void> - 参数 -| 参数名 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| slotType | [ERROR:Invalid link:zh-cn_topic_0000001158696346.xml#xref1120863519109,link:zh-cn_topic_0000001180018813.xml#section072355105110](zh-cn_topic_0000001180018813.xml#section072355105110) | 是 | 目标notification slot的类型。 | +| slotType | [ERROR:Invalid link:zh-cn_topic_0000001158696346.xml#xref1120863519109,link:zh-cn_topic_0000001180018813.xml#section072355105110](zh-cn_topic_0000001180018813.xml#section072355105110) | 是 | 目标notification slot的类型。 | - 返回值 -| 类型 | 说明 | +| 类型 | 说明 | | -------- | -------- | -| Promise<void> | Promise类型异步回调。 | +| Promise<void> | Promise类型异步回调。 | - 示例 @@ -375,72 +380,72 @@ export default { 按钮的类型。 -| 名称 | 默认值 | 说明 | +| 名称 | 默认值 | 说明 | | -------- | -------- | -------- | -| ACTION_BUTTON_TYPE_CLOSE | 0 | 表示关闭提醒的按钮。 | -| ACTION_BUTTON_TYPE_SNOOZE | 1 | 表示延迟提醒的按钮。 | +| ACTION_BUTTON_TYPE_CLOSE | 0 | 表示关闭提醒的按钮。 | +| ACTION_BUTTON_TYPE_SNOOZE | 1 | 表示延迟提醒的按钮。 | ## ReminderType 提醒的类型。 -| 名称 | 默认值 | 说明 | +| 名称 | 默认值 | 说明 | | -------- | -------- | -------- | -| REMINDER_TYPE_TIMER | 0 | 表示提醒类型:倒计时。 | -| REMINDER_TYPE_CALENDAR | 1 | 表示提醒类型:日历。 | -| REMINDER_TYPE_ALARM | 2 | 表示提醒类型:闹钟。 | +| REMINDER_TYPE_TIMER | 0 | 表示提醒类型:倒计时。 | +| REMINDER_TYPE_CALENDAR | 1 | 表示提醒类型:日历。 | +| REMINDER_TYPE_ALARM | 2 | 表示提醒类型:闹钟。 | ## ActionButton 用于设置弹出的提醒通知信息上显示的按钮类型和标题。 -| 名称 | 参数类型 | 必填 | 说明 | +| 名称 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| title | string | 是 | 按钮显示的标题。 | -| type | [ActionButtonType](#actionbuttontype) | 是 | 按钮的类型。 | +| title | string | 是 | 按钮显示的标题。 | +| type | [ActionButtonType](#actionbuttontype) | 是 | 按钮的类型。 | ## WantAgent 点击提醒通知后跳转的目标ability信息。 -| 名称 | 参数类型 | 必填 | 说明 | +| 名称 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| pkgName | string | 是 | 指明点击提醒通知栏后跳转的目标hap包名。 | -| abilityName | string | 是 | 指明点击提醒通知栏后跳转的目标ability名称。 | +| pkgName | string | 是 | 指明点击提醒通知栏后跳转的目标hap包名。 | +| abilityName | string | 是 | 指明点击提醒通知栏后跳转的目标ability名称。 | ## MaxScreenWantAgent 提醒到达时自动拉起的目标ability信息。 -| 名称 | 参数类型 | 必填 | 说明 | +| 名称 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| pkgName | string | 是 | 指明提醒到达时自动拉起的目标hap包名(如果设备在使用中,则只弹出通知横幅框)。 | -| abilityName | string | 是 | 指明提醒到达时自动拉起的目标ability名(如果设备在使用中,则只弹出通知横幅框)。 | +| pkgName | string | 是 | 指明提醒到达时自动拉起的目标hap包名(如果设备在使用中,则只弹出通知横幅框)。 | +| abilityName | string | 是 | 指明提醒到达时自动拉起的目标ability名(如果设备在使用中,则只弹出通知横幅框)。 | ## ReminderRequest 提醒实例对象,用于设置提醒类型、响铃时长等具体信息。 -| 名称 | 参数类型 | 必填 | 说明 | +| 名称 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| reminderType | ReminderType | 是 | 指明提醒类型。 | -| actionButton | [ActionButton?, ActionButton?] | 否 | 弹出的提醒通知栏中显示的按钮(参数可选,支持0/1/2个按钮)。 | -| wantAgent | WantAgent | 否 | 点击通知后需要跳转的目标ability信息。 | -| maxScreenWantAgent | MaxScreenWantAgent | 否 | 提醒到达时跳转的目标包。如果设备正在使用中,则弹出一个通知框。 | -| ringDuration | number | 否 | 指明响铃时长。 | -| snoozeTimes | number | 否 | 指明延迟提醒次数。 | -| timeInterval | number | 否 | 执行延迟提醒间隔。 | -| title | string | 否 | 指明提醒标题。 | -| content | string | 否 | 指明提醒内容。 | -| expiredContent | string | 否 | 指明提醒过期后需要显示的内容。 | -| snoozeContent | string | 否 | 指明延迟提醒时需要显示的内容。 | -| notificationId | number | 否 | 指明提醒使用的通知的id号,相同id号的提醒会覆盖。 | -| slotType | [ERROR:Invalid link:zh-cn_topic_0000001158696346.xml#xref39047351518,link:zh-cn_topic_0000001180018813.xml#section072355105110](zh-cn_topic_0000001180018813.xml#section072355105110) | 否 | 指明提醒的slot类型。 | +| reminderType | ReminderType | 是 | 指明提醒类型。 | +| actionButton | [ActionButton?, ActionButton?] | 否 | 弹出的提醒通知栏中显示的按钮(参数可选,支持0/1/2个按钮)。 | +| wantAgent | WantAgent | 否 | 点击通知后需要跳转的目标ability信息。 | +| maxScreenWantAgent | MaxScreenWantAgent | 否 | 提醒到达时跳转的目标包。如果设备正在使用中,则弹出一个通知框。 | +| ringDuration | number | 否 | 指明响铃时长。 | +| snoozeTimes | number | 否 | 指明延迟提醒次数。 | +| timeInterval | number | 否 | 执行延迟提醒间隔。 | +| title | string | 否 | 指明提醒标题。 | +| content | string | 否 | 指明提醒内容。 | +| expiredContent | string | 否 | 指明提醒过期后需要显示的内容。 | +| snoozeContent | string | 否 | 指明延迟提醒时需要显示的内容。 | +| notificationId | number | 否 | 指明提醒使用的通知的id号,相同id号的提醒会覆盖。 | +| slotType | [ERROR:Invalid link:zh-cn_topic_0000001158696346.xml#xref39047351518,link:zh-cn_topic_0000001180018813.xml#section072355105110](zh-cn_topic_0000001180018813.xml#section072355105110) | 否 | 指明提醒的slot类型。 | ## ReminderRequestCalendar @@ -449,11 +454,11 @@ ReminderRequestCalendar extends ReminderRequest 日历实例对象,用于设置提醒的时间。 -| 名称 | 参数类型 | 必填 | 说明 | +| 名称 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| dateTime | [LocalDateTime](#localdatetime) | 是 | 指明提醒的目标时间。 | -| repeatMonths | Array<number> | 否 | 指明重复提醒的月份。 | -| repeatDays | Array<number> | 否 | 指明重复提醒的日期。 | +| dateTime | [LocalDateTime](#localdatetime) | 是 | 指明提醒的目标时间。 | +| repeatMonths | Array<number> | 否 | 指明重复提醒的月份。 | +| repeatDays | Array<number> | 否 | 指明重复提醒的日期。 | ## ReminderRequestAlarm @@ -462,11 +467,11 @@ ReminderRequestAlarm extends ReminderRequest 闹钟实例对象,用于设置提醒的时间。 -| 名称 | 参数类型 | 必填 | 说明 | +| 名称 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| hour | number | 是 | 指明提醒的目标时刻。 | -| minute | number | 是 | 指明提醒的目标分钟。 | -| daysOfWeek | Array<number> | 否 | 指明每周哪几天需要重复提醒。 | +| hour | number | 是 | 指明提醒的目标时刻。 | +| minute | number | 是 | 指明提醒的目标分钟。 | +| daysOfWeek | Array<number> | 否 | 指明每周哪几天需要重复提醒。 | ## ReminderRequestTimer @@ -475,20 +480,20 @@ ReminderRequestTimer extends ReminderRequest 倒计时实例对象,用于设置提醒的时间。 -| 名称 | 参数类型 | 必填 | 说明 | +| 名称 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| triggerTimeInSeconds | number | 是 | 指明倒计时的秒数。 | +| triggerTimeInSeconds | number | 是 | 指明倒计时的秒数。 | ## LocalDateTime 用于日历类提醒设置时指定时间信息。 -| 名称 | 参数类型 | 必填 | 说明 | +| 名称 | 参数类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| year | number | 是 | 年 | -| month | number | 是 | 月 | -| day | number | 是 | 日 | -| hour | number | 是 | 时 | -| minute | number | 是 | 分 | -| second | number | 否 | 秒 | +| year | number | 是 | 年 | +| month | number | 是 | 月 | +| day | number | 是 | 日 | +| hour | number | 是 | 时 | +| minute | number | 是 | 分 | +| second | number | 否 | 秒 |