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.
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 methods for publishing and canceling reminders.
| function publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback\<number>): void;<br>function 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. |
| function cancelReminder(reminderId: number, callback: AsyncCallback\<void>): void;<br/>function cancelReminder(reminderId: number): Promise\<void>; | Cancels a specified reminder. (The value of **reminderId** is obtained from the return value of **publishReminder**.) |
| function getValidReminders(callback: AsyncCallback<Array\<ReminderRequest>>): void;<br/>function getValidReminders(): Promise<Array\<ReminderRequest>>; | Obtains all valid reminders set by the current application. |
| function cancelAllReminders(callback: AsyncCallback\<void>): void;<br/>function cancelAllReminders(): Promise\<void>; | Cancels all reminders set by the current application. |
| function addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback\<void>): void;<br/>function addNotificationSlot(slot: NotificationSlot): Promise<void>; | Registers a NotificationSlot instance to be used by the reminder. |
| function removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback\<void>): void;function removeNotificationSlot(slotType: notification.SlotType): Promise\<void>; | Removes a NotificationSlot instance of a specified type. |
**ActionButtonType** enumerates types of buttons displayed in a reminder notification.
| ACTION_BUTTON_TYPE_CLOSE | Close button, which can be tapped to stop the reminder alert tone, close the reminder notification, and cancel the reminder snoozing. |
**ReminderType** enumerates the reminder types.
**Table 3** ReminderType enumeration
| Name | Description |
| ---------------------- | ------------------- |
| REMINDER_TYPE_TIMER | Countdown reminder. |
| REMINDER_TYPE_CALENDAR | Calendar reminder. |
| REMINDER_TYPE_ALARM | Alarm reminder. |
**ActionButton** defines a button displayed in the reminder notification.
| pkgName | string | Yes | Name of the package redirected to when the reminder notification is clicked. |
| abilityName | string | Yes | Name of the ability redirected to when the reminder notification is clicked. |
**MaxScreenWantAgent** sets the name of the target package and ability to start automatically when the reminder arrives and the device is not in use. If the device is in use, a notification will be displayed.
| reminderType | ReminderType | Yes | Type of the reminder. |
| actionButton | [ActionButton?, ActionButton?] | No | Action button displayed in the reminder notification. |
| wantAgent | WantAgent | No | Information about the ability that is redirected to when the notification is clicked. |
| 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 | Ring duration. |
| snoozeTimes | number | No | Number of reminder snooze times. |
| timeInterval | number | No | Reminder snooze interval. |
| title | string | No | Reminder title. |
| content | string | No | Reminder content. |
| expiredContent | string | No | Extended content to be displayed when the reminder expires. |
| snoozeContent | string | No | Extended content to be displayed when the reminder is snoozing. |
| notificationId | number | No | Notification ID used by the reminder. For details, see the API reference of the **NotificationRequest.setNotificationId(int id)** method. |
| slotType | SlotType | No | Type of the slot used by the reminder. |
**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.
| triggerTimeInSeconds | number | Yes | Number of seconds in the countdown timer. |
**LocalDateTime** defines a **LocalDateTime** instance.
**Table 11** LocalDateTime instance
**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 | Type | Mandatory | Description |
| Name| Description|
| ------ | ------ | --------- | ----------- |
| -------- | -------- |
| year | number | Yes | Year. |
| 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. |
| month | number | Yes | Month. |
| 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**.)|
| day | number | Yes | Date. |
| getValidReminders(callback: AsyncCallback<Array<ReminderRequest>>): void<br>getValidReminders(): Promise<Array<ReminderRequest>> | Obtains all valid reminders set by the current application.|
| hour | number | Yes | Hour. |
| cancelAllReminders(callback: AsyncCallback<void>): void<br>cancelAllReminders(): Promise<void> | Cancels all reminders set by the current application.|
| minute | number | Yes | Minute. |
| addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback<void>): void<br>addNotificationSlot(slot: NotificationSlot): Promise<void> | Registers a **NotificationSlot** instance to be used by the reminder.|
| second | number | No | Second. |
| 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
## How to Develop
> **NOTE**
> **NOTE**
> To publish a reminder, your application needs to apply for the **ohos.permission.PUBLISH_AGENT_REMINDER** permission.
>
> 1. To publish a reminder through the reminder agent, your application needs to apply for the **ohos.permission.PUBLISH_AGENT_REMINDER** permission.
Publish a 10-second countdown reminder.
>
> 2. Your application must have notification enabled. For details, see [Notification.requestEnableNotification](../reference/apis/js-apis-notification.md#notificationrequestenablenotification8).
1. Define a countdown timer instance.
1. Define a reminder agent.
```
Sample code for defining a reminder agent for a countdown timer:
Publishes an agent-powered reminder. This API uses an asynchronous callback to return the result.
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](../reference/apis/js-apis-notification.md#notificationrequestenablenotification8).
Publishes an agent-powered reminder. This API uses a promise callback to return the result.
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](../reference/apis/js-apis-notification.md#notificationrequestenablenotification8).
@@ -435,7 +435,7 @@ Sets the package and ability that are redirected to when the reminder notificati
...
@@ -435,7 +435,7 @@ Sets the package and ability that are redirected to when the reminder notificati
## MaxScreenWantAgent
## MaxScreenWantAgent
Sets the name of the target package and ability to start automatically when the reminder arrives and the device is not in use. If the device is in use, a notification will be displayed.
Provides the information about the target package and ability to start automatically when the reminder is displayed in full-screen mode. This API is reserved.
@@ -454,7 +454,7 @@ Defines the reminder to publish.
...
@@ -454,7 +454,7 @@ Defines the reminder to publish.
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| reminderType | ReminderType | Yes| Type of the reminder.|
| reminderType | ReminderType | Yes| Type of the reminder.|
| actionButton | [ActionButton?, ActionButton?] | No| Action 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 | No| Information about the ability that is redirected to when the notification is clicked.|
| wantAgent | WantAgent | No| Information about the ability that is redirected to when the notification is clicked.|
| 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 | No| Information about the ability that is automatically started when the reminder arrives. If the device is in use, a notification will be displayed.|
| onSubmit(callback: (value: string) => void) | Triggered when users click the search icon or the search button, or tap the search button on a soft keyboard.<br> - **value**: current text input. |
| onSubmit(callback: (value: string) => void) | Triggered when users click the search icon or the search button, or touch the search button on a soft keyboard.<br> -**value**: current text input.|
| onChange(callback: (value: string) => void) | Triggered when the input in the text box changes.<br> -**value**: current text input. |
| onChange(callback: (value: string) => void) | Triggered when the input in the text box changes.<br> -**value**: current text input. |
| onCopy(callback: (value: string) => void) | Triggered when data is copied to the pasteboard.<br> -**value**: text copied. |
| onCopy(callback: (value: string) => void) | Triggered when data is copied to the pasteboard.<br> -**value**: text copied. |
| onCut(callback: (value: string) => void) | Triggered when data is cut from the pasteboard.<br> -**value**: text cut. |
| onCut(callback: (value: string) => void) | Triggered when data is cut from the pasteboard.<br> -**value**: text cut. |
| onPaste(callback: (value: string) => void) | Triggered when data is pasted from the pasteboard.<br> -**value**: text pasted. |
| onPaste(callback: (value: string) => void) | Triggered when data is pasted from the pasteboard.<br> -**value**: text pasted. |
## SearchController
## SearchController
...
@@ -63,9 +64,9 @@ Sets the position of the caret.
...
@@ -63,9 +64,9 @@ Sets the position of the caret.
- Parameters
- Parameters
| Name | Type | Mandatory | Default Value | Description |
| Name | Type | Mandatory | Default Value | Description |
Moves the current point of the path back to the start point of the path, and draws a straight line between the current point and the start point. If the shape has already been closed or has only one point, this method does nothing.
Moves the current point of the path back to the start point of the path, and draws a straight line between the current point and the start point. If the shape has already been closed or has only one point, this method does nothing.
- Example
**Example**
```
```ts
@Entry
// xxx.ets
@Component
@Entry
struct ClosePath {
@Component
private settings: RenderingContextSettings = new RenderingContextSettings(true)
structClosePath{
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
| y | number | Yes | 0 | Y-coordinate of the ellipse center. |
| x | number | Yes | 0 | X-coordinate of the ellipse center. |
| radiusX | number | Yes | 0 | Ellipse radius on the x-axis. |
| y | number | Yes | 0 | Y-coordinate of the ellipse center. |
| radiusY | number | Yes | 0 | Ellipse radius on the y-axis. |
| radiusX | number | Yes | 0 | Ellipse radius on the x-axis. |
| rotation | number | Yes | 0 | Rotation angle of the ellipse, in radians. |
| radiusY | number | Yes | 0 | Ellipse radius on the y-axis. |
| startAngle | number | Yes | 0 | Angle of the start point for drawing the ellipse, in radians. |
| rotation | number | Yes | 0 | Rotation angle of the ellipse, in radians. |
| endAngle | number | Yes | 0 | Angle of the end point for drawing the ellipse, in radians. |
| startAngle | number | Yes | 0 | Angle of the start point for drawing the ellipse, in radians. |
| anticlockwise | number | No | 0 | Whether to draw the ellipse in the counterclockwise direction. The value **0** means to draw the ellipse in the clockwise direction, and **1** means to draw the ellipse in the counterclockwise direction. This parameter is optional. The default value is **0**. |
| endAngle | number | Yes | 0 | Angle of the end point for drawing the ellipse, in radians. |
| anticlockwise | number | No | 0 | Whether to draw the ellipse in the counterclockwise direction. The value **0** means to draw the ellipse in the clockwise direction, and **1** means to draw the ellipse in the counterclockwise direction. This parameter is optional. The default value is **0**. |
- Example
**Example**
```
```ts
// xxx.ets
@Entry
@Entry
@Component
@Component
structCanvasExample{
structCanvasExample{
...
@@ -407,7 +424,7 @@ Draws an ellipse in the specified rectangular region.
...
@@ -407,7 +424,7 @@ Draws an ellipse in the specified rectangular region.