You need to sign in or sign up before continuing.
未验证 提交 1e3a479f 编写于 作者: O openharmony_ci 提交者: Gitee

!3266 后台代理提醒-更新开发指南描述和接口文档示例

Merge pull request !3266 from rcy-hw/0326
......@@ -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,
......
......@@ -29,19 +29,14 @@ Publishes an agent-powered reminder. This API uses an asynchronous callback to r
| callback | AsyncCallback&lt;number&gt; | Yes| Asynchronous callback used to return the published reminder's ID.|
**Example**
```
export default {
data: {
timer: {
reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER,
triggerTimeInSeconds: 3
}
},
startTimer() {
reminderAgent.publishReminder(timer, (err, reminderId) => { console.log("reminderId = " + reminderId);
});
}
```js
let timer = {
reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER,
triggerTimeInSeconds: 10
}
reminderAgent.publishReminder(timer, (err, reminderId) => {
console.log("reminderId = " + reminderId);
});
```
......@@ -64,20 +59,14 @@ Publishes an agent-powered reminder. This API uses a promise callback to return
| Promise&lt;number&gt; | Promise used to return the published reminder's ID.|
**Example**
```
export default {
data:
{timer: {
reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER,
triggerTimeInSeconds: 3
}
},
startTimer() {
reminderAgent.publishReminder(this.timer).then((reminderId) => {
console.log("reminderId = " + reminderId);
});
}
```js
let timer = {
reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER,
triggerTimeInSeconds: 10
}
reminderAgent.publishReminder(timer).then((reminderId) => {
console.log("reminderId = " + reminderId);
});
```
......@@ -98,14 +87,10 @@ 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");
});
}
}
```js
reminderAgent.cancelReminder(1, (err, data) => {
console.log("cancelReminder callback");
});
```
......@@ -131,14 +116,10 @@ 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");
});
}
}
```js
reminderAgent.cancelReminder(1).then(() => {
console.log("cancelReminder promise");
});
```
......@@ -158,8 +139,9 @@ Obtains all valid (not yet expired) reminders set by the current application. Th
**Example**
```
```js
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);
......@@ -201,8 +183,9 @@ Obtains all valid (not yet expired) reminders set by the current application. Th
**Example**
```
```js
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);
......@@ -244,9 +227,10 @@ Cancels all reminders set by the current application. This API uses an asynchron
**Example**
```
```js
reminderAgent.cancelAllReminders((err, data) =>{
console.log("do next")})
console.log("cancelAllReminders callback")
})
```
......@@ -266,9 +250,10 @@ Cancels all reminders set by the current application. This API uses a promise to
**Example**
```
```js
reminderAgent.cancelAllReminders().then(() => {
console.log("do next")})
console.log("cancelAllReminders promise")
})
```
......@@ -289,17 +274,14 @@ 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");
});
}
```js
let mySlot = {
type: 3,
sound: "/sdcard/music2.mp3"
}
reminderAgent.addNotificationSlot(mySlot, (err, data) => {
console.log("addNotificationSlot callback");
});
```
......@@ -325,17 +307,14 @@ Adds a reminder notification slot. This API uses a promise to return the result.
**Example**
```
export default { data: { mySlot: {
type: 3,
sound: "/sdcard/music2.mp3"
} },
addSlot() {
reminderAgent.addNotificationSlot(this.mySlot).then(() => {
console.log("do next");
});
}
```js
let mySlot = {
type: 3,
sound: "/sdcard/music2.mp3"
}
reminderAgent.addNotificationSlot(mySlot).then(() => {
console.log("addNotificationSlot promise");
});
```
......@@ -356,13 +335,10 @@ 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");
```js
reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION, (err, data) => {
console.log("removeNotificationSlot callback");
});
}
}
```
......@@ -388,13 +364,10 @@ 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");
});
}
}
```js
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);
});
}
```js
let timer = {
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);
});
}
```js
let timer = {
reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER,
triggerTimeInSeconds: 10
}
```
reminderAgent.publishReminder(timer).then((reminderId) => {
console.log("reminderId = " + reminderId);
});
```
## reminderAgent.cancelReminder
......@@ -98,14 +87,10 @@ cancelReminder(reminderId: number, callback: AsyncCallback&lt;void&gt;): void
**示例**
```
export default {
cancel() {
reminderAgent.cancelReminder(1, (err, data) => {
console.log("do next");
});
}
}
```js
reminderAgent.cancelReminder(1, (err, data) => {
console.log("cancelReminder callback");
});
```
......@@ -131,14 +116,10 @@ cancelReminder(reminderId: number): Promise&lt;void&gt;
**示例**
```
export default {
cancel() {
reminderAgent.cancelReminder(1).then(() => {
console.log("do next");
});
}
}
```js
reminderAgent.cancelReminder(1).then(() => {
console.log("cancelReminder promise");
});
```
......@@ -158,8 +139,9 @@ getValidReminders(callback: AsyncCallback&lt;Array&lt;ReminderRequest&gt;&gt;):
**示例**
```
```js
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);
......@@ -201,8 +183,9 @@ getValidReminders(): Promise&lt;Array&lt;ReminderRequest&gt;&gt;
**示例**
```
```js
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);
......@@ -244,9 +227,10 @@ cancelAllReminders(callback: AsyncCallback&lt;void&gt;): void
**示例**
```
```js
reminderAgent.cancelAllReminders((err, data) =>{
console.log("do next")})
console.log("cancelAllReminders callback")
})
```
......@@ -266,9 +250,10 @@ cancelAllReminders(): Promise&lt;void&gt;
**示例**
```
```js
reminderAgent.cancelAllReminders().then(() => {
console.log("do next")})
console.log("cancelAllReminders promise")
})
```
......@@ -289,17 +274,14 @@ 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");
});
}
```js
let mySlot = {
type: 3,
sound: "/sdcard/music2.mp3"
}
reminderAgent.addNotificationSlot(mySlot, (err, data) => {
console.log("addNotificationSlot callback");
});
```
......@@ -325,17 +307,14 @@ 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");
});
}
```js
let mySlot = {
type: 3,
sound: "/sdcard/music2.mp3"
}
reminderAgent.addNotificationSlot(mySlot).then(() => {
console.log("addNotificationSlot promise");
});
```
......@@ -356,13 +335,10 @@ removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback&
**示例**
```
export default {
removeSlot() {reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION, (err, data) => {
console.log("do next");
```js
reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION, (err, data) => {
console.log("removeNotificationSlot callback");
});
}
}
```
......@@ -388,13 +364,10 @@ removeNotificationSlot(slotType: notification.SlotType): Promise&lt;void&gt;
**示例**
```
export default {
removeSlot() { reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION).then(() => {
console.log("do next");
});
}
}
```js
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.
先完成此消息的编辑!
想要评论请 注册