• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.reminderAgentManager (Agent-Powered Reminders)
2
3The reminderAgentManager module provides APIs related to agent-powered reminders. When your application is frozen or exits, the timing and notification functions of your application will be taken over by a system service running in the background. You can use the APIs to create scheduled reminders for countdown timers, calendar events, and alarm clocks.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8
9
10## Modules to Import
11
12```ts
13import { reminderAgentManager } from '@kit.BackgroundTasksKit';
14```
15
16## reminderAgentManager.publishReminder
17
18publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback\<number>): void
19
20Publishes a reminder. This API uses an asynchronous callback to return the result.
21
22If the value of [ReminderRequest.ringDuration](#reminderrequest) is greater than 0, the custom ringtone is played on the alarm channel by default. If the value is less than or equal to 0, no ringtone is played.
23
24> **NOTE**
25>
26> This API can be called only after the [NotificationManager.requestEnableNotification](../apis-notification-kit/js-apis-notificationManager.md#notificationmanagerrequestenablenotification10) permission is obtained.
27>
28> <!--RP1--><!--RP1End-->
29
30**Required permissions**: ohos.permission.PUBLISH_AGENT_REMINDER
31
32**System capability**: SystemCapability.Notification.ReminderAgent
33
34**Parameters**
35
36  | Name| Type| Mandatory| Description|
37  | -------- | -------- | -------- | -------- |
38  | reminderReq | [ReminderRequest](#reminderrequest) | Yes| Request used for publishing the reminder.|
39  | callback | AsyncCallback\<number> | Yes| Callback used to return the published reminder's ID.|
40
41**Error codes**
42
43For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md).
44
45| ID  | Error Message|
46| --------- | ------- |
47| 401 | If the input parameter is not valid parameter. |
48| 1700001    | Notification is not enabled. |
49| 1700002    | The number of reminders exceeds the limit. |
50
51**Example**
52```ts
53import { BusinessError } from '@kit.BasicServicesKit';
54
55let timer: reminderAgentManager.ReminderRequestTimer = {
56  reminderType: reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER,
57  triggerTimeInSeconds: 10
58}
59
60reminderAgentManager.publishReminder(timer, (err: BusinessError, reminderId: number) => {
61  if (err.code) {
62    console.error("callback err code:" + err.code + " message:" + err.message);
63  } else {
64    console.log("callback, reminderId = " + reminderId);
65  }
66});
67```
68
69## reminderAgentManager.publishReminder
70
71publishReminder(reminderReq: ReminderRequest): Promise\<number>
72
73Publishes a reminder. This API uses a promise to return the result.
74
75If the value of [ReminderRequest.ringDuration](#reminderrequest) is greater than 0, the custom ringtone is played on the alarm channel by default. If the value is less than or equal to 0, no ringtone is played.
76
77> **NOTE**
78>
79> This API can be called only after the [NotificationManager.requestEnableNotification](../apis-notification-kit/js-apis-notificationManager.md#notificationmanagerrequestenablenotification10) permission is obtained.
80>
81> <!--RP1--><!--RP1End-->
82
83**Required permissions**: ohos.permission.PUBLISH_AGENT_REMINDER
84
85**System capability**: SystemCapability.Notification.ReminderAgent
86
87**Parameters**
88
89  | Name| Type| Mandatory| Description|
90  | -------- | -------- | -------- | -------- |
91  | reminderReq | [ReminderRequest](#reminderrequest) | Yes| Request used for publishing the reminder.|
92
93**Return value**
94
95| Type| Description|
96| -------- | -------- |
97| Promise\<number> | Promise used to return the published reminder ID.|
98
99**Error codes**
100
101For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md).
102
103| ID  | Error Message|
104| --------- | ------- |
105| 401 | If the input parameter is not valid parameter. |
106| 1700001    | Notification is not enabled. |
107| 1700002    | The number of reminders exceeds the limit. |
108
109**Example**
110```ts
111import { BusinessError } from '@kit.BasicServicesKit';
112
113let timer: reminderAgentManager.ReminderRequestTimer = {
114  reminderType: reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER,
115  triggerTimeInSeconds: 10
116}
117
118reminderAgentManager.publishReminder(timer).then((reminderId: number) => {
119  console.log("promise, reminderId = " + reminderId);
120}).catch((err: BusinessError) => {
121  console.error("promise err code:" + err.code + " message:" + err.message);
122});
123```
124
125
126## reminderAgentManager.cancelReminder
127
128cancelReminder(reminderId: number, callback: AsyncCallback\<void>): void
129
130Cancels a reminder published. This API uses an asynchronous callback to return the result.
131
132**System capability**: SystemCapability.Notification.ReminderAgent
133
134**Parameters**
135
136| Name| Type| Mandatory| Description|
137| -------- | -------- | -------- | -------- |
138| reminderId | number | Yes| ID of the reminder to cancel.|
139| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the reminder is canceled, **err** is **undefined**. Otherwise, **err** is an error object.|
140
141**Error codes**
142
143For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md).
144
145| ID  | Error Message|
146| --------- | ------- |
147| 401 | If the input parameter is not valid parameter. |
148| 1700003    | The reminder does not exist. |
149| 1700004    | The bundle name does not exist. |
150
151**Example**
152
153```ts
154import { BusinessError } from '@kit.BasicServicesKit';
155
156let reminderId: number = 1;
157reminderAgentManager.cancelReminder(reminderId, (err: BusinessError) => {
158  if (err.code) {
159    console.error("callback err code:" + err.code + " message:" + err.message);
160  } else {
161    console.log("cancelReminder callback");
162  }
163});
164```
165
166## reminderAgentManager.cancelReminder
167
168cancelReminder(reminderId: number): Promise\<void>
169
170Cancels a reminder published. This API uses a promise to return the result.
171
172**System capability**: SystemCapability.Notification.ReminderAgent
173
174**Parameters**
175
176| Name| Type| Mandatory| Description|
177| -------- | -------- | -------- | -------- |
178| reminderId | number | Yes| ID of the reminder to cancel.|
179
180**Return value**
181
182| Type| Description|
183| -------- | -------- |
184| Promise\<void> | Promise that returns no value.|
185
186**Error codes**
187
188For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md).
189
190| ID  | Error Message|
191| --------- | ------- |
192| 401 | If the input parameter is not valid parameter. |
193| 1700003    | The reminder does not exist. |
194| 1700004    | The bundle name does not exist. |
195
196**Example**
197
198```ts
199import { BusinessError } from '@kit.BasicServicesKit';
200
201let reminderId: number = 1;
202reminderAgentManager.cancelReminder(reminderId).then(() => {
203  console.log("cancelReminder promise");
204}).catch((err: BusinessError) => {
205  console.error("promise err code:" + err.code + " message:" + err.message);
206});
207```
208
209## reminderAgentManager.getValidReminders
210
211getValidReminders(callback: AsyncCallback<Array\<ReminderRequest>>): void
212
213Obtains all [valid (not yet expired) reminders](../../task-management/agent-powered-reminder.md#constraints) set by the current application. This API uses an asynchronous callback to return the result.
214
215**System capability**: SystemCapability.Notification.ReminderAgent
216
217**Parameters**
218
219| Name| Type| Mandatory| Description|
220| -------- | -------- | -------- | -------- |
221| callback | AsyncCallback\<Array\<[ReminderRequest](#reminderrequest)>> | Yes| Callback used to return all the valid reminders.|
222
223**Error codes**
224
225For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md).
226
227| ID  | Error Message|
228| --------- | ------- |
229| 401 | If the input parameter is not valid parameter. |
230| 1700004    | The bundle name does not exist. |
231
232**Example**
233
234```ts
235import { BusinessError } from '@kit.BasicServicesKit';
236
237reminderAgentManager.getValidReminders((err: BusinessError, reminders: Array<reminderAgentManager.ReminderRequest>) => {
238  if (err.code) {
239    console.error("callback err code:" + err.code + " message:" + err.message);
240  } else {
241    console.log("callback, getValidReminders length = " + reminders.length);
242    for (let i = 0; i < reminders.length; i++) {
243      console.log("getValidReminders = " + reminders[i]);
244      console.log("getValidReminders, reminderType = " + reminders[i].reminderType);
245      const actionButton = reminders[i].actionButton || [];
246      for (let j = 0; j < actionButton.length; j++) {
247        console.log("getValidReminders, actionButton.title = " + actionButton[j]?.title);
248        console.log("getValidReminders, actionButton.type = " + actionButton[j]?.type);
249      }
250      console.log("getValidReminders, wantAgent.pkgName = " + reminders[i].wantAgent?.pkgName);
251      console.log("getValidReminders, wantAgent.abilityName = " + reminders[i].wantAgent?.abilityName);
252      console.log("getValidReminders, ringDuration = " + reminders[i].ringDuration);
253      console.log("getValidReminders, snoozeTimes = " + reminders[i].snoozeTimes);
254      console.log("getValidReminders, timeInterval = " + reminders[i].timeInterval);
255      console.log("getValidReminders, title = " + reminders[i].title);
256      console.log("getValidReminders, content = " + reminders[i].content);
257      console.log("getValidReminders, expiredContent = " + reminders[i].expiredContent);
258      console.log("getValidReminders, snoozeContent = " + reminders[i].snoozeContent);
259      console.log("getValidReminders, notificationId = " + reminders[i].notificationId);
260      console.log("getValidReminders, slotType = " + reminders[i].slotType);
261    }
262  }
263});
264```
265
266## reminderAgentManager.getValidReminders
267
268getValidReminders(): Promise\<Array\<ReminderRequest>>
269
270Obtains all [valid (not yet expired) reminders](../../task-management/agent-powered-reminder.md#constraints) set by the current application. This API uses a promise to return the result.
271
272**System capability**: SystemCapability.Notification.ReminderAgent
273
274**Return value**
275
276| Type| Description|
277| -------- | -------- |
278| Promise\<Array\<[ReminderRequest](#reminderrequest)>> | Promise used to return all the valid reminders.|
279
280**Error codes**
281
282For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md).
283
284| ID  | Error Message|
285| --------- | ------- |
286| 401 | If the input parameter is not valid parameter. |
287| 1700004    | The bundle name does not exist. |
288
289**Example**
290
291```ts
292import { BusinessError } from '@kit.BasicServicesKit';
293
294reminderAgentManager.getValidReminders().then((reminders: Array<reminderAgentManager.ReminderRequest>) => {
295  console.log("promise, getValidReminders length = " + reminders.length);
296  for (let i = 0; i < reminders.length; i++) {
297    console.log("getValidReminders = " + reminders[i]);
298    console.log("getValidReminders, reminderType = " + reminders[i].reminderType);
299    const actionButton = reminders[i].actionButton || [];
300    for (let j = 0; j < actionButton.length; j++) {
301      console.log("getValidReminders, actionButton.title = " + actionButton[j]?.title);
302      console.log("getValidReminders, actionButton.type = " + actionButton[j]?.type);
303    }
304    console.log("getValidReminders, wantAgent.pkgName = " + reminders[i].wantAgent?.pkgName);
305    console.log("getValidReminders, wantAgent.abilityName = " + reminders[i].wantAgent?.abilityName);
306    console.log("getValidReminders, ringDuration = " + reminders[i].ringDuration);
307    console.log("getValidReminders, snoozeTimes = " + reminders[i].snoozeTimes);
308    console.log("getValidReminders, timeInterval = " + reminders[i].timeInterval);
309    console.log("getValidReminders, title = " + reminders[i].title);
310    console.log("getValidReminders, content = " + reminders[i].content);
311    console.log("getValidReminders, expiredContent = " + reminders[i].expiredContent);
312    console.log("getValidReminders, snoozeContent = " + reminders[i].snoozeContent);
313    console.log("getValidReminders, notificationId = " + reminders[i].notificationId);
314    console.log("getValidReminders, slotType = " + reminders[i].slotType);
315  }
316}).catch((err: BusinessError) => {
317  console.error("promise err code:" + err.code + " message:" + err.message);
318});
319```
320
321## reminderAgentManager.cancelAllReminders
322
323cancelAllReminders(callback: AsyncCallback\<void>): void
324
325Cancels all reminders set by the current application. This API uses an asynchronous callback to return the result.
326
327**System capability**: SystemCapability.Notification.ReminderAgent
328
329**Parameters**
330
331| Name| Type| Mandatory| Description|
332| -------- | -------- | -------- | -------- |
333| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If all the reminders are canceled, **err** is **undefined**. Otherwise, **err** is an error object. |
334
335**Error codes**
336
337For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md).
338
339| ID  | Error Message|
340| --------- | ------- |
341| 401 | If the input parameter is not valid parameter. |
342| 1700004    | The bundle name does not exist. |
343
344**Example**
345
346```ts
347import { BusinessError } from '@kit.BasicServicesKit';
348
349reminderAgentManager.cancelAllReminders((err: BusinessError) =>{
350  if (err.code) {
351    console.error("callback err code:" + err.code + " message:" + err.message);
352  } else {
353    console.log("cancelAllReminders callback")
354  }
355});
356```
357
358## reminderAgentManager.cancelAllReminders
359
360cancelAllReminders(): Promise\<void>
361
362Cancels all reminders set by the current application. This API uses a promise to return the result.
363
364**System capability**: SystemCapability.Notification.ReminderAgent
365
366**Return value**
367
368| Type| Description|
369| -------- | -------- |
370| Promise\<void> | Promise that returns no value.|
371
372**Error codes**
373
374For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md).
375
376| ID  | Error Message|
377| --------- | ------- |
378| 401 | If the input parameter is not valid parameter. |
379| 1700004    | The bundle name does not exist. |
380
381**Example**
382
383```ts
384import { BusinessError } from '@kit.BasicServicesKit';
385
386reminderAgentManager.cancelAllReminders().then(() => {
387  console.log("cancelAllReminders promise")
388}).catch((err: BusinessError) => {
389  console.error("promise err code:" + err.code + " message:" + err.message);
390});
391```
392
393
394## reminderAgentManager.addNotificationSlot
395
396addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback\<void>): void
397
398Adds a notification slot. This API uses an asynchronous callback to return the result.
399
400**System capability**: SystemCapability.Notification.ReminderAgent
401
402**Parameters**
403
404| Name| Type| Mandatory| Description|
405| -------- | -------- | -------- | -------- |
406| slot | [NotificationSlot](../apis-notification-kit/js-apis-inner-notification-notificationSlot.md#notificationslot-1) | Yes| notificationManager\.slot instance. Only **notificationType** can be set.|
407| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the notification slot is added, **err** is **undefined**. Otherwise, **err** is an error object.|
408
409**Error codes**
410
411For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
412
413| ID| Error Message                                      |
414| -------- | ---------------------------------------------- |
415| 401      | If the input parameter is not valid parameter. |
416
417**Example**
418
419```ts
420import { notificationManager } from '@kit.NotificationKit';
421import { BusinessError } from '@kit.BasicServicesKit';
422
423let mySlot: notificationManager.NotificationSlot = {
424  notificationType: notificationManager.SlotType.SOCIAL_COMMUNICATION
425}
426
427reminderAgentManager.addNotificationSlot(mySlot, (err: BusinessError) => {
428  if (err.code) {
429    console.error("callback err code:" + err.code + " message:" + err.message);
430  } else {
431    console.log("addNotificationSlot callback");
432  }
433});
434```
435
436
437## reminderAgentManager.addNotificationSlot
438
439addNotificationSlot(slot: NotificationSlot): Promise\<void>
440
441Adds a notification slot. This API uses a promise to return the result.
442
443**System capability**: SystemCapability.Notification.ReminderAgent
444
445**Parameters**
446
447| Name| Type| Mandatory| Description|
448| -------- | -------- | -------- | -------- |
449| slot | [NotificationSlot](../apis-notification-kit/js-apis-inner-notification-notificationSlot.md#notificationslot-1) | Yes| notificationManager\.slot instance. Only **notificationType** can be set.|
450
451**Return value**
452
453| Type| Description|
454| -------- | -------- |
455| Promise\<void> | Promise that returns no value.|
456
457**Error codes**
458
459For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
460
461| ID| Error Message                                      |
462| -------- | ---------------------------------------------- |
463| 401      | If the input parameter is not valid parameter. |
464
465**Example**
466
467```ts
468import { notificationManager } from '@kit.NotificationKit';
469import { BusinessError } from '@kit.BasicServicesKit';
470
471let mySlot: notificationManager.NotificationSlot = {
472  notificationType: notificationManager.SlotType.SOCIAL_COMMUNICATION
473}
474reminderAgentManager.addNotificationSlot(mySlot).then(() => {
475  console.log("addNotificationSlot promise");
476}).catch((err: BusinessError) => {
477  console.error("promise err code:" + err.code + " message:" + err.message);
478});
479```
480
481
482## reminderAgentManager.removeNotificationSlot
483
484removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback\<void>): void
485
486Removes a notification slot. This API uses an asynchronous callback to return the result.
487
488**System capability**: SystemCapability.Notification.ReminderAgent
489
490**Parameters**
491
492| Name| Type| Mandatory| Description|
493| -------- | -------- | -------- | -------- |
494| slotType | [notification.SlotType](../apis-notification-kit/js-apis-notification.md#slottype) | Yes| Type of the notification slot.|
495| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the notification slot is removed, **err** is **undefined**. Otherwise, **err** is an error object.|
496
497**Error codes**
498
499For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
500
501| ID| Error Message                                      |
502| -------- | ---------------------------------------------- |
503| 401      | If the input parameter is not valid parameter. |
504
505**Example**
506
507```ts
508import { notificationManager } from '@kit.NotificationKit';
509import { BusinessError } from '@kit.BasicServicesKit';
510
511reminderAgentManager.removeNotificationSlot(notificationManager.SlotType.CONTENT_INFORMATION,
512  (err: BusinessError) => {
513  if (err.code) {
514    console.error("callback err code:" + err.code + " message:" + err.message);
515  } else {
516    console.log("removeNotificationSlot callback");
517  }
518});
519```
520
521
522## reminderAgentManager.removeNotificationSlot
523
524removeNotificationSlot(slotType: notification.SlotType): Promise\<void>
525
526Removes a notification slot. This API uses a promise to return the result.
527
528**System capability**: SystemCapability.Notification.ReminderAgent
529
530**Parameters**
531
532| Name| Type| Mandatory| Description|
533| -------- | -------- | -------- | -------- |
534| slotType | [notification.SlotType](../apis-notification-kit/js-apis-notification.md#slottype) | Yes| Type of the notification slot.|
535
536**Return value**
537
538| Type| Description|
539| -------- | -------- |
540| Promise\<void> | Promise that returns no value.|
541
542**Error codes**
543
544For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
545
546| ID| Error Message                                      |
547| -------- | ---------------------------------------------- |
548| 401      | If the input parameter is not valid parameter. |
549
550**Example**
551
552```ts
553import { notificationManager } from '@kit.NotificationKit';
554import { BusinessError } from '@kit.BasicServicesKit';
555
556reminderAgentManager.removeNotificationSlot(notificationManager.SlotType.CONTENT_INFORMATION).then(() => {
557  console.log("removeNotificationSlot promise");
558}).catch((err: BusinessError) => {
559  console.error("promise err code:" + err.code + " message:" + err.message);
560});
561```
562
563## reminderAgentManager.getAllValidReminders<sup>12+</sup>
564
565getAllValidReminders(): Promise\<Array\<ReminderInfo>>
566
567Obtains all [valid (not yet expired) reminders](../../task-management/agent-powered-reminder.md#constraints) set by the current application. This API uses a promise to return the result.
568
569**System capability**: SystemCapability.Notification.ReminderAgent
570
571**Return value**
572
573| Type                                             | Description                                                        |
574| ------------------------------------------------- | ------------------------------------------------------------ |
575| Promise\<Array\<[ReminderInfo](#reminderinfo12)>> | Promise used to return all the valid reminders.|
576
577**Error codes**
578
579For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
580
581| ID| Error Message          |
582| -------- | ------------------ |
583| 201      | Permission denied. |
584
585**Example**
586
587```ts
588import { BusinessError } from '@kit.BasicServicesKit';
589
590reminderAgentManager.getAllValidReminders().then((reminders: Array<reminderAgentManager.ReminderInfo>) => {
591  console.log("promise, getAllValidReminders length = " + reminders.length);
592  for (let i = 0; i < reminders.length; i++) {
593    console.log("getAllValidReminders, reminderId = " + reminders[i].reminderId);
594    console.log("getAllValidReminders, reminderType = " + reminders[i].reminderReq.reminderType);
595    const actionButton = reminders[i].reminderReq.actionButton || [];
596    for (let j = 0; j < actionButton.length; j++) {
597      console.log("getAllValidReminders, actionButton.title = " + actionButton[j]?.title);
598      console.log("getAllValidReminders, actionButton.type = " + actionButton[j]?.type);
599    }
600    console.log("getAllValidReminders, wantAgent.pkgName = " + reminders[i].reminderReq.wantAgent?.pkgName);
601    console.log("getAllValidReminders, wantAgent.abilityName = " + reminders[i].reminderReq.wantAgent?.abilityName);
602    console.log("getAllValidReminders, ringDuration = " + reminders[i].reminderReq.ringDuration);
603    console.log("getAllValidReminders, snoozeTimes = " + reminders[i].reminderReq.snoozeTimes);
604    console.log("getAllValidReminders, timeInterval = " + reminders[i].reminderReq.timeInterval);
605    console.log("getAllValidReminders, title = " + reminders[i].reminderReq.title);
606    console.log("getAllValidReminders, content = " + reminders[i].reminderReq.content);
607    console.log("getAllValidReminders, expiredContent = " + reminders[i].reminderReq.expiredContent);
608    console.log("getAllValidReminders, snoozeContent = " + reminders[i].reminderReq.snoozeContent);
609    console.log("getAllValidReminders, notificationId = " + reminders[i].reminderReq.notificationId);
610    console.log("getAllValidReminders, slotType = " + reminders[i].reminderReq.slotType);
611  }
612}).catch((err: BusinessError) => {
613  console.error("promise err code:" + err.code + " message:" + err.message);
614});
615```
616
617## reminderAgentManager.addExcludeDate<sup>12+</sup>
618
619addExcludeDate(reminderId: number, date: Date): Promise\<void>
620
621Adds a non-reminder date for a recurring calendar reminder with a specific ID. For example, configure a daily reminder to skip notifications on Tuesdays. This API uses a promise to return the result.
622
623**System capability**: SystemCapability.Notification.ReminderAgent
624
625**Parameters**
626
627| Name    | Type  | Mandatory| Description                              |
628| ---------- | ------ | ---- | ---------------------------------- |
629| reminderId | number | Yes  | ID of the recurring calendar reminder.|
630| date       | Date   | Yes  | Non-reminder date.                    |
631
632**Return value**
633
634| Type          | Description                     |
635| -------------- | ------------------------- |
636| Promise\<void> | Promise that returns no value.|
637
638**Error codes**
639
640For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md).
641
642| ID| Error Message                                      |
643| -------- | ---------------------------------------------- |
644| 201      | Permission denied.                             |
645| 401      | If the input parameter is not valid parameter. |
646| 1700003  | The reminder does not exist.                   |
647
648**Example**
649
650```ts
651import { BusinessError } from '@kit.BasicServicesKit';
652
653let reminderId: number = 1;
654let date = new Date();
655reminderAgentManager.addExcludeDate(reminderId, date).then(() => {
656  console.log("addExcludeDate promise");
657}).catch((err: BusinessError) => {
658  console.error("promise err code:" + err.code + " message:" + err.message);
659});
660```
661
662## reminderAgentManager.deleteExcludeDates<sup>12+</sup>
663
664deleteExcludeDates(reminderId: number): Promise\<void>
665
666Deletes all non-reminder dates for a recurring calendar reminder with a specific ID. This API uses a promise to return the result.
667
668**System capability**: SystemCapability.Notification.ReminderAgent
669
670**Parameters**
671
672| Name    | Type  | Mandatory| Description                              |
673| ---------- | ------ | ---- | ---------------------------------- |
674| reminderId | number | Yes  | ID of the recurring calendar reminder.|
675
676**Return value**
677
678| Type          | Description                     |
679| -------------- | ------------------------- |
680| Promise\<void> | Promise that returns no value.|
681
682**Error codes**
683
684For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md).
685
686| ID| Error Message                    |
687| -------- | ---------------------------- |
688| 201      | Permission denied.           |
689| 1700003  | The reminder does not exist. |
690
691**Example**
692
693```ts
694import { BusinessError } from '@kit.BasicServicesKit';
695
696let reminderId: number = 1;
697reminderAgentManager.deleteExcludeDates(reminderId).then(() => {
698  console.log("deleteExcludeDates promise");
699}).catch((err: BusinessError) => {
700  console.error("promise err code:" + err.code + " message:" + err.message);
701});
702```
703
704## reminderAgentManager.getExcludeDates<sup>12+</sup>
705
706getExcludeDates(reminderId: number): Promise\<Array\<Date>>
707
708Obtains all non-reminder dates for a recurring calendar reminder with a specific ID. This API uses a promise to return the result.
709
710**System capability**: SystemCapability.Notification.ReminderAgent
711
712**Parameters**
713
714| Name    | Type  | Mandatory| Description                              |
715| ---------- | ------ | ---- | ---------------------------------- |
716| reminderId | number | Yes  | ID of the recurring calendar reminder.|
717
718**Return value**
719
720| Type                  | Description                             |
721| ---------------------- | --------------------------------- |
722| Promise\<Array\<Date>> | Promise used to return all the non-reminder dates.|
723
724**Error codes**
725
726For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md).
727
728| ID| Error Message                    |
729| -------- | ---------------------------- |
730| 201      | Permission denied.           |
731| 1700003  | The reminder does not exist. |
732
733**Example**
734
735```ts
736import { BusinessError } from '@kit.BasicServicesKit';
737
738let reminderId: number = 1;
739reminderAgentManager.getExcludeDates(reminderId).then((dates) => {
740  console.log("getExcludeDates promise length: " + dates.length);
741  for (let i = 0; i < dates.length; i++) {
742	console.log("getExcludeDates promise date is: " + dates[i].toString());
743  }
744}).catch((err: BusinessError) => {
745  console.error("promise err code:" + err.code + " message:" + err.message);
746});
747```
748
749## reminderAgentManager.updateReminder<sup>20+</sup>
750
751updateReminder(reminderId: number, reminderReq: ReminderRequest): Promise\<void>
752
753Updates the agent-powered reminder with the specified ID. This API uses a promise to return the result. Only [valid (not yet expired) reminders](../../task-management/agent-powered-reminder.md#constraints) that are not displayed in the notification panel can be updated.
754
755**Required permissions**: ohos.permission.PUBLISH_AGENT_REMINDER
756
757**System capability**: SystemCapability.Notification.ReminderAgent
758
759**Parameters**
760
761| Name    | Type  | Mandatory| Description                              |
762| ---------- | ------ | ---- | ---------------------------------- |
763| reminderId | number | Yes  | ID of the reminder to be updated, which is the return value of [publishReminder](#reminderagentmanagerpublishreminder).|
764| reminderReq | [ReminderRequest](#reminderrequest) | Yes  | Request instance used to set detailed information such as the reminder type and ringing duration.|
765
766**Return value**
767
768| Type                  | Description                             |
769| ---------------------- | --------------------------------- |
770| Promise\<void> | Promise that returns no value.|
771
772**Error codes**
773
774For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md).
775
776| ID| Error Message                    |
777| -------- | ---------------------------- |
778| 201      | Permission denied.           |
779| 1700003  | The reminder does not exist. |
780| 1700007  | If the input parameter is not valid parameter. |
781
782**Example**
783
784```ts
785import { reminderAgentManager } from '@kit.BackgroundTasksKit';
786import { BusinessError } from '@kit.BasicServicesKit';
787
788let timer: reminderAgentManager.ReminderRequestTimer = {
789  reminderType: reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER,
790  triggerTimeInSeconds: 10
791}
792
793let reminderId: number = 1;
794reminderAgentManager.updateReminder(reminderId, timer).then(() => {
795  console.info("update reminder succeed");
796}).catch((err: BusinessError) => {
797  console.error("promise err code:" + err.code + " message:" + err.message);
798});
799```
800
801## ActionButtonType
802
803Enumerates the types of buttons displayed for a reminder.
804
805**System capability**: SystemCapability.Notification.ReminderAgent
806
807| Name| Value| Description|
808| -------- | -------- | -------- |
809| ACTION_BUTTON_TYPE_CLOSE | 0 | Button for closing the reminder.|
810| ACTION_BUTTON_TYPE_SNOOZE | 1 | Button for snoozing the reminder, with the frequency and timing configured via **snoozeTimes** and **timeInterval** in the **ReminderRequest** struct.|
811
812## ReminderType
813
814Enumerates the reminder types.
815
816**System capability**: SystemCapability.Notification.ReminderAgent
817
818| Name| Value| Description|
819| -------- | -------- | -------- |
820| REMINDER_TYPE_TIMER | 0 | Countdown reminder.|
821| REMINDER_TYPE_CALENDAR | 1 | Calendar reminder.|
822| REMINDER_TYPE_ALARM | 2 | Alarm reminder.|
823
824## RingChannel<sup>20+</sup>
825
826Enumerates the audio playback channels for the custom prompt tone.
827
828**System capability**: SystemCapability.Notification.ReminderAgent
829
830| Name| Value| Description|
831| -------- | -------- | -------- |
832| RING_CHANNEL_ALARM | 0 | Alarm channel.|
833| RING_CHANNEL_MEDIA | 1 | Media channel.|
834
835
836## ActionButton
837
838Describes the button displayed for a reminder.
839
840**System capability**: SystemCapability.Notification.ReminderAgent
841
842| Name| Type| Mandatory| Description|
843| -------- | -------- | -------- | -------- |
844| title | string | Yes| Text on the button.|
845| titleResource<sup>11+</sup> | string | No| Resource ID of the title. This parameter is used to read the title information after the system language is switched.|
846| type | [ActionButtonType](#actionbuttontype) | Yes| Button type.|
847
848
849## WantAgent
850
851Defines the information about the redirected-to ability.
852
853**System capability**: SystemCapability.Notification.ReminderAgent
854
855
856| Name| Type| Mandatory| Description|
857| -------- | -------- | -------- | -------- |
858| pkgName | string | Yes| Name of the target package.|
859| abilityName | string | Yes| Name of the target ability.|
860| parameters<sup>12+</sup> | Record\<string, Object> | No| Parameters to be transferred to the target.|
861| uri<sup>12+</sup> | string | No| URI of the target ability.|
862
863
864## MaxScreenWantAgent
865
866Describes the information about the ability that is started automatically and displayed in full-screen mode when a reminder is displayed in the notification center. This API is reserved.
867
868**System capability**: SystemCapability.Notification.ReminderAgent
869
870| Name| Type| Mandatory| Description|
871| -------- | -------- | -------- | -------- |
872| pkgName | string | Yes| Name of the target package. (If the device is in use, only a notification banner is displayed.)|
873| abilityName | string | Yes| Name of the target ability. (If the device is in use, only a notification banner is displayed.)|
874
875
876## ReminderRequest
877
878Defines the request for publishing a reminder.
879
880**System capability**: SystemCapability.Notification.ReminderAgent
881
882| Name| Type| Mandatory| Description|
883| -------- | -------- | -------- | -------- |
884| reminderType | [ReminderType](#remindertype) | Yes| Type of the reminder.|
885| actionButton | [[ActionButton?, ActionButton?, ActionButton?]](#actionbutton) | No| Buttons displayed for the reminder notification.<br>- For common applications, a maximum of two buttons are supported.<br>- For system applications, a maximum of two buttons are supported in API version 9, and a maximum of three buttons are supported in API version 10 and later versions.|
886| wantAgent | [WantAgent](#wantagent) | No| Information about the ability that is redirected to when the reminder is clicked.|
887| maxScreenWantAgent | [MaxScreenWantAgent](#maxscreenwantagent) | No| Information about the ability that is started automatically and displayed in full-screen mode when the reminder arrives. If the device is in use, only a notification banner is displayed.<br> This API is reserved.|
888| ringDuration | number | No| Ringing duration, in seconds. The default value is **1**.|
889| snoozeTimes | number | No| Number of reminder snooze times. The default value is **0**. (It is not applicable to countdown reminders.)|
890| timeInterval | number | No| Reminder snooze interval, in seconds. The minimum value is 5 minutes. (It is not applicable to countdown reminders.)|
891| title | string | No| Reminder title.|
892| titleResourceId<sup>18+</sup> | number | No| Resource ID of the reminder title.|
893| content | string | No| Reminder content.|
894| contentResourceId<sup>18+</sup> | number | No| Resource ID of the reminder content.|
895| expiredContent | string | No| Content to be displayed after the reminder expires.|
896| expiredContentResourceId<sup>18+</sup> | number | No| Resource ID of the content to be displayed after the reminder expires.|
897| snoozeContent | string | No| Content to be displayed when the reminder is snoozing. (It is not applicable to countdown reminders.)|
898| snoozeContentResourceId<sup>18+</sup> | number | No| Resource ID of the content to be displayed when the reminder is snoozing.|
899| notificationId | number | No| Notification ID used by the reminder. You must pass in a notification ID. If there are reminders with the same notification ID, the later one will overwrite the earlier one.|
900| groupId<sup>11+</sup> | string | No| Group ID used for the reminder. If "Don't ask again" or similar information is selected for the reminder, other reminders with the same group ID are also canceled.|
901| slotType | [notification.SlotType](../apis-notification-kit/js-apis-notificationManager.md#slottype) | No| Type of the slot used by the reminder.|
902| tapDismissed<sup>10+</sup> | boolean | No| Whether the reminder is automatically cleared. For details, see [NotificationRequest.tapDismissed](../apis-notification-kit/js-apis-inner-notification-notificationRequest.md#notificationrequest-1).<br> - **true** (default): The reminder is automatically cleared after the notification or button is tapped.<br> - **false**: The reminder is retained after the notification or button is tapped.|
903| autoDeletedTime<sup>10+</sup> | number | No| Time when the reminder is automatically cleared. For details, see [NotificationRequest.autoDeletedTime](../apis-notification-kit/js-apis-inner-notification-notificationRequest.md#notificationrequest-1).|
904| snoozeSlotType<sup>11+</sup> | [notification.SlotType](../apis-notification-kit/js-apis-notificationManager.md#slottype) | No| Type of the slot used by the snoozed reminder. (It is not applicable to countdown reminders.)|
905| customRingUri<sup>11+</sup> | string | No| URI of the custom prompt tone. The prompt tone file must be stored in the **resources/rawfile** directory and supports formats such as M4A, AAC, MP3, OGG, WAV, FLAC, and AMR.|
906| ringChannel<sup>20+</sup> | [RingChannel](#ringchannel20) | No| Audio channel of the custom prompt tone. The default channel is the alarm channel.|
907
908## ReminderRequestCalendar
909
910ReminderRequestCalendar extends ReminderRequest
911
912Defines a reminder for a calendar event.
913
914**System capability**: SystemCapability.Notification.ReminderAgent
915
916| Name| Type| Mandatory| Description|
917| -------- | -------- | -------- | -------- |
918| dateTime | [LocalDateTime](#localdatetime) | Yes| Reminder time.|
919| repeatMonths | Array\<number> | No| Month in which the reminder repeats.|
920| repeatDays | Array\<number> | No| Date on which the reminder repeats.|
921| daysOfWeek<sup>11+</sup> | 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.|
922| endDateTime<sup>12+</sup> | [LocalDateTime](#localdatetime) | No| End time of the reminder.|
923
924
925## ReminderRequestAlarm
926
927ReminderRequestAlarm extends ReminderRequest
928
929Defines a reminder for an alarm.
930
931**System capability**: SystemCapability.Notification.ReminderAgent
932
933| Name| Type| Mandatory| Description|
934| -------- | -------- | -------- | -------- |
935| hour | number | Yes| Hour portion of the reminder time.|
936| minute | number | Yes| Minute portion of the reminder time.|
937| 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.|
938
939
940## ReminderRequestTimer
941
942ReminderRequestTimer extends ReminderRequest
943
944Defines a reminder for a scheduled timer.
945
946**System capability**: SystemCapability.Notification.ReminderAgent
947
948| Name| Type| Mandatory| Description|
949| -------- | -------- | -------- | -------- |
950| triggerTimeInSeconds | number | Yes| Number of seconds in the countdown timer.|
951
952
953## LocalDateTime
954
955Defines the time information for a calendar reminder.
956
957**System capability**: SystemCapability.Notification.ReminderAgent
958
959| Name| Type| Mandatory| Description|
960| -------- | -------- | -------- | -------- |
961| year | number | Yes| Year.|
962| month | number | Yes| Month. The value ranges from 1 to 12.|
963| day | number | Yes| Day. The value ranges from 1 to 31.|
964| hour | number | Yes| Hour. The value ranges from 0 to 23.|
965| minute | number | Yes| Minute. The value ranges from 0 to 59.|
966| second | number | No| Second. The value ranges from 0 to 59.|
967
968## ReminderInfo<sup>12+</sup>
969
970Defines the reminder information.
971
972**System capability**: SystemCapability.Notification.ReminderAgent
973
974| Name       | Type                               | Read Only| Optional| Description                |
975| ----------- | ----------------------------------- | ---- | ---- | -------------------- |
976| reminderId  | number                              | No  | No  | ID of the reminder.|
977| reminderReq | [ReminderRequest](#reminderrequest) | No  | No  | Request used for publishing the reminder.      |
978