You can set your application to call the **ReminderRequest** class 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, even when your application is frozen or exits.
## Available APIs
**reminderAgent** encapsulates the APIs for publishing and canceling reminders.
For details about the APIs, see [reminderAgent](../reference/apis/js-apis-reminderAgent.md).
**Table 1** Major APIs in reminderAgent
| Name| Description|
| -------- | -------- |
| publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback<number>): void<br>publishReminder(reminderReq: ReminderRequest): Promise<number> | Publishes a scheduled reminder.<br>The maximum number of valid notifications (excluding expired ones that will not pop up again) is 30 for one application and 2000 for the entire system. |
| cancelReminder(reminderId: number, callback: AsyncCallback<void>): void<br>cancelReminder(reminderId: number): Promise<void> | Cancels a specified reminder. (The value of **reminderId** is obtained from the return value of **publishReminder**.)|
| getValidReminders(callback: AsyncCallback<Array<ReminderRequest>>): void<br>getValidReminders(): Promise<Array<ReminderRequest>> | Obtains all valid reminders set by the current application.|
| cancelAllReminders(callback: AsyncCallback<void>): void<br>cancelAllReminders(): Promise<void> | Cancels all reminders set by the current application.|
| addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback<void>): void<br>addNotificationSlot(slot: NotificationSlot): Promise<void> | Registers a **NotificationSlot** instance to be used by the reminder.|
| removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback<void>): void<br>removeNotificationSlot(slotType: notification.SlotType): Promise<void> | Removes a **NotificationSlot** instance of a specified type.|
## How to Develop
> **NOTE**
>
> 1. To publish a reminder through the reminder agent, your application needs to apply for the **ohos.permission.PUBLISH_AGENT_REMINDER** permission.
>
> 2. Your application must have notification enabled. For details, see [Notification.requestEnableNotification](../reference/apis/js-apis-notification.md#notificationrequestenablenotification8).
1. Define a reminder agent.
Sample code for defining a reminder agent for a countdown timer:
Your application can call the **ReminderRequest** class 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, even when your application is frozen or exits.
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**
>
>
...
@@ -33,7 +33,7 @@ Publishes a reminder through the reminder agent. This API uses an asynchronous c
...
@@ -33,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.|
**Example**
**Example**
```js
```js
...
@@ -341,7 +341,7 @@ Removes a notification slot of a specified type. This API uses an asynchronous c
...
@@ -341,7 +341,7 @@ Removes a notification slot of a specified type. This API uses an asynchronous c
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| slotType | [notification.SlotType](js-apis-notification.md#slottype) | Yes| Type of the notification slot to remove.|
| slotType | [notification.SlotType](js-apis-notification.md#slottype) | Yes| Type of the reminder notification slot to remove.|
| callback | AsyncCallback<void> | Yes| Asynchronous callback used to return the result.|
| callback | AsyncCallback<void> | Yes| Asynchronous callback used to return the result.|
**Example**
**Example**
...
@@ -367,7 +367,7 @@ Removes a notification slot of a specified type. This API uses a promise to retu
...
@@ -367,7 +367,7 @@ Removes a notification slot of a specified type. This API uses a promise to retu
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| slotType | [notification.SlotType](js-apis-notification.md#slottype) | Yes| Type of the notification slot to remove.|
| slotType | [notification.SlotType](js-apis-notification.md#slottype) | Yes| Type of the reminder notification slot to remove.|
@@ -431,7 +431,7 @@ Sets the package and ability that are redirected to when the reminder notificati
...
@@ -431,7 +431,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 +443,7 @@ Provides the information about the target package and ability to start automatic
...
@@ -443,7 +443,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 +459,9 @@ Defines the reminder to publish.
...
@@ -459,9 +459,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.|
...
@@ -497,7 +497,7 @@ Defines a reminder for an alarm.
...
@@ -497,7 +497,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**
>
>
...
@@ -31,7 +31,7 @@ Publishes a reminder through the reminder agent. This API uses an asynchronous c
...
@@ -31,7 +31,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**
...
@@ -39,7 +39,7 @@ For details about the error codes, see [reminderAgentManager Error Codes](../err
...
@@ -39,7 +39,7 @@ For details about the error codes, see [reminderAgentManager Error Codes](../err
| ID | Error Message|
| ID | Error Message|
| --------- | ------- |
| --------- | ------- |
| 1700001 | Notification does not enable. |
| 1700001 | Notification is not enabled. |
| 1700002 | The number of reminders exceeds the limit. |
| 1700002 | The number of reminders exceeds the limit. |
**Example**
**Example**
...
@@ -88,7 +88,7 @@ For details about the error codes, see [reminderAgentManager Error Codes](../err
...
@@ -88,7 +88,7 @@ For details about the error codes, see [reminderAgentManager Error Codes](../err
| ID | Error Message|
| ID | Error Message|
| --------- | ------- |
| --------- | ------- |
| 1700001 | Notification does not enable. |
| 1700001 | Notification is not enabled. |
| 1700002 | The number of reminders exceeds the limit. |
| 1700002 | The number of reminders exceeds the limit. |
**Example**
**Example**
...
@@ -131,7 +131,7 @@ For details about the error codes, see [reminderAgentManager Error Codes](../err
...
@@ -131,7 +131,7 @@ For details about the error codes, see [reminderAgentManager Error Codes](../err
| ID | Error Message|
| ID | Error Message|
| --------- | ------- |
| --------- | ------- |
| 1700003 | The reminder does not exist. |
| 1700003 | The reminder does not exist. |
| 1700004 | The package name does not exist. |
| 1700004 | The bundle name does not exist. |
**Example**
**Example**
...
@@ -168,7 +168,7 @@ Cancels the reminder with the specified ID. This API uses a promise to return th
...
@@ -168,7 +168,7 @@ Cancels the reminder with the specified ID. This API uses a promise to return th
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Promise<void> | Promise used to return the result.|
**Error codes**
**Error codes**
...
@@ -177,7 +177,7 @@ For details about the error codes, see [reminderAgentManager Error Codes](../err
...
@@ -177,7 +177,7 @@ For details about the error codes, see [reminderAgentManager Error Codes](../err
@@ -580,7 +580,7 @@ Sets the package and ability that are redirected to when the reminder notificati
...
@@ -580,7 +580,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 +592,7 @@ Provides the information about the target package and ability to start automatic
...
@@ -592,7 +592,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 +608,9 @@ Defines the reminder to publish.
...
@@ -608,9 +608,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.|
...
@@ -646,7 +646,7 @@ Defines a reminder for an alarm.
...
@@ -646,7 +646,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.|
You can set your application to call the **ReminderRequest** class 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, even when your application is frozen or exits.
## Available APIs
**reminderAgentManager** encapsulates the APIs for publishing and canceling reminders.
For details about the APIs, see [reminderAgentManager](../reference/apis/js-apis-reminderAgentManager.md).
**Table 1** Major APIs in reminderAgentManager
| Name| Description|
| -------- | -------- |
| publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback<number>): void<br>publishReminder(reminderReq: ReminderRequest): Promise<number> | Publishes a scheduled reminder.<br>The maximum number of valid notifications (excluding expired ones that will not pop up again) is 30 for one application and 2000 for the entire system. |
| cancelReminder(reminderId: number, callback: AsyncCallback<void>): void<br>cancelReminder(reminderId: number): Promise<void> | Cancels a specified reminder. (The value of **reminderId** is obtained from the return value of **publishReminder**.)|
| getValidReminders(callback: AsyncCallback<Array<ReminderRequest>>): void<br>getValidReminders(): Promise<Array<ReminderRequest>> | Obtains all valid reminders set by the current application.|
| cancelAllReminders(callback: AsyncCallback<void>): void<br>cancelAllReminders(): Promise<void> | Cancels all reminders set by the current application.|
| addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback<void>): void<br>addNotificationSlot(slot: NotificationSlot): Promise<void> | Registers a **NotificationSlot** instance to be used by the reminder.|
| removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback<void>): void<br>removeNotificationSlot(slotType: notification.SlotType): Promise<void> | Removes a **NotificationSlot** instance of a specified type.|
## How to Develop
> **NOTE**
>
> 1. To publish a reminder through the reminder agent, your application must apply for the **ohos.permission.PUBLISH_AGENT_REMINDER** permission.
>2. Your application must have notification enabled. For details, see [Notification.requestEnableNotification](../reference/apis/js-apis-notification.md#notificationrequestenablenotification8).
> 3. The reminder agent can be used only after being authorized by the user.
According to the OpenHarmony background activity specifications, a third-party application will be suspended if it does not execute background tasks after switching to the background. In practice, an application may need to process certain work at specified moments, no matter what state it is in. For example, a shopping application needs to remind users of flash sale activities at some time points. Generally, a timer is used to achieve the preceding scenario. When the timer expires, the system starts the application to execute the task. However, some applications abuse the timer mechanism so they can be frequently waken up when running in the background. To avoid malicious background activities and meet service requirements of applications, OpenHarmony introduces the agent-powered scheduled reminder.
With the agent-powered scheduled reminder, the timing and pop-up notification functions of an application will be taken over by the reminder agent in the background, even when the application is suspended or exits. This prevents an application from being frequently woken up and helps reduce power consumption.
## Notification Instance Types
-**Countdown timers**: Applications can use this type to implement short-time timing notification services.
-**Calendar events**: Applications can use this type to implement long-time notification services.
-**Alarm clocks**: Applications can use this type to implement alarm-related services.
The agent-powered reminder feature provides APIs for publishing background reminders. You can call these APIs to create scheduled reminders for countdown timers, calendar events, and alarm clocks. The APIs are encapsulated in the [reminderAgentManager](../reference/apis/js-apis-reminderAgentManager.md) class.
| publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback<number>): void<br>publishReminder(reminderReq: ReminderRequest): Promise<number> | Publishes a scheduled reminder.<br>The maximum number of valid notifications (excluding expired ones that will not pop up again) is 30 for one application and 2000 for the entire system. |
| cancelReminder(reminderId: number, callback: AsyncCallback<void>): void<br>cancelReminder(reminderId: number): Promise<void> | Cancels a specified reminder. (The value of **reminderId** is obtained from the return value of **publishReminder**.) |
| getValidReminders(callback: AsyncCallback<Array<ReminderRequest>>): void<br>getValidReminders(): Promise<Array<ReminderRequest>> | Obtains all valid reminders set by the current application. |
| cancelAllReminders(callback: AsyncCallback<void>): void<br>cancelAllReminders(): Promise<void> | Cancels all reminders set by the current application. |
| addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback<void>): void<br>addNotificationSlot(slot: NotificationSlot): Promise<void> | Registers a **NotificationSlot** instance to be used by the reminder. |
| removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback<void>): void<br>removeNotificationSlot(slotType: notification.SlotType): Promise<void> | Removes a **NotificationSlot** instance of a specified type. |
## How to Develop
1. Request the **ohos.permission.PUBLISH_AGENT_REMINDER** permission. For details, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
2.[Enable the notification feature](../notification/notification-enable.md).
4. Define a reminder agent. You can define the following types of reminder agents based on project requirements.
- Countdown timer
```js
let targetReminderAgent: reminderAgentManager.ReminderRequestTimer = {
reminderType: reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER, // The reminder type is countdown timer.
triggerTimeInSeconds: 10,
actionButton: [ // Set the button type and title displayed in the reminder notification. The Close and Snooze types are supported, and the Snooze type must be used together with the snoozeTimes and timeInterval parameters.
wantAgent: {// Information about the target UIAbility that is displayed after the reminder notification is touched.
pkgName: 'com.example.myapplication',
abilityName: 'EntryAbility'
},
maxScreenWantAgent: {// Information about the target ability that is automatically started when the specified reminder time arrives is displayed in full screen.
pkgName: 'com.example.myapplication',
abilityName: 'EntryAbility'
},
title:'this is title', // Reminder title.
content:'this is content', // Reminder content.
expiredContent:'this reminder has expired', // Content to be displayed after the reminder expires.
notificationId: 100, // Notification ID used by the reminder. If there are reminders with the same notification ID, the later one will overwrite the earlier one.
slotType: NotificationManager.SlotType.SOCIAL_COMMUNICATION // Type of the slot used by the reminder.
}
```
- Calendar event
```js
let targetReminderAgent: reminderAgentManager.ReminderRequestCalendar = {
reminderType: reminderAgentManager.ReminderType.REMINDER_TYPE_CALENDAR, // The reminder type is calendar event.
dateTime: { // Reminder time.
year: 2023,
month: 7,
day: 30,
hour: 11,
minute: 14,
second: 30
},
repeatMonths: [1], // Month in which the reminder repeats.
repeatDays: [1], // Date on which the reminder repeats.
actionButton: [ // Set the button type and title displayed in the reminder notification. The Close and Snooze types are supported, and the Snooze type must be used together with the snoozeTimes and timeInterval parameters.
wantAgent: {// Information about the target UIAbility that is displayed after the reminder notification is touched.
pkgName: 'com.example.myapplication',
abilityName: 'EntryAbility'
},
maxScreenWantAgent: { // Information about the target UIAbility that is displayed after the reminder notification is touched.
pkgName: 'com.example.myapplication',
abilityName: 'EntryAbility'
},
ringDuration: 5, // Ringing duration, in seconds.
snoozeTimes: 2, // Number of reminder snooze times.
timeInterval: 5, // Reminder snooze interval, in seconds.
title:'this is title', // Reminder title.
content:'this is content', // Reminder content.
expiredContent:'this reminder has expired', // Content to be displayed after the reminder expires.
snoozeContent:'remind later', // Content to be displayed when the reminder is snoozed.
notificationId: 100, // Notification ID used by the reminder. If there are reminders with the same notification ID, the later one will overwrite the earlier one.
slotType: NotificationManager.SlotType.SOCIAL_COMMUNICATION // Type of the slot used by the reminder.
}
```
- Alarm clock
```js
let targetReminderAgent: reminderAgentManager.ReminderRequestAlarm = {
reminderType: reminderAgentManager.ReminderType.REMINDER_TYPE_ALARM, // The reminder type is alarm clock.
hour: 23, // Hour portion of the reminder time.
minute: 9, // Minute portion of the reminder time.
daysOfWeek: [2], // Days of a week when the reminder repeats..
actionButton: [ // Set the button type and title displayed in the reminder notification. The Close and Snooze types are supported, and the Snooze type must be used together with the snoozeTimes and timeInterval parameters.
wantAgent: {// Information about the target UIAbility that is displayed after the reminder notification is touched.
pkgName: 'com.example.myapplication',
abilityName: 'EntryAbility'
},
maxScreenWantAgent: { // Information about the target UIAbility that is displayed after the reminder notification is touched.
pkgName: 'com.example.myapplication',
abilityName: 'EntryAbility'
},
ringDuration: 5, // Ringing duration, in seconds.
snoozeTimes: 2, // Number of reminder snooze times.
timeInterval: 5, // Reminder snooze interval, in seconds.
title:'this is title', // Reminder title.
content:'this is content', // Reminder content.
expiredContent:'this reminder has expired', // Content to be displayed after the reminder expires.
snoozeContent:'remind later', // Content to be displayed when the reminder is snoozed.
notificationId: 99, // Notification ID used by the reminder. If there are reminders with the same notification ID, the later one will overwrite the earlier one.
slotType: NotificationManager.SlotType.SOCIAL_COMMUNICATION // Type of the slot used by the reminder.
}
```
5. Publish the reminder agent. After the agent is published, your application can use the agent-powered reminder feature.
6. To delete a reminder task, call [reminderAgentManager.cancelReminder()](../reference/apis/js-apis-reminderAgentManager.md#reminderagentmanagercancelreminder).
```js
letreminderId=0;// The reminderId is obtained from the callback after the agent is published.
To deliver a better user experience, OpenHarmony manages background application processes in a more orderly manner. Applications cannot reside in the background randomly, and their background behavior is strictly managed to minimize malicious behavior. However, for some applications that are running in the background or have exited, notifications may need to be sent at a specified time. For example, a shopping application wants to remind users of flash sale activities at some time points. To meet these service requirements, OpenHarmony provides the agent-powered redminder feature. After an application switches to the background or exits, their timing and pop-up notification functions are taken over by the background agent.
OpenHarmony provides the following types of background agents:
- Countdown timers: Applications can use this type to implement short-time timing notification services.
- Calendar events: Applications can use this type to implement long-time notification services.
- Alarm clocks: Applications can use this type to implement alarm-related services.