diff --git a/zh-cn/application-dev/notification/background-agent-scheduled-reminder-guide.md b/zh-cn/application-dev/notification/background-agent-scheduled-reminder-guide.md index 14bf590dee80d341932975ba780a20d1c5a75649..b34d60d59cfcbc42652b6640b1fdb451e930622f 100644 --- a/zh-cn/application-dev/notification/background-agent-scheduled-reminder-guide.md +++ b/zh-cn/application-dev/notification/background-agent-scheduled-reminder-guide.md @@ -7,7 +7,7 @@ ## 接口说明 -reminderAgent:封装了发布、取消提醒类通知的方法 +reminderAgent:封装了发布、取消提醒类通知的方法。 具体后台提醒相关功能接口请见[后台代理提醒](../reference/apis/js-apis-reminderAgent.md)。 @@ -26,14 +26,14 @@ reminderAgent:封装了发布、取消提醒类通知的方法 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > -> 1. 应用需要配置权限:ohos.permission.PUBLISH_AGENT_REMINDER +> 1. 应用需要配置权限:ohos.permission.PUBLISH_AGENT_REMINDER。 > -> 2. 应用需要申请通知弹窗:[Notification.requestEnableNotification](../reference/apis/js-apis-notification.md#notificationrequestenablenotification8) +> 2. 应用需要申请通知弹窗:[Notification.requestEnableNotification](../reference/apis/js-apis-notification.md#notificationrequestenablenotification8)。 -发布一个10秒倒计时提醒 +1. 定义一个提醒代理。 -1. 定义一个倒计时实例 - ``` + 倒计时实例定义: + ```js import reminderAgent from '@ohos.reminderAgent'; import notification from '@ohos.notification'; export default { @@ -66,8 +66,97 @@ reminderAgent:封装了发布、取消提醒类通知的方法 } ``` -2. 发布提醒 - ``` + 日历实例定义: + + ```js + // JS工程写法: + // calendar: { + // eTS工程写法: + let calendar : reminderAgent.ReminderRequestCalendar = { + reminderType: reminderAgent.ReminderType.REMINDER_TYPE_CALENDAR, + dateTime: { + year: 2050, + month: 7, + day: 30, + hour: 11, + minute: 14, + second: 30 + }, + repeatMonths: [1], + repeatDays: [1], + actionButton: [ + { + title: "close", + type: reminderAgent.ActionButtonType.ACTION_BUTTON_TYPE_CLOSE + }, + { + title: "snooze", + type: reminderAgent.ActionButtonType.ACTION_BUTTON_TYPE_SNOOZE + }, + ], + wantAgent: { + pkgName: "com.example.device", + abilityName: "com.example.device.MainAbility" + }, + maxScreenWantAgent: { + pkgName: "com.example.device", + abilityName: "com.example.device.MainAbility" + }, + ringDuration: 5, + snoozeTimes: 2, + timeInterval: 5, + title: "this is title", + content: "this is content", + expiredContent: "this reminder has expired", + snoozeContent: "remind later", + notificationId: 100, + slotType: notification.SlotType.SOCIAL_COMMUNICATION + } + ``` + + 闹钟实例定义: + + ```js + // JS工程写法: + // alarm: { + // eTS工程写法: + let alarm : reminderAgent.ReminderRequestAlarm = { + reminderType: reminderAgent.ReminderType.REMINDER_TYPE_ALARM, + hour: 11, + minute: 14, + daysOfWeek: [0], + actionButton: [ + { + title: "close", + type: reminderAgent.ActionButtonType.ACTION_BUTTON_TYPE_CLOSE + }, + { + title: "snooze", + type: reminderAgent.ActionButtonType.ACTION_BUTTON_TYPE_SNOOZE + }, + ], + wantAgent: { + pkgName: "com.example.device", + abilityName: "com.example.device.MainAbility" + }, + maxScreenWantAgent: { + pkgName: "com.example.device", + abilityName: "com.example.device.MainAbility" + }, + ringDuration: 5, + snoozeTimes: 2, + timeInterval: 5, + title: "this is title", + content: "this is content", + expiredContent: "this reminder has expired", + snoozeContent: "remind later", + notificationId: 100, + slotType: notification.SlotType.SOCIAL_COMMUNICATION + } + ``` + +2. 发布倒计时提醒。 + ```js startTimer() { reminderAgent.publishReminder(this.timer, (err, reminderId) =>{ this.printInfo(JSON.stringify(err)); @@ -77,102 +166,12 @@ reminderAgent:封装了发布、取消提醒类通知的方法 ``` HML页面: - ``` + ```html