The **reminderAgent** module provides APIs for publishing scheduled reminders through the reminder agent.
The **reminderAgent** module provides APIs for publishing scheduled reminders through the reminder agent.
You can set your application to use the reminder agent APIs to create scheduled reminders for countdown timers, calendar events, and alarm clocks. When the created reminders are published, the timing and pop-up notification functions of your application will be taken over by the reminder agent in the background when your application is frozen or exits.
You can use the APIs to create scheduled reminders for countdown timers, calendar events, and alarm clocks. When the created reminders are published, the timing and pop-up notification functions of your application will be taken over by the reminder agent in the background when your application is frozen or exits.
> **NOTE**
> **NOTE**
>
>
...
@@ -13,14 +13,16 @@ You can set your application to use the reminder agent APIs to create scheduled
...
@@ -13,14 +13,16 @@ You can set your application to use the reminder agent APIs to create scheduled
Publishes a reminder through the reminder agent. This API uses an asynchronous callback to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8).
Publishes a reminder through the reminder agent. This API uses an asynchronous callback to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8).
...
@@ -33,14 +35,15 @@ Publishes a reminder through the reminder agent. This API uses an asynchronous c
...
@@ -33,14 +35,15 @@ Publishes a reminder through the reminder agent. This API uses an asynchronous c
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| reminderReq | [ReminderRequest](#reminderrequest) | Yes| Reminder to be published.|
| reminderReq | [ReminderRequest](#reminderrequest) | Yes| Reminder to be published.|
| callback | AsyncCallback<number> | Yes| Asynchronous callback used to return the published reminder's ID.|
| callback | AsyncCallback\<number\> | Yes| Callback used to return the published reminder's ID.|
Publishes a reminder through the reminder agent. This API uses a promise to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8).
Publishes a reminder through the reminder agent. This API uses a promise to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8).
...
@@ -65,14 +70,15 @@ Publishes a reminder through the reminder agent. This API uses a promise to retu
...
@@ -65,14 +70,15 @@ Publishes a reminder through the reminder agent. This API uses a promise to retu
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<number> | Promise used to return the published reminder's ID.|
| Promise\<number\> | Promise used to return the published reminder's ID.|
Obtains all valid (not yet expired) reminders set by the current application. This API uses an asynchronous callback to return the reminders.
Obtains all valid (not yet expired) reminders set by the current application. This API uses an asynchronous callback to return the reminders.
...
@@ -144,11 +155,11 @@ Obtains all valid (not yet expired) reminders set by the current application. Th
...
@@ -144,11 +155,11 @@ Obtains all valid (not yet expired) reminders set by the current application. Th
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<Array<[ReminderRequest](#reminderrequest)>> | Yes| Asynchronous callback used to return an array of all valid reminders set by the current application.|
| callback | AsyncCallback\<Array\<[ReminderRequest](#reminderrequest)\>\> | Yes| Asynchronous callback used to return an array of all valid reminders set by the current application.|
Obtains all valid (not yet expired) reminders set by the current application. This API uses a promise to return the reminders.
Obtains all valid (not yet expired) reminders set by the current application. This API uses a promise to return the reminders.
...
@@ -188,11 +201,11 @@ Obtains all valid (not yet expired) reminders set by the current application. Th
...
@@ -188,11 +201,11 @@ Obtains all valid (not yet expired) reminders set by the current application. Th
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<Array<[ReminderRequest](#reminderrequest)>> | Promise used to return an array of all valid reminders set by the current application.|
| Promise\<Array\<[ReminderRequest](#reminderrequest)\>\> | Promise used to return an array of all valid reminders set by the current application.|
@@ -431,7 +455,7 @@ Sets the package and ability that are redirected to when the reminder notificati
...
@@ -431,7 +455,7 @@ Sets the package and ability that are redirected to when the reminder notificati
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| pkgName | string | Yes| Name of the package that is redirected to when the reminder notification is clicked.|
| pkgName | string | Yes| Name of the HAP that is redirected to when the reminder notification is clicked.|
| abilityName | string | Yes| Name of the ability that is redirected to when the reminder notification is clicked.|
| abilityName | string | Yes| Name of the ability that is redirected to when the reminder notification is clicked.|
...
@@ -443,7 +467,7 @@ Provides the information about the target package and ability to start automatic
...
@@ -443,7 +467,7 @@ Provides the information about the target package and ability to start automatic
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| pkgName | string | Yes| Name of the package that is automatically started when the reminder arrives and the device is not in use.|
| pkgName | string | Yes| Name of the HAP that is automatically started when the reminder arrives and the device is not in use.|
| abilityName | string | Yes| Name of the ability that is automatically started when the reminder arrives and the device is not in use.|
| abilityName | string | Yes| Name of the ability that is automatically started when the reminder arrives and the device is not in use.|
...
@@ -459,9 +483,9 @@ Defines the reminder to publish.
...
@@ -459,9 +483,9 @@ Defines the reminder to publish.
| actionButton | [ActionButton](#actionbutton) | No| Button displayed in the reminder notification. (The parameter is optional. Up to two buttons are supported.)|
| actionButton | [ActionButton](#actionbutton) | No| Button displayed in the reminder notification. (The parameter is optional. Up to two buttons are supported.)|
| wantAgent | [WantAgent](#wantagent) | No| Information about the ability that is redirected to when the notification is clicked.|
| wantAgent | [WantAgent](#wantagent) | No| Information about the ability that is redirected to when the notification is clicked.|
| maxScreenWantAgent | [MaxScreenWantAgent](#maxscreenwantagent) | No| Information about the ability that is automatically started when the reminder arrives. If the device is in use, a notification will be displayed.|
| maxScreenWantAgent | [MaxScreenWantAgent](#maxscreenwantagent) | No| Information about the ability that is automatically started when the reminder arrives. If the device is in use, a notification will be displayed.|
| ringDuration | number | No| Ringing duration.|
| ringDuration | number | No| Ringing duration, in seconds. The default value is **1**.|
| snoozeTimes | number | No| Number of reminder snooze times.|
| snoozeTimes | number | No| Number of reminder snooze times. The default value is **0**.|
| timeInterval | number | No| Reminder snooze interval.|
| timeInterval | number | No| Reminder snooze interval, in seconds. The default value is **0**.|
| title | string | No| Reminder title.|
| title | string | No| Reminder title.|
| content | string | No| Reminder content.|
| content | string | No| Reminder content.|
| expiredContent | string | No| Content to be displayed after the reminder expires.|
| expiredContent | string | No| Content to be displayed after the reminder expires.|
...
@@ -481,8 +505,8 @@ Defines a reminder for a calendar event.
...
@@ -481,8 +505,8 @@ Defines a reminder for a calendar event.
| repeatMonths | Array<number> | No| Month in which the reminder repeats.|
| repeatMonths | Array\<number\> | No| Month in which the reminder repeats.|
| repeatDays | Array<number> | No| Date on which the reminder repeats.|
| repeatDays | Array\<number\> | No| Date on which the reminder repeats.|
## ReminderRequestAlarm
## ReminderRequestAlarm
...
@@ -497,7 +521,7 @@ Defines a reminder for an alarm.
...
@@ -497,7 +521,7 @@ Defines a reminder for an alarm.
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| hour | number | Yes| Hour portion of the reminder time.|
| hour | number | Yes| Hour portion of the reminder time.|
| minute | number | Yes| Minute portion of the reminder time.|
| minute | number | Yes| Minute portion of the reminder time.|
| daysOfWeek | Array<number> | No| Days of a week when the reminder repeats.|
| daysOfWeek | Array\<number\> | No| Days of a week when the reminder repeats. The value ranges from 1 to 7, corresponding to the data from Monday to Sunday.|
The **reminderAgentManager** module provides APIs for publishing scheduled reminders through the reminder agent.
The **reminderAgentManager** module provides APIs for publishing scheduled reminders through the reminder agent.
You can set your application to use the reminder agent APIs to create scheduled reminders for countdown timers, calendar events, and alarm clocks. When the created reminders are published, the timing and pop-up notification functions of your application will be taken over by the reminder agent in the background when your application is frozen or exits.
You can use the APIs to create scheduled reminders for countdown timers, calendar events, and alarm clocks. When the created reminders are published, the timing and pop-up notification functions of your application will be taken over by the reminder agent in the background when your application is frozen or exits.
> **NOTE**
> **NOTE**
>
>
...
@@ -11,14 +11,16 @@ You can set your application to use the reminder agent APIs to create scheduled
...
@@ -11,14 +11,16 @@ You can set your application to use the reminder agent APIs to create scheduled
Publishes a reminder through the reminder agent. This API uses an asynchronous callback to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8).
Publishes a reminder through the reminder agent. This API uses an asynchronous callback to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8).
...
@@ -31,7 +33,7 @@ Publishes a reminder through the reminder agent. This API uses an asynchronous c
...
@@ -31,7 +33,7 @@ Publishes a reminder through the reminder agent. This API uses an asynchronous c
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| reminderReq | [ReminderRequest](#reminderrequest) | Yes| Reminder to be published.|
| reminderReq | [ReminderRequest](#reminderrequest) | Yes| Reminder to be published.|
| callback | AsyncCallback<number> | Yes| Asynchronous callback used to return the published reminder's ID.|
| callback | AsyncCallback\<number\> | Yes| Callback used to return the published reminder's ID.|
**Error codes**
**Error codes**
...
@@ -43,11 +45,12 @@ For details about the error codes, see [reminderAgentManager Error Codes](../err
...
@@ -43,11 +45,12 @@ For details about the error codes, see [reminderAgentManager Error Codes](../err
| 1700002 | The number of reminders exceeds the limit. |
| 1700002 | The number of reminders exceeds the limit. |
Publishes a reminder through the reminder agent. This API uses a promise to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8).
Publishes a reminder through the reminder agent. This API uses a promise to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8).
...
@@ -80,7 +85,7 @@ Publishes a reminder through the reminder agent. This API uses a promise to retu
...
@@ -80,7 +85,7 @@ Publishes a reminder through the reminder agent. This API uses a promise to retu
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<number> | Promise used to return the published reminder's ID.|
| Promise\<number\> | Promise used to return the published reminder's ID.|
**Error codes**
**Error codes**
...
@@ -92,11 +97,12 @@ For details about the error codes, see [reminderAgentManager Error Codes](../err
...
@@ -92,11 +97,12 @@ For details about the error codes, see [reminderAgentManager Error Codes](../err
| 1700002 | The number of reminders exceeds the limit. |
| 1700002 | The number of reminders exceeds the limit. |
Obtains all valid (not yet expired) reminders set by the current application. This API uses an asynchronous callback to return the reminders.
Obtains all valid (not yet expired) reminders set by the current application. This API uses an asynchronous callback to return the reminders.
...
@@ -206,7 +218,7 @@ Obtains all valid (not yet expired) reminders set by the current application. Th
...
@@ -206,7 +218,7 @@ Obtains all valid (not yet expired) reminders set by the current application. Th
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<Array<[ReminderRequest](#reminderrequest)>> | Yes| Asynchronous callback used to return an array of all valid reminders set by the current application.|
| callback | AsyncCallback\<Array\<[ReminderRequest](#reminderrequest)\>\> | Yes| Asynchronous callback used to return an array of all valid reminders set by the current application.|
**Error codes**
**Error codes**
...
@@ -218,7 +230,7 @@ For details about the error codes, see [reminderAgentManager Error Codes](../err
...
@@ -218,7 +230,7 @@ For details about the error codes, see [reminderAgentManager Error Codes](../err
Obtains all valid (not yet expired) reminders set by the current application. This API uses a promise to return the reminders.
Obtains all valid (not yet expired) reminders set by the current application. This API uses a promise to return the reminders.
...
@@ -266,7 +279,7 @@ Obtains all valid (not yet expired) reminders set by the current application. Th
...
@@ -266,7 +279,7 @@ Obtains all valid (not yet expired) reminders set by the current application. Th
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<Array<[ReminderRequest](#reminderrequest)>> | Promise used to return an array of all valid reminders set by the current application.|
| Promise\<Array\<[ReminderRequest](#reminderrequest)\>\> | Promise used to return an array of all valid reminders set by the current application.|
**Error codes**
**Error codes**
...
@@ -278,7 +291,7 @@ For details about the error codes, see [reminderAgentManager Error Codes](../err
...
@@ -278,7 +291,7 @@ For details about the error codes, see [reminderAgentManager Error Codes](../err
Removes a notification slot of a specified type. This API uses a promise to return the result.
Removes a notification slot of a specified type. This API uses a promise to return the result.
...
@@ -517,11 +542,11 @@ Removes a notification slot of a specified type. This API uses a promise to retu
...
@@ -517,11 +542,11 @@ Removes a notification slot of a specified type. This API uses a promise to retu
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Promise\<void\> | Promise used to return the result.|
**Example**
**Example**
```js
```ts
importnotificationfrom'@ohos.notification'
importnotificationfrom'@ohos.notification'
try{
try{
...
@@ -580,7 +605,7 @@ Sets the package and ability that are redirected to when the reminder notificati
...
@@ -580,7 +605,7 @@ Sets the package and ability that are redirected to when the reminder notificati
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| pkgName | string | Yes| Name of the package that is redirected to when the reminder notification is clicked.|
| pkgName | string | Yes| Name of the HAP that is redirected to when the reminder notification is clicked.|
| abilityName | string | Yes| Name of the ability that is redirected to when the reminder notification is clicked.|
| abilityName | string | Yes| Name of the ability that is redirected to when the reminder notification is clicked.|
...
@@ -592,7 +617,7 @@ Provides the information about the target package and ability to start automatic
...
@@ -592,7 +617,7 @@ Provides the information about the target package and ability to start automatic
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| pkgName | string | Yes| Name of the package that is automatically started when the reminder arrives and the device is not in use.|
| pkgName | string | Yes| Name of the HAP that is automatically started when the reminder arrives and the device is not in use.|
| abilityName | string | Yes| Name of the ability that is automatically started when the reminder arrives and the device is not in use.|
| abilityName | string | Yes| Name of the ability that is automatically started when the reminder arrives and the device is not in use.|
...
@@ -608,9 +633,9 @@ Defines the reminder to publish.
...
@@ -608,9 +633,9 @@ Defines the reminder to publish.
| actionButton | [ActionButton](#actionbutton) | No| Button displayed in the reminder notification. (The parameter is optional. Up to two buttons are supported.)|
| actionButton | [ActionButton](#actionbutton) | No| Button displayed in the reminder notification. (The parameter is optional. Up to two buttons are supported.)|
| wantAgent | [WantAgent](#wantagent) | No| Information about the ability that is redirected to when the notification is clicked.|
| wantAgent | [WantAgent](#wantagent) | No| Information about the ability that is redirected to when the notification is clicked.|
| maxScreenWantAgent | [MaxScreenWantAgent](#maxscreenwantagent) | No| Information about the ability that is automatically started when the reminder arrives. If the device is in use, a notification will be displayed.|
| maxScreenWantAgent | [MaxScreenWantAgent](#maxscreenwantagent) | No| Information about the ability that is automatically started when the reminder arrives. If the device is in use, a notification will be displayed.|
| ringDuration | number | No| Ringing duration, in seconds.|
| ringDuration | number | No| Ringing duration, in seconds. The default value is **1**.|
| snoozeTimes | number | No| Number of reminder snooze times.|
| snoozeTimes | number | No| Number of reminder snooze times. The default value is **0**.|
| timeInterval | number | No| Reminder snooze interval, in seconds.|
| timeInterval | number | No| Reminder snooze interval, in seconds. The default value is **0**.|
| title | string | No| Reminder title.|
| title | string | No| Reminder title.|
| content | string | No| Reminder content.|
| content | string | No| Reminder content.|
| expiredContent | string | No| Content to be displayed after the reminder expires.|
| expiredContent | string | No| Content to be displayed after the reminder expires.|
...
@@ -630,8 +655,8 @@ Defines a reminder for a calendar event.
...
@@ -630,8 +655,8 @@ Defines a reminder for a calendar event.
| repeatMonths | Array<number> | No| Month in which the reminder repeats.|
| repeatMonths | Array\<number\> | No| Month in which the reminder repeats.|
| repeatDays | Array<number> | No| Date on which the reminder repeats.|
| repeatDays | Array\<number\> | No| Date on which the reminder repeats.|
## ReminderRequestAlarm
## ReminderRequestAlarm
...
@@ -646,7 +671,7 @@ Defines a reminder for an alarm.
...
@@ -646,7 +671,7 @@ Defines a reminder for an alarm.
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| hour | number | Yes| Hour portion of the reminder time.|
| hour | number | Yes| Hour portion of the reminder time.|
| minute | number | Yes| Minute portion of the reminder time.|
| minute | number | Yes| Minute portion of the reminder time.|
| daysOfWeek | Array<number> | No| Days of a week when the reminder repeats. The value ranges from 1 to 7, corresponding to the data from Monday to Sunday.|
| daysOfWeek | Array\<number\> | No| Days of a week when the reminder repeats. The value ranges from 1 to 7, corresponding to the data from Monday to Sunday.|