diff --git a/en/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md b/en/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md index cb31281e693400790ddb2f438ebb744d77ddaf89..5b5961b409b1c843bc344a898582de3bfffd7060 100644 --- a/en/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md +++ b/en/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md @@ -350,7 +350,7 @@ You can set your application to call the **ReminderRequest** class to create s **ReminderRequestCalendar** extends **ReminderRequest** and defines a reminder for a calendar event. -For the application to run properly, if both **repeatMonths** and **repeatDays** are not specified, the earliest reminder time must be later than the current time. +For the application to run properly, if both **repeatMonths** and **repeatDays** are not specified, the earliest reminder time must be later than the current time. **Table 8** ReminderRequestCalendar instance @@ -542,7 +542,7 @@ For the application to run properly, if both **repeatMonths** and **repeatDays** ## How to Develop ->![](../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE:** >To publish a reminder, your application needs to apply for the **ohos.permission.PUBLISH\_AGENT\_REMINDER** permission. Publish a 10-second countdown reminder. @@ -553,7 +553,10 @@ Publish a 10-second countdown reminder. import reminderAgent from '@ohos.reminderAgent'; import notification from '@ohos.notification'; export default { - timer: { + // In JS Project: + // timer: { + // In eTS Project: + let timer : reminderAgent.ReminderRequestTimer = { reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER, triggerTimeInSeconds: 10, actionButton: [ @@ -602,7 +605,10 @@ Publish a 10-second countdown reminder. Sample code for defining a calendar reminder instance: ``` -calendar: { +// In JS Project: +// calendar: { +// In eTS Project: +let calendar : reminderAgent.ReminderRequestCalendar = { reminderType: reminderAgent.ReminderType.REMINDER_TYPE_CALENDAR, dateTime: { year: 2050, @@ -647,7 +653,10 @@ calendar: { Sample code for defining an alarm reminder instance: ``` -alarm: { +// In JS Project: +// alarm: { +// In eTS Project: +let alarm : reminderAgent.ReminderRequestAlarm = { reminderType: reminderAgent.ReminderType.REMINDER_TYPE_ALARM, hour: 11, minute: 14, diff --git a/en/application-dev/reference/apis/js-apis-reminderAgent.md b/en/application-dev/reference/apis/js-apis-reminderAgent.md index 8d8b442bcfdfff03f6b1e4214c1033b1061fb00c..9c74bc655ec2c4959ad4b38c164bfd70a2a06f1a 100644 --- a/en/application-dev/reference/apis/js-apis-reminderAgent.md +++ b/en/application-dev/reference/apis/js-apis-reminderAgent.md @@ -30,18 +30,13 @@ Publishes an agent-powered reminder. This API uses an asynchronous callback to r **Example** ``` - export default { - data: { - timer: { - reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER, - triggerTimeInSeconds: 3 - } - }, - startTimer() { - reminderAgent.publishReminder(timer, (err, reminderId) => { console.log("reminderId = " + reminderId); - }); - } + let timer : reminderAgent.ReminderRequestTimer = { + reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER, + triggerTimeInSeconds: 10 } + reminderAgent.publishReminder(timer, (err, reminderId) => { + console.log("reminderId = " + reminderId); + }); ``` @@ -65,19 +60,13 @@ Publishes an agent-powered reminder. This API uses a promise callback to return **Example** ``` - export default { - data: - {timer: { - reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER, - triggerTimeInSeconds: 3 - } - }, - startTimer() { - reminderAgent.publishReminder(this.timer).then((reminderId) => { - console.log("reminderId = " + reminderId); - }); - } + let timer : reminderAgent.ReminderRequestTimer = { + reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER, + triggerTimeInSeconds: 10 } + reminderAgent.publishReminder(timer).then((reminderId) => { + console.log("reminderId = " + reminderId); + }); ``` @@ -99,13 +88,9 @@ Cancels the reminder with the specified ID. This API uses an asynchronous callba **Example** ``` -export default { - cancel() { - reminderAgent.cancelReminder(1, (err, data) => { - console.log("do next"); - }); - } -} +reminderAgent.cancelReminder(1, (err, data) => { + console.log("cancelReminder callback"); +}); ``` @@ -132,13 +117,9 @@ Cancels the reminder with the specified ID. This API uses a promise to return th **Example** ``` -export default { - cancel() { - reminderAgent.cancelReminder(1).then(() => { - console.log("do next"); - }); - } -} +reminderAgent.cancelReminder(1).then(() => { + console.log("cancelReminder promise"); +}); ``` @@ -160,6 +141,7 @@ Obtains all valid (not yet expired) reminders set by the current application. Th ``` reminderAgent.getValidReminders((err, reminders) => { + console.log("getValidReminders length = " + reminders.length); for (let i = 0; i < reminders.length; i++) { console.log("getValidReminders = " + reminders[i]); console.log("getValidReminders, reminderType = " + reminders[i].reminderType); @@ -203,6 +185,7 @@ Obtains all valid (not yet expired) reminders set by the current application. Th ``` reminderAgent.getValidReminders().then((reminders) => { + console.log("getValidReminders length = " + reminders.length); for (let i = 0; i < reminders.length; i++) { console.log("getValidReminders = " + reminders[i]); console.log("getValidReminders, reminderType = " + reminders[i].reminderType); @@ -246,7 +229,8 @@ Cancels all reminders set by the current application. This API uses an asynchron ``` reminderAgent.cancelAllReminders((err, data) =>{ - console.log("do next")}) + console.log("cancelAllReminders callback") +}) ``` @@ -268,7 +252,8 @@ Cancels all reminders set by the current application. This API uses a promise to ``` reminderAgent.cancelAllReminders().then(() => { - console.log("do next")}) + console.log("cancelAllReminders promise") +}) ``` @@ -290,16 +275,13 @@ Adds a reminder notification slot. This API uses an asynchronous callback to ret **Example** ``` -export default { data: { mySlot: { - type: 3, - sound: "/sdcard/music2.mp3" - } }, - addSlot() { - reminderAgent.addNotificationSlot(this.mySlot, (err, data) => { - console.log("do next"); - }); - } +mySlot: { + type: 3, + sound: "/sdcard/music2.mp3" } +reminderAgent.addNotificationSlot(this.mySlot, (err, data) => { + console.log("addNotificationSlot callback"); +}); ``` @@ -357,12 +339,9 @@ Removes a notification slot of a specified type. This API uses an asynchronous c **Example** ``` -export default { - removeSlot() {reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION, (err, data) => { - console.log("do next"); +reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION, (err, data) => { + console.log("removeNotificationSlot callback"); }); - } -} ``` @@ -389,12 +368,9 @@ Removes a notification slot of a specified type. This API uses a promise to retu **Example** ``` -export default { - removeSlot() { reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION).then(() => { - console.log("do next"); - }); - } -} +reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION).then(() => { + console.log("removeNotificationSlot promise"); +}); ``` diff --git a/zh-cn/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md b/zh-cn/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md index 354cf1f372dbbc825a03e30ad2163b98eef427e6..58fcf2260cbd4e29d4a0cfdae629cd3a970500c7 100644 --- a/zh-cn/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md +++ b/zh-cn/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md @@ -139,8 +139,12 @@ interface LocalDateTime:时间信息实例 1. 定义一个倒计时实例 ``` import reminderAgent from '@ohos.reminderAgent'; - import notification from '@ohos.notification';export default { - timer: { + import notification from '@ohos.notification'; + export default { + // JS工程写法: + // timer: { + // eTS工程写法: + let timer : reminderAgent.ReminderRequestTimer = { reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER, triggerTimeInSeconds: 10, actionButton: [ @@ -186,7 +190,10 @@ interface LocalDateTime:时间信息实例 日历实例定义: ``` -calendar: { +// JS工程写法: +// calendar: { +// eTS工程写法: +let calendar : reminderAgent.ReminderRequestCalendar = { reminderType: reminderAgent.ReminderType.REMINDER_TYPE_CALENDAR, dateTime: { year: 2050, @@ -231,7 +238,10 @@ calendar: { 闹钟实例定义: ``` -alarm: { +// JS工程写法: +// alarm: { +// eTS工程写法: +let alarm : reminderAgent.ReminderRequestAlarm = { reminderType: reminderAgent.ReminderType.REMINDER_TYPE_ALARM, hour: 11, minute: 14, 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 03b20d12cecd0a6db2c63e3c3bacf6c9ecd381da..3bbe28f2a16472c13da96d8fe7d9ea67fc822356 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-reminderAgent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-reminderAgent.md @@ -29,20 +29,15 @@ publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback<number& | callback | AsyncCallback<number> | 是 | 异步回调,返回当前发布的提醒的reminderId。 | **示例**: - ``` - export default { - data: { - timer: { - reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER, - triggerTimeInSeconds: 3 - } - }, - startTimer() { - reminderAgent.publishReminder(timer, (err, reminderId) => { console.log("reminderId = " + reminderId); - }); - } +``` + let timer : reminderAgent.ReminderRequestTimer = { + reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER, + triggerTimeInSeconds: 10 } - ``` + reminderAgent.publishReminder(timer, (err, reminderId) => { + console.log("reminderId = " + reminderId); + }); +``` ## reminderAgent.publishReminder @@ -64,21 +59,15 @@ publishReminder(reminderReq: ReminderRequest): Promise<number> | Promise<number> | 返回提醒的reminderId。 | **示例**: - ``` - export default { - data: - {timer: { - reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER, - triggerTimeInSeconds: 3 - } - }, - startTimer() { - reminderAgent.publishReminder(this.timer).then((reminderId) => { - console.log("reminderId = " + reminderId); - }); - } +``` + let timer : reminderAgent.ReminderRequestTimer = { + reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER, + triggerTimeInSeconds: 10 } - ``` + reminderAgent.publishReminder(timer).then((reminderId) => { + console.log("reminderId = " + reminderId); + }); +``` ## reminderAgent.cancelReminder @@ -99,13 +88,9 @@ cancelReminder(reminderId: number, callback: AsyncCallback<void>): void **示例**: ``` -export default { - cancel() { - reminderAgent.cancelReminder(1, (err, data) => { - console.log("do next"); - }); - } -} +reminderAgent.cancelReminder(1, (err, data) => { + console.log("cancelReminder callback"); +}); ``` @@ -132,13 +117,9 @@ cancelReminder(reminderId: number): Promise<void> **示例**: ``` -export default { - cancel() { - reminderAgent.cancelReminder(1).then(() => { - console.log("do next"); - }); - } -} +reminderAgent.cancelReminder(1).then(() => { + console.log("cancelReminder promise"); +}); ``` @@ -160,6 +141,7 @@ getValidReminders(callback: AsyncCallback<Array<ReminderRequest>>): ``` reminderAgent.getValidReminders((err, reminders) => { + console.log("getValidReminders length = " + reminders.length); for (let i = 0; i < reminders.length; i++) { console.log("getValidReminders = " + reminders[i]); console.log("getValidReminders, reminderType = " + reminders[i].reminderType); @@ -203,6 +185,7 @@ getValidReminders(): Promise<Array<ReminderRequest>> ``` reminderAgent.getValidReminders().then((reminders) => { + console.log("getValidReminders length = " + reminders.length); for (let i = 0; i < reminders.length; i++) { console.log("getValidReminders = " + reminders[i]); console.log("getValidReminders, reminderType = " + reminders[i].reminderType); @@ -246,7 +229,8 @@ cancelAllReminders(callback: AsyncCallback<void>): void ``` reminderAgent.cancelAllReminders((err, data) =>{ - console.log("do next")}) + console.log("cancelAllReminders callback") +}) ``` @@ -268,7 +252,8 @@ cancelAllReminders(): Promise<void> ``` reminderAgent.cancelAllReminders().then(() => { - console.log("do next")}) + console.log("cancelAllReminders promise") +}) ``` @@ -290,16 +275,13 @@ addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback<void>) **示例**: ``` -export default { data: { mySlot: { - type: 3, - sound: "/sdcard/music2.mp3" - } }, - addSlot() { - reminderAgent.addNotificationSlot(this.mySlot, (err, data) => { - console.log("do next"); - }); - } +mySlot: { + type: 3, + sound: "/sdcard/music2.mp3" } +reminderAgent.addNotificationSlot(this.mySlot, (err, data) => { + console.log("addNotificationSlot callback"); +}); ``` @@ -326,16 +308,13 @@ addNotificationSlot(slot: NotificationSlot): Promise<void> **示例**: ``` -export default { data: { mySlot: { - type: 3, - sound: "/sdcard/music2.mp3" - } }, - addSlot() { - reminderAgent.addNotificationSlot(this.mySlot).then(() => { - console.log("do next"); - }); - } +mySlot: { + type: 3, + sound: "/sdcard/music2.mp3" } +reminderAgent.addNotificationSlot(this.mySlot).then(() => { + console.log("addNotificationSlot promise"); +}); ``` @@ -357,12 +336,9 @@ removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback& **示例**: ``` -export default { - removeSlot() {reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION, (err, data) => { - console.log("do next"); +reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION, (err, data) => { + console.log("removeNotificationSlot callback"); }); - } -} ``` @@ -389,12 +365,9 @@ removeNotificationSlot(slotType: notification.SlotType): Promise<void> **示例**: ``` -export default { - removeSlot() { reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION).then(() => { - console.log("do next"); - }); - } -} +reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION).then(() => { + console.log("removeNotificationSlot promise"); +}); ```