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 22> **NOTE** 23> 24> This API can be called only after the [NotificationManager.requestEnableNotification](../apis-notification-kit/js-apis-notificationManager.md#notificationmanagerrequestenablenotification10) permission is obtained. 25> 26> <!--RP1--><!--RP1End--> 27 28**Required permissions**: ohos.permission.PUBLISH_AGENT_REMINDER 29 30**System capability**: SystemCapability.Notification.ReminderAgent 31 32**Parameters** 33 34 | Name| Type| Mandatory| Description| 35 | -------- | -------- | -------- | -------- | 36 | reminderReq | [ReminderRequest](#reminderrequest) | Yes| Request used for publishing the reminder.| 37 | callback | AsyncCallback\<number> | Yes| Callback used to return the published reminder's ID.| 38 39**Error codes** 40 41For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md). 42 43| ID | Error Message| 44| --------- | ------- | 45| 401 | If the input parameter is not valid parameter. | 46| 1700001 | Notification is not enabled. | 47| 1700002 | The number of reminders exceeds the limit. | 48 49**Example** 50```ts 51import { BusinessError } from '@kit.BasicServicesKit'; 52 53let timer: reminderAgentManager.ReminderRequestTimer = { 54 reminderType: reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER, 55 triggerTimeInSeconds: 10 56} 57 58reminderAgentManager.publishReminder(timer, (err: BusinessError, reminderId: number) => { 59 if (err.code) { 60 console.error("callback err code:" + err.code + " message:" + err.message); 61 } else { 62 console.log("callback, reminderId = " + reminderId); 63 } 64}); 65``` 66 67## reminderAgentManager.publishReminder 68 69publishReminder(reminderReq: ReminderRequest): Promise\<number> 70 71Publishes a reminder. This API uses a promise to return the result. 72 73> **NOTE** 74> 75> This API can be called only after the [NotificationManager.requestEnableNotification](../apis-notification-kit/js-apis-notificationManager.md#notificationmanagerrequestenablenotification10) permission is obtained. 76> 77> <!--RP1--><!--RP1End--> 78 79**Required permissions**: ohos.permission.PUBLISH_AGENT_REMINDER 80 81**System capability**: SystemCapability.Notification.ReminderAgent 82 83**Parameters** 84 85 | Name| Type| Mandatory| Description| 86 | -------- | -------- | -------- | -------- | 87 | reminderReq | [ReminderRequest](#reminderrequest) | Yes| Request used for publishing the reminder.| 88 89**Return value** 90 91| Type| Description| 92| -------- | -------- | 93| Promise\<number> | Promise used to return the published reminder ID.| 94 95**Error codes** 96 97For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md). 98 99| ID | Error Message| 100| --------- | ------- | 101| 401 | If the input parameter is not valid parameter. | 102| 1700001 | Notification is not enabled. | 103| 1700002 | The number of reminders exceeds the limit. | 104 105**Example** 106```ts 107import { BusinessError } from '@kit.BasicServicesKit'; 108 109let timer: reminderAgentManager.ReminderRequestTimer = { 110 reminderType: reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER, 111 triggerTimeInSeconds: 10 112} 113 114reminderAgentManager.publishReminder(timer).then((reminderId: number) => { 115 console.log("promise, reminderId = " + reminderId); 116}).catch((err: BusinessError) => { 117 console.error("promise err code:" + err.code + " message:" + err.message); 118}); 119``` 120 121 122## reminderAgentManager.cancelReminder 123 124cancelReminder(reminderId: number, callback: AsyncCallback\<void>): void 125 126Cancels a reminder published. This API uses an asynchronous callback to return the result. 127 128**System capability**: SystemCapability.Notification.ReminderAgent 129 130**Parameters** 131 132| Name| Type| Mandatory| Description| 133| -------- | -------- | -------- | -------- | 134| reminderId | number | Yes| ID of the reminder to cancel.| 135| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the reminder is canceled, **err** is **undefined**. Otherwise, **err** is an error object.| 136 137**Error codes** 138 139For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md). 140 141| ID | Error Message| 142| --------- | ------- | 143| 401 | If the input parameter is not valid parameter. | 144| 1700003 | The reminder does not exist. | 145| 1700004 | The bundle name does not exist. | 146 147**Example** 148 149```ts 150import { BusinessError } from '@kit.BasicServicesKit'; 151 152let reminderId: number = 1; 153reminderAgentManager.cancelReminder(reminderId, (err: BusinessError) => { 154 if (err.code) { 155 console.error("callback err code:" + err.code + " message:" + err.message); 156 } else { 157 console.log("cancelReminder callback"); 158 } 159}); 160``` 161 162## reminderAgentManager.cancelReminder 163 164cancelReminder(reminderId: number): Promise\<void> 165 166Cancels a reminder published. This API uses a promise to return the result. 167 168**System capability**: SystemCapability.Notification.ReminderAgent 169 170**Parameters** 171 172| Name| Type| Mandatory| Description| 173| -------- | -------- | -------- | -------- | 174| reminderId | number | Yes| ID of the reminder to cancel.| 175 176**Return value** 177 178| Type| Description| 179| -------- | -------- | 180| Promise\<void> | Promise that returns no value.| 181 182**Error codes** 183 184For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md). 185 186| ID | Error Message| 187| --------- | ------- | 188| 401 | If the input parameter is not valid parameter. | 189| 1700003 | The reminder does not exist. | 190| 1700004 | The bundle name does not exist. | 191 192**Example** 193 194```ts 195import { BusinessError } from '@kit.BasicServicesKit'; 196 197let reminderId: number = 1; 198reminderAgentManager.cancelReminder(reminderId).then(() => { 199 console.log("cancelReminder promise"); 200}).catch((err: BusinessError) => { 201 console.error("promise err code:" + err.code + " message:" + err.message); 202}); 203``` 204 205## reminderAgentManager.getValidReminders 206 207getValidReminders(callback: AsyncCallback<Array\<ReminderRequest>>): void 208 209Obtains 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. 210 211**System capability**: SystemCapability.Notification.ReminderAgent 212 213**Parameters** 214 215| Name| Type| Mandatory| Description| 216| -------- | -------- | -------- | -------- | 217| callback | AsyncCallback\<Array\<[ReminderRequest](#reminderrequest)>> | Yes| Callback used to return all the valid reminders.| 218 219**Error codes** 220 221For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md). 222 223| ID | Error Message| 224| --------- | ------- | 225| 401 | If the input parameter is not valid parameter. | 226| 1700004 | The bundle name does not exist. | 227 228**Example** 229 230```ts 231import { BusinessError } from '@kit.BasicServicesKit'; 232 233reminderAgentManager.getValidReminders((err: BusinessError, reminders: Array<reminderAgentManager.ReminderRequest>) => { 234 if (err.code) { 235 console.error("callback err code:" + err.code + " message:" + err.message); 236 } else { 237 console.log("callback, getValidReminders length = " + reminders.length); 238 for (let i = 0; i < reminders.length; i++) { 239 console.log("getValidReminders = " + reminders[i]); 240 console.log("getValidReminders, reminderType = " + reminders[i].reminderType); 241 const actionButton = reminders[i].actionButton || []; 242 for (let j = 0; j < actionButton.length; j++) { 243 console.log("getValidReminders, actionButton.title = " + actionButton[j]?.title); 244 console.log("getValidReminders, actionButton.type = " + actionButton[j]?.type); 245 } 246 console.log("getValidReminders, wantAgent.pkgName = " + reminders[i].wantAgent?.pkgName); 247 console.log("getValidReminders, wantAgent.abilityName = " + reminders[i].wantAgent?.abilityName); 248 console.log("getValidReminders, maxScreenWantAgent.pkgName = " + reminders[i].maxScreenWantAgent?.pkgName); 249 console.log("getValidReminders, maxScreenWantAgent.abilityName = " + reminders[i].maxScreenWantAgent?.abilityName); 250 console.log("getValidReminders, ringDuration = " + reminders[i].ringDuration); 251 console.log("getValidReminders, snoozeTimes = " + reminders[i].snoozeTimes); 252 console.log("getValidReminders, timeInterval = " + reminders[i].timeInterval); 253 console.log("getValidReminders, title = " + reminders[i].title); 254 console.log("getValidReminders, content = " + reminders[i].content); 255 console.log("getValidReminders, expiredContent = " + reminders[i].expiredContent); 256 console.log("getValidReminders, snoozeContent = " + reminders[i].snoozeContent); 257 console.log("getValidReminders, notificationId = " + reminders[i].notificationId); 258 console.log("getValidReminders, slotType = " + reminders[i].slotType); 259 } 260 } 261}); 262``` 263 264## reminderAgentManager.getValidReminders 265 266getValidReminders(): Promise\<Array\<ReminderRequest>> 267 268Obtains 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. 269 270**System capability**: SystemCapability.Notification.ReminderAgent 271 272**Return value** 273 274| Type| Description| 275| -------- | -------- | 276| Promise\<Array\<[ReminderRequest](#reminderrequest)>> | Promise used to return all the valid reminders.| 277 278**Error codes** 279 280For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md). 281 282| ID | Error Message| 283| --------- | ------- | 284| 401 | If the input parameter is not valid parameter. | 285| 1700004 | The bundle name does not exist. | 286 287**Example** 288 289```ts 290import { BusinessError } from '@kit.BasicServicesKit'; 291 292reminderAgentManager.getValidReminders().then((reminders: Array<reminderAgentManager.ReminderRequest>) => { 293 console.log("promise, getValidReminders length = " + reminders.length); 294 for (let i = 0; i < reminders.length; i++) { 295 console.log("getValidReminders = " + reminders[i]); 296 console.log("getValidReminders, reminderType = " + reminders[i].reminderType); 297 const actionButton = reminders[i].actionButton || []; 298 for (let j = 0; j < actionButton.length; j++) { 299 console.log("getValidReminders, actionButton.title = " + actionButton[j]?.title); 300 console.log("getValidReminders, actionButton.type = " + actionButton[j]?.type); 301 } 302 console.log("getValidReminders, wantAgent.pkgName = " + reminders[i].wantAgent?.pkgName); 303 console.log("getValidReminders, wantAgent.abilityName = " + reminders[i].wantAgent?.abilityName); 304 console.log("getValidReminders, maxScreenWantAgent.pkgName = " + reminders[i].maxScreenWantAgent?.pkgName); 305 console.log("getValidReminders, maxScreenWantAgent.abilityName = " + reminders[i].maxScreenWantAgent?.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) | 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) | 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, maxScreenWantAgent.pkgName = " + reminders[i].reminderReq.maxScreenWantAgent?.pkgName); 603 console.log("getAllValidReminders, maxScreenWantAgent.abilityName = " + reminders[i].reminderReq.maxScreenWantAgent?.abilityName); 604 console.log("getAllValidReminders, ringDuration = " + reminders[i].reminderReq.ringDuration); 605 console.log("getAllValidReminders, snoozeTimes = " + reminders[i].reminderReq.snoozeTimes); 606 console.log("getAllValidReminders, timeInterval = " + reminders[i].reminderReq.timeInterval); 607 console.log("getAllValidReminders, title = " + reminders[i].reminderReq.title); 608 console.log("getAllValidReminders, content = " + reminders[i].reminderReq.content); 609 console.log("getAllValidReminders, expiredContent = " + reminders[i].reminderReq.expiredContent); 610 console.log("getAllValidReminders, snoozeContent = " + reminders[i].reminderReq.snoozeContent); 611 console.log("getAllValidReminders, notificationId = " + reminders[i].reminderReq.notificationId); 612 console.log("getAllValidReminders, slotType = " + reminders[i].reminderReq.slotType); 613 } 614}).catch((err: BusinessError) => { 615 console.error("promise err code:" + err.code + " message:" + err.message); 616}); 617``` 618 619## reminderAgentManager.addExcludeDate<sup>12+</sup> 620 621addExcludeDate(reminderId: number, date: Date): Promise\<void> 622 623Adds 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. 624 625**System capability**: SystemCapability.Notification.ReminderAgent 626 627**Parameters** 628 629| Name | Type | Mandatory| Description | 630| ---------- | ------ | ---- | ---------------------------------- | 631| reminderId | number | Yes | ID of the recurring calendar reminder.| 632| date | Date | Yes | Non-reminder date. | 633 634**Return value** 635 636| Type | Description | 637| -------------- | ------------------------- | 638| Promise\<void> | Promise that returns no value.| 639 640**Error codes** 641 642For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md). 643 644| ID| Error Message | 645| -------- | ---------------------------------------------- | 646| 201 | Permission denied. | 647| 401 | If the input parameter is not valid parameter. | 648| 1700003 | The reminder does not exist. | 649 650**Example** 651 652```ts 653import { BusinessError } from '@kit.BasicServicesKit'; 654 655let reminderId: number = 1; 656let date = new Date(); 657reminderAgentManager.addExcludeDate(reminderId, date).then(() => { 658 console.log("addExcludeDate promise"); 659}).catch((err: BusinessError) => { 660 console.error("promise err code:" + err.code + " message:" + err.message); 661}); 662``` 663 664## reminderAgentManager.deleteExcludeDates<sup>12+</sup> 665 666deleteExcludeDates(reminderId: number): Promise\<void> 667 668Deletes all non-reminder dates for a recurring calendar reminder with a specific ID. This API uses a promise to return the result. 669 670**System capability**: SystemCapability.Notification.ReminderAgent 671 672**Parameters** 673 674| Name | Type | Mandatory| Description | 675| ---------- | ------ | ---- | ---------------------------------- | 676| reminderId | number | Yes | ID of the recurring calendar reminder.| 677 678**Return value** 679 680| Type | Description | 681| -------------- | ------------------------- | 682| Promise\<void> | Promise that returns no value.| 683 684**Error codes** 685 686For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md). 687 688| ID| Error Message | 689| -------- | ---------------------------- | 690| 201 | Permission denied. | 691| 1700003 | The reminder does not exist. | 692 693**Example** 694 695```ts 696import { BusinessError } from '@kit.BasicServicesKit'; 697 698let reminderId: number = 1; 699reminderAgentManager.deleteExcludeDates(reminderId).then(() => { 700 console.log("deleteExcludeDates promise"); 701}).catch((err: BusinessError) => { 702 console.error("promise err code:" + err.code + " message:" + err.message); 703}); 704``` 705 706## reminderAgentManager.getExcludeDates<sup>12+</sup> 707 708getExcludeDates(reminderId: number): Promise\<Array\<Date>> 709 710Obtains all non-reminder dates for a recurring calendar reminder with a specific ID. This API uses a promise to return the result. 711 712**System capability**: SystemCapability.Notification.ReminderAgent 713 714**Parameters** 715 716| Name | Type | Mandatory| Description | 717| ---------- | ------ | ---- | ---------------------------------- | 718| reminderId | number | Yes | ID of the recurring calendar reminder.| 719 720**Return value** 721 722| Type | Description | 723| ---------------------- | --------------------------------- | 724| Promise\<Array\<Date>> | Promise used to return all the non-reminder dates.| 725 726**Error codes** 727 728For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md). 729 730| ID| Error Message | 731| -------- | ---------------------------- | 732| 201 | Permission denied. | 733| 1700003 | The reminder does not exist. | 734 735**Example** 736 737```ts 738import { BusinessError } from '@kit.BasicServicesKit'; 739 740let reminderId: number = 1; 741reminderAgentManager.getExcludeDates(reminderId).then((dates) => { 742 console.log("getExcludeDates promise length: " + dates.length); 743 for (let i = 0; i < dates.length; i++) { 744 console.log("getExcludeDates promise date is: " + dates[i].toString()); 745 } 746}).catch((err: BusinessError) => { 747 console.error("promise err code:" + err.code + " message:" + err.message); 748}); 749``` 750 751## ActionButtonType 752 753Enumerates the types of buttons displayed for a reminder. 754 755**System capability**: SystemCapability.Notification.ReminderAgent 756 757| Name| Value| Description| 758| -------- | -------- | -------- | 759| ACTION_BUTTON_TYPE_CLOSE | 0 | Button for closing the reminder.| 760| ACTION_BUTTON_TYPE_SNOOZE | 1 | Button for snoozing the reminder, with the frequency and timing configured via **snoozeTimes** and **timeInterval** in the **ReminderRequest** struct.| 761 762## ReminderType 763 764Enumerates the reminder types. 765 766**System capability**: SystemCapability.Notification.ReminderAgent 767 768| Name| Value| Description| 769| -------- | -------- | -------- | 770| REMINDER_TYPE_TIMER | 0 | Countdown reminder.| 771| REMINDER_TYPE_CALENDAR | 1 | Calendar reminder.| 772| REMINDER_TYPE_ALARM | 2 | Alarm reminder.| 773 774 775## ActionButton 776 777Describes the button displayed for a reminder. 778 779**System capability**: SystemCapability.Notification.ReminderAgent 780 781| Name| Type| Mandatory| Description| 782| -------- | -------- | -------- | -------- | 783| title | string | Yes| Text on the button.| 784| 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.| 785| type | [ActionButtonType](#actionbuttontype) | Yes| Button type.| 786 787 788## WantAgent 789 790Defines the information about the redirected-to ability. 791 792**System capability**: SystemCapability.Notification.ReminderAgent 793 794 795| Name| Type| Mandatory| Description| 796| -------- | -------- | -------- | -------- | 797| pkgName | string | Yes| Name of the target package.| 798| abilityName | string | Yes| Name of the target ability.| 799| parameters<sup>12+</sup> | Record\<string, Object> | No| Parameters to be transferred to the target.| 800| uri<sup>12+</sup> | string | No| URI of the target ability.| 801 802 803## MaxScreenWantAgent 804 805Describes 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. 806 807**System capability**: SystemCapability.Notification.ReminderAgent 808 809| Name| Type| Mandatory| Description| 810| -------- | -------- | -------- | -------- | 811| pkgName | string | Yes| Name of the target package. (If the device is in use, only a notification banner is displayed.)| 812| abilityName | string | Yes| Name of the target ability. (If the device is in use, only a notification banner is displayed.)| 813 814 815## ReminderRequest 816 817Defines the request for publishing a reminder. 818 819**System capability**: SystemCapability.Notification.ReminderAgent 820 821| Name| Type| Mandatory| Description| 822| -------- | -------- | -------- | -------- | 823| reminderType | [ReminderType](#remindertype) | Yes| Type of the reminder.| 824| 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.| 825| wantAgent | [WantAgent](#wantagent) | No| Information about the ability that is redirected to when the reminder is clicked.| 826| 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.| 827| ringDuration | number | No| Ringing duration, in seconds. The default value is **1**.| 828| snoozeTimes | number | No| Number of reminder snooze times. The default value is **0**. (It is not applicable to countdown reminders.)| 829| timeInterval | number | No| Reminder snooze interval, in seconds. The minimum value is 5 minutes. (It is not applicable to countdown reminders.)| 830| title | string | No| Reminder title.| 831| content | string | No| Reminder content.| 832| expiredContent | string | No| Content to be displayed after the reminder expires.| 833| snoozeContent | string | No| Content to be displayed when the reminder is snoozing. (It is not applicable to countdown reminders.)| 834| 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.| 835| 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.| 836| slotType | [notification.SlotType](../apis-notification-kit/js-apis-notificationManager.md#slottype) | No| Type of the slot used by the reminder.| 837| 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). | 838| 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).| 839| 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.)| 840| 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.| 841 842## ReminderRequestCalendar 843 844ReminderRequestCalendar extends ReminderRequest 845 846Defines a reminder for a calendar event. 847 848**System capability**: SystemCapability.Notification.ReminderAgent 849 850| Name| Type| Mandatory| Description| 851| -------- | -------- | -------- | -------- | 852| dateTime | [LocalDateTime](#localdatetime) | Yes| Reminder time.| 853| repeatMonths | Array\<number> | No| Month in which the reminder repeats.| 854| repeatDays | Array\<number> | No| Date on which the reminder repeats.| 855| 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.| 856| endDateTime<sup>12+</sup> | [LocalDateTime](#localdatetime) | No| End time of the reminder.| 857 858 859## ReminderRequestAlarm 860 861ReminderRequestAlarm extends ReminderRequest 862 863Defines a reminder for an alarm. 864 865**System capability**: SystemCapability.Notification.ReminderAgent 866 867| Name| Type| Mandatory| Description| 868| -------- | -------- | -------- | -------- | 869| hour | number | Yes| Hour portion of the reminder time.| 870| minute | number | Yes| Minute portion of the reminder time.| 871| 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.| 872 873 874## ReminderRequestTimer 875 876ReminderRequestTimer extends ReminderRequest 877 878Defines a reminder for a scheduled timer. 879 880**System capability**: SystemCapability.Notification.ReminderAgent 881 882| Name| Type| Mandatory| Description| 883| -------- | -------- | -------- | -------- | 884| triggerTimeInSeconds | number | Yes| Number of seconds in the countdown timer.| 885 886 887## LocalDateTime 888 889Defines the time information for a calendar reminder. 890 891**System capability**: SystemCapability.Notification.ReminderAgent 892 893| Name| Type| Mandatory| Description| 894| -------- | -------- | -------- | -------- | 895| year | number | Yes| Year.| 896| month | number | Yes| Month. The value ranges from 1 to 12.| 897| day | number | Yes| Day. The value ranges from 1 to 31.| 898| hour | number | Yes| Hour. The value ranges from 0 to 23.| 899| minute | number | Yes| Minute. The value ranges from 0 to 59.| 900| second | number | No| Second. The value ranges from 0 to 59.| 901 902## ReminderInfo<sup>12+</sup> 903 904Defines the reminder information. 905 906**System capability**: SystemCapability.Notification.ReminderAgent 907 908| Name | Type | Read Only| Optional| Description | 909| ----------- | ----------------------------------- | ---- | ---- | -------------------- | 910| reminderId | number | No | No | ID of the reminder.| 911| reminderReq | [ReminderRequest](#reminderrequest) | No | No | Request used for publishing the reminder. | 912