提交 d87e6b2c 编写于 作者: R rcy-hw

update api and user guide

Signed-off-by: Nrcy-hw <renchunyang@huawei.com>
上级 d66c8408
......@@ -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<a name="section4207112818418"></a>
>![](../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,
......
......@@ -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");
});
```
......
......@@ -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,
......
......@@ -29,20 +29,15 @@ publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback&lt;number&
| callback | AsyncCallback&lt;number&gt; | 是 | 异步回调,返回当前发布的提醒的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&lt;number&gt;
| Promise&lt;number&gt; | 返回提醒的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&lt;void&gt;): 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&lt;void&gt;
**示例**
```
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&lt;Array&lt;ReminderRequest&gt;&gt;):
```
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&lt;Array&lt;ReminderRequest&gt;&gt;
```
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&lt;void&gt;): void
```
reminderAgent.cancelAllReminders((err, data) =>{
console.log("do next")})
console.log("cancelAllReminders callback")
})
```
......@@ -268,7 +252,8 @@ cancelAllReminders(): Promise&lt;void&gt;
```
reminderAgent.cancelAllReminders().then(() => {
console.log("do next")})
console.log("cancelAllReminders promise")
})
```
......@@ -290,16 +275,13 @@ addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback&lt;void&gt;)
**示例**
```
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&lt;void&gt;
**示例**
```
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&lt;void&gt;
**示例**
```
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");
});
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册