• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.reminderAgentManager (后台代理提醒)
2
3本模块提供后台代理提醒的能力,即当应用被冻结或应用退出时,计时和提醒的功能将被系统服务代理。开发者可以调用本模块接口创建定时提醒,提醒类型支持倒计时、日历、闹钟三种。
4
5> **说明:**
6>
7> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8
9
10## 导入模块
11
12```ts
13import { reminderAgentManager } from '@kit.BackgroundTasksKit';
14```
15
16## reminderAgentManager.publishReminder
17
18publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback\<number>): void
19
20发布后台代理提醒。使用callback异步回调。
21
22如果[ReminderRequest.ringDuration](#reminderrequest)参数值大于0,则自定义铃声默认在闹钟通道上播放,如果值不大于0,则无响铃。
23
24> **说明:**
25>
26> 该接口需要申请通知弹窗权限[NotificationManager.requestEnableNotification](../apis-notification-kit/js-apis-notificationManager.md#notificationmanagerrequestenablenotification10)后调用。
27>
28> <!--RP1--><!--RP1End-->
29
30**需要权限**: ohos.permission.PUBLISH_AGENT_REMINDER
31
32**系统能力**: SystemCapability.Notification.ReminderAgent
33
34**参数**:
35
36  | 参数名 | 类型 | 必填 | 说明 |
37  | -------- | -------- | -------- | -------- |
38  | reminderReq | [ReminderRequest](#reminderrequest) | 是 | 需要发布的代理提醒实例。 |
39  | callback | AsyncCallback\<number> | 是 | 回调函数,返回当前发布提醒的id。 |
40
41**错误码:**
42
43以下错误码的详细介绍请参见[reminderAgentManager错误码](errorcode-reminderAgentManager.md)和[通用错误码](../errorcode-universal.md)。
44
45| 错误码ID   | 错误信息 |
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**示例**:
52```ts
53import { BusinessError } from '@kit.BasicServicesKit';
54import { reminderAgentManager } from '@kit.BackgroundTasksKit';
55
56let timer: reminderAgentManager.ReminderRequestTimer = {
57  reminderType: reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER,
58  triggerTimeInSeconds: 10
59}
60
61reminderAgentManager.publishReminder(timer, (err: BusinessError, reminderId: number) => {
62  if (err.code) {
63    console.error("callback err code:" + err.code + " message:" + err.message);
64  } else {
65    console.log("callback, reminderId = " + reminderId);
66  }
67});
68```
69
70## reminderAgentManager.publishReminder
71
72publishReminder(reminderReq: ReminderRequest): Promise\<number>
73
74发布后台代理提醒。使用promise异步回调。
75
76如果[ReminderRequest.ringDuration](#reminderrequest)参数值大于0,则自定义铃声默认在闹钟通道上播放,如果值不大于0,则无响铃。
77
78> **说明:**
79>
80> 该接口需要申请通知弹窗权限[NotificationManager.requestEnableNotification](../apis-notification-kit/js-apis-notificationManager.md#notificationmanagerrequestenablenotification10)后调用。
81>
82> <!--RP1--><!--RP1End-->
83
84**需要权限**: ohos.permission.PUBLISH_AGENT_REMINDER
85
86**系统能力**: SystemCapability.Notification.ReminderAgent
87
88**参数**:
89
90  | 参数名 | 类型 | 必填 | 说明 |
91  | -------- | -------- | -------- | -------- |
92  | reminderReq | [ReminderRequest](#reminderrequest) | 是 | 需要发布的代理提醒实例。 |
93
94**返回值**:
95
96| 类型 | 说明 |
97| -------- | -------- |
98| Promise\<number> | Promise对象,返回当前发布提醒的id。 |
99
100**错误码:**
101
102以下错误码的详细介绍请参见[reminderAgentManager错误码](errorcode-reminderAgentManager.md)和[通用错误码](../errorcode-universal.md)。
103
104| 错误码ID   | 错误信息 |
105| --------- | ------- |
106| 401 | If the input parameter is not valid parameter. |
107| 1700001    | Notification is not enabled. |
108| 1700002    | The number of reminders exceeds the limit. |
109
110**示例**:
111```ts
112import { BusinessError } from '@kit.BasicServicesKit';
113import { reminderAgentManager } from '@kit.BackgroundTasksKit';
114
115let timer: reminderAgentManager.ReminderRequestTimer = {
116  reminderType: reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER,
117  triggerTimeInSeconds: 10
118}
119
120reminderAgentManager.publishReminder(timer).then((reminderId: number) => {
121  console.log("promise, reminderId = " + reminderId);
122}).catch((err: BusinessError) => {
123  console.error("promise err code:" + err.code + " message:" + err.message);
124});
125```
126
127
128## reminderAgentManager.cancelReminder
129
130cancelReminder(reminderId: number, callback: AsyncCallback\<void>): void
131
132取消指定id的代理提醒。使用callback异步回调。
133
134**系统能力**: SystemCapability.Notification.ReminderAgent
135
136**参数**:
137
138| 参数名 | 类型 | 必填 | 说明 |
139| -------- | -------- | -------- | -------- |
140| reminderId | number | 是 | 需要取消的代理提醒的id。 |
141| callback | AsyncCallback\<void> | 是 | 回调函数,取消代理提醒成功,err为undefined,否则返回err信息。 |
142
143**错误码:**
144
145以下错误码的详细介绍请参见[reminderAgentManager错误码](errorcode-reminderAgentManager.md)和[通用错误码](../errorcode-universal.md)。
146
147| 错误码ID   | 错误信息 |
148| --------- | ------- |
149| 401 | If the input parameter is not valid parameter. |
150| 1700003    | The reminder does not exist. |
151| 1700004    | The bundle name does not exist. |
152
153**示例**:
154
155```ts
156import { BusinessError } from '@kit.BasicServicesKit';
157import { reminderAgentManager } from '@kit.BackgroundTasksKit';
158
159let reminderId: number = 1;
160reminderAgentManager.cancelReminder(reminderId, (err: BusinessError) => {
161  if (err.code) {
162    console.error("callback err code:" + err.code + " message:" + err.message);
163  } else {
164    console.log("cancelReminder callback");
165  }
166});
167```
168
169## reminderAgentManager.cancelReminder
170
171cancelReminder(reminderId: number): Promise\<void>
172
173取消指定id的代理提醒。使用Promise异步回调。
174
175**系统能力**: SystemCapability.Notification.ReminderAgent
176
177**参数**:
178
179| 参数名 | 类型 | 必填 | 说明 |
180| -------- | -------- | -------- | -------- |
181| reminderId | number | 是 | 需要取消的代理提醒的id。 |
182
183**返回值**:
184
185| 类型 | 说明 |
186| -------- | -------- |
187| Promise\<void> | 无返回结果的Promise对象。 |
188
189**错误码:**
190
191以下错误码的详细介绍请参见[reminderAgentManager错误码](errorcode-reminderAgentManager.md)和[通用错误码](../errorcode-universal.md)。
192
193| 错误码ID   | 错误信息 |
194| --------- | ------- |
195| 401 | If the input parameter is not valid parameter. |
196| 1700003    | The reminder does not exist. |
197| 1700004    | The bundle name does not exist. |
198
199**示例**:
200
201```ts
202import { BusinessError } from '@kit.BasicServicesKit';
203import { reminderAgentManager } from '@kit.BackgroundTasksKit';
204
205let reminderId: number = 1;
206reminderAgentManager.cancelReminder(reminderId).then(() => {
207  console.log("cancelReminder promise");
208}).catch((err: BusinessError) => {
209  console.error("promise err code:" + err.code + " message:" + err.message);
210});
211```
212
213## reminderAgentManager.getValidReminders
214
215getValidReminders(callback: AsyncCallback<Array\<ReminderRequest>>): void
216
217获取当前应用设置的所有[有效(未过期)的代理提醒](../../task-management/agent-powered-reminder.md#约束与限制)。使用callback异步回调。
218
219**系统能力**: SystemCapability.Notification.ReminderAgent
220
221**参数**:
222
223| 参数名 | 类型 | 必填 | 说明 |
224| -------- | -------- | -------- | -------- |
225| callback | AsyncCallback\<Array\<[ReminderRequest](#reminderrequest)>> | 是 | 回调函数,返回当前应用设置的所有有效(未过期)的代理提醒。 |
226
227**错误码:**
228
229以下错误码的详细介绍请参见[reminderAgentManager错误码](errorcode-reminderAgentManager.md)和[通用错误码](../errorcode-universal.md)。
230
231| 错误码ID   | 错误信息 |
232| --------- | ------- |
233| 401 | If the input parameter is not valid parameter. |
234| 1700004    | The bundle name does not exist. |
235
236**示例**:
237
238```ts
239import { BusinessError } from '@kit.BasicServicesKit';
240import { reminderAgentManager } from '@kit.BackgroundTasksKit';
241
242reminderAgentManager.getValidReminders((err: BusinessError, reminders: Array<reminderAgentManager.ReminderRequest>) => {
243  if (err.code) {
244    console.error("callback err code:" + err.code + " message:" + err.message);
245  } else {
246    console.log("callback, getValidReminders length = " + reminders.length);
247    for (let i = 0; i < reminders.length; i++) {
248      console.log("getValidReminders = " + reminders[i]);
249      console.log("getValidReminders, reminderType = " + reminders[i].reminderType);
250      const actionButton = reminders[i].actionButton || [];
251      for (let j = 0; j < actionButton.length; j++) {
252        console.log("getValidReminders, actionButton.title = " + actionButton[j]?.title);
253        console.log("getValidReminders, actionButton.type = " + actionButton[j]?.type);
254      }
255      console.log("getValidReminders, wantAgent.pkgName = " + reminders[i].wantAgent?.pkgName);
256      console.log("getValidReminders, wantAgent.abilityName = " + reminders[i].wantAgent?.abilityName);
257      console.log("getValidReminders, ringDuration = " + reminders[i].ringDuration);
258      console.log("getValidReminders, snoozeTimes = " + reminders[i].snoozeTimes);
259      console.log("getValidReminders, timeInterval = " + reminders[i].timeInterval);
260      console.log("getValidReminders, title = " + reminders[i].title);
261      console.log("getValidReminders, content = " + reminders[i].content);
262      console.log("getValidReminders, expiredContent = " + reminders[i].expiredContent);
263      console.log("getValidReminders, snoozeContent = " + reminders[i].snoozeContent);
264      console.log("getValidReminders, notificationId = " + reminders[i].notificationId);
265      console.log("getValidReminders, slotType = " + reminders[i].slotType);
266    }
267  }
268});
269```
270
271## reminderAgentManager.getValidReminders
272
273getValidReminders(): Promise\<Array\<ReminderRequest>>
274
275获取当前应用设置的所有[有效(未过期)的代理提醒](../../task-management/agent-powered-reminder.md#约束与限制)。使用promise异步回调。
276
277**系统能力**: SystemCapability.Notification.ReminderAgent
278
279**返回值**:
280
281| 类型 | 说明 |
282| -------- | -------- |
283| Promise\<Array\<[ReminderRequest](#reminderrequest)>> | Promise对象,返回当前应用设置的所有有效(未过期)的代理提醒。 |
284
285**错误码:**
286
287以下错误码的详细介绍请参见[reminderAgentManager错误码](errorcode-reminderAgentManager.md)和[通用错误码](../errorcode-universal.md)。
288
289| 错误码ID   | 错误信息 |
290| --------- | ------- |
291| 401 | If the input parameter is not valid parameter. |
292| 1700004    | The bundle name does not exist. |
293
294**示例**:
295
296```ts
297import { BusinessError } from '@kit.BasicServicesKit';
298import { reminderAgentManager } from '@kit.BackgroundTasksKit';
299
300reminderAgentManager.getValidReminders().then((reminders: Array<reminderAgentManager.ReminderRequest>) => {
301  console.log("promise, getValidReminders length = " + reminders.length);
302  for (let i = 0; i < reminders.length; i++) {
303    console.log("getValidReminders = " + reminders[i]);
304    console.log("getValidReminders, reminderType = " + reminders[i].reminderType);
305    const actionButton = reminders[i].actionButton || [];
306    for (let j = 0; j < actionButton.length; j++) {
307      console.log("getValidReminders, actionButton.title = " + actionButton[j]?.title);
308      console.log("getValidReminders, actionButton.type = " + actionButton[j]?.type);
309    }
310    console.log("getValidReminders, wantAgent.pkgName = " + reminders[i].wantAgent?.pkgName);
311    console.log("getValidReminders, wantAgent.abilityName = " + reminders[i].wantAgent?.abilityName);
312    console.log("getValidReminders, ringDuration = " + reminders[i].ringDuration);
313    console.log("getValidReminders, snoozeTimes = " + reminders[i].snoozeTimes);
314    console.log("getValidReminders, timeInterval = " + reminders[i].timeInterval);
315    console.log("getValidReminders, title = " + reminders[i].title);
316    console.log("getValidReminders, content = " + reminders[i].content);
317    console.log("getValidReminders, expiredContent = " + reminders[i].expiredContent);
318    console.log("getValidReminders, snoozeContent = " + reminders[i].snoozeContent);
319    console.log("getValidReminders, notificationId = " + reminders[i].notificationId);
320    console.log("getValidReminders, slotType = " + reminders[i].slotType);
321  }
322}).catch((err: BusinessError) => {
323  console.error("promise err code:" + err.code + " message:" + err.message);
324});
325```
326
327## reminderAgentManager.cancelAllReminders
328
329cancelAllReminders(callback: AsyncCallback\<void>): void
330
331取消当前应用设置的所有代理提醒。使用callback异步回调。
332
333**系统能力**: SystemCapability.Notification.ReminderAgent
334
335**参数**:
336
337| 参数名 | 类型 | 必填 | 说明 |
338| -------- | -------- | -------- | -------- |
339| callback | AsyncCallback\<void> | 是 | 回调函数,取消代理提醒成功,err为undefined,否则为错误对象。  |
340
341**错误码:**
342
343以下错误码的详细介绍请参见[reminderAgentManager错误码](errorcode-reminderAgentManager.md)和[通用错误码](../errorcode-universal.md)。
344
345| 错误码ID   | 错误信息 |
346| --------- | ------- |
347| 401 | If the input parameter is not valid parameter. |
348| 1700004    | The bundle name does not exist. |
349
350**示例**:
351
352```ts
353import { BusinessError } from '@kit.BasicServicesKit';
354import { reminderAgentManager } from '@kit.BackgroundTasksKit';
355
356reminderAgentManager.cancelAllReminders((err: BusinessError) =>{
357  if (err.code) {
358    console.error("callback err code:" + err.code + " message:" + err.message);
359  } else {
360    console.log("cancelAllReminders callback")
361  }
362});
363```
364
365## reminderAgentManager.cancelAllReminders
366
367cancelAllReminders(): Promise\<void>
368
369取消当前应用设置的所有代理提醒。使用Promise异步回调。
370
371**系统能力**: SystemCapability.Notification.ReminderAgent
372
373**返回值**:
374
375| 类型 | 说明 |
376| -------- | -------- |
377| Promise\<void> | 无返回结果的Promise对象。 |
378
379**错误码:**
380
381以下错误码的详细介绍请参见[reminderAgentManager错误码](errorcode-reminderAgentManager.md)和[通用错误码](../errorcode-universal.md)。
382
383| 错误码ID   | 错误信息 |
384| --------- | ------- |
385| 401 | If the input parameter is not valid parameter. |
386| 1700004    | The bundle name does not exist. |
387
388**示例**:
389
390```ts
391import { BusinessError } from '@kit.BasicServicesKit';
392import { reminderAgentManager } from '@kit.BackgroundTasksKit';
393
394reminderAgentManager.cancelAllReminders().then(() => {
395  console.log("cancelAllReminders promise")
396}).catch((err: BusinessError) => {
397  console.error("promise err code:" + err.code + " message:" + err.message);
398});
399```
400
401
402## reminderAgentManager.addNotificationSlot
403
404addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback\<void>): void
405
406添加通知槽。使用callback异步回调。
407
408**系统能力**: SystemCapability.Notification.ReminderAgent
409
410**参数**:
411
412| 参数名 | 类型 | 必填 | 说明 |
413| -------- | -------- | -------- | -------- |
414| slot | [NotificationSlot](../apis-notification-kit/js-apis-inner-notification-notificationSlot.md#notificationslot-1) | 是 | notificationManager\.slot实例,仅支持设置其notificationType属性。 |
415| callback | AsyncCallback\<void> | 是 | 回调函数,添加NotificationSlot成功时,err为undefined,否则err为错误对象。 |
416
417**错误码:**
418
419以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
420
421| 错误码ID | 错误信息                                       |
422| -------- | ---------------------------------------------- |
423| 401      | If the input parameter is not valid parameter. |
424
425**示例**:
426
427```ts
428import { notificationManager } from '@kit.NotificationKit';
429import { BusinessError } from '@kit.BasicServicesKit';
430import { reminderAgentManager } from '@kit.BackgroundTasksKit';
431
432let mySlot: notificationManager.NotificationSlot = {
433  notificationType: notificationManager.SlotType.SOCIAL_COMMUNICATION
434}
435
436reminderAgentManager.addNotificationSlot(mySlot, (err: BusinessError) => {
437  if (err.code) {
438    console.error("callback err code:" + err.code + " message:" + err.message);
439  } else {
440    console.log("addNotificationSlot callback");
441  }
442});
443```
444
445
446## reminderAgentManager.addNotificationSlot
447
448addNotificationSlot(slot: NotificationSlot): Promise\<void>
449
450添加通知槽。使用promise异步回调。
451
452**系统能力**: SystemCapability.Notification.ReminderAgent
453
454**参数**:
455
456| 参数名 | 类型 | 必填 | 说明 |
457| -------- | -------- | -------- | -------- |
458| slot | [NotificationSlot](../apis-notification-kit/js-apis-inner-notification-notificationSlot.md#notificationslot-1) | 是 | notificationManager\.slot实例,仅支持设置其notificationType属性。 |
459
460**返回值**:
461
462| 类型 | 说明 |
463| -------- | -------- |
464| Promise\<void> | 无返回结果的Promise对象。 |
465
466**错误码:**
467
468以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
469
470| 错误码ID | 错误信息                                       |
471| -------- | ---------------------------------------------- |
472| 401      | If the input parameter is not valid parameter. |
473
474**示例**:
475
476```ts
477import { notificationManager } from '@kit.NotificationKit';
478import { BusinessError } from '@kit.BasicServicesKit';
479import { reminderAgentManager } from '@kit.BackgroundTasksKit';
480
481let mySlot: notificationManager.NotificationSlot = {
482  notificationType: notificationManager.SlotType.SOCIAL_COMMUNICATION
483}
484reminderAgentManager.addNotificationSlot(mySlot).then(() => {
485  console.log("addNotificationSlot promise");
486}).catch((err: BusinessError) => {
487  console.error("promise err code:" + err.code + " message:" + err.message);
488});
489```
490
491
492## reminderAgentManager.removeNotificationSlot
493
494removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback\<void>): void
495
496删除目标通知槽,使用callback异步回调。
497
498**系统能力**: SystemCapability.Notification.ReminderAgent
499
500**参数**:
501
502| 参数名 | 类型 | 必填 | 说明 |
503| -------- | -------- | -------- | -------- |
504| slotType | [notification.SlotType](../apis-notification-kit/js-apis-notification.md#slottype) | 是 | 通知渠道类型。 |
505| callback | AsyncCallback\<void> | 是 | 回调函数,当删除成功时,err为undefined,否则为错误对象。 |
506
507**错误码:**
508
509以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
510
511| 错误码ID | 错误信息                                       |
512| -------- | ---------------------------------------------- |
513| 401      | If the input parameter is not valid parameter. |
514
515**示例**:
516
517```ts
518import { notificationManager } from '@kit.NotificationKit';
519import { BusinessError } from '@kit.BasicServicesKit';
520import { reminderAgentManager } from '@kit.BackgroundTasksKit';
521
522reminderAgentManager.removeNotificationSlot(notificationManager.SlotType.CONTENT_INFORMATION,
523  (err: BusinessError) => {
524  if (err.code) {
525    console.error("callback err code:" + err.code + " message:" + err.message);
526  } else {
527    console.log("removeNotificationSlot callback");
528  }
529});
530```
531
532
533## reminderAgentManager.removeNotificationSlot
534
535removeNotificationSlot(slotType: notification.SlotType): Promise\<void>
536
537删除目标通知槽,使用Promise异步回调。
538
539**系统能力**: SystemCapability.Notification.ReminderAgent
540
541**参数**:
542
543| 参数名 | 类型 | 必填 | 说明 |
544| -------- | -------- | -------- | -------- |
545| slotType | [notification.SlotType](../apis-notification-kit/js-apis-notification.md#slottype) | 是 | 通知渠道类型。 |
546
547**返回值**:
548
549| 类型 | 说明 |
550| -------- | -------- |
551| Promise\<void> | 无返回结果的Promise对象。 |
552
553**错误码:**
554
555以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
556
557| 错误码ID | 错误信息                                       |
558| -------- | ---------------------------------------------- |
559| 401      | If the input parameter is not valid parameter. |
560
561**示例**:
562
563```ts
564import { notificationManager } from '@kit.NotificationKit';
565import { BusinessError } from '@kit.BasicServicesKit';
566import { reminderAgentManager } from '@kit.BackgroundTasksKit';
567
568reminderAgentManager.removeNotificationSlot(notificationManager.SlotType.CONTENT_INFORMATION).then(() => {
569  console.log("removeNotificationSlot promise");
570}).catch((err: BusinessError) => {
571  console.error("promise err code:" + err.code + " message:" + err.message);
572});
573```
574
575## reminderAgentManager.getAllValidReminders<sup>12+</sup>
576
577getAllValidReminders(): Promise\<Array\<ReminderInfo>>
578
579获取当前应用设置的所有[有效(未过期)的代理提醒](../../task-management/agent-powered-reminder.md#约束与限制)。使用promise异步回调。
580
581**系统能力**: SystemCapability.Notification.ReminderAgent
582
583**返回值**:
584
585| 类型                                              | 说明                                                         |
586| ------------------------------------------------- | ------------------------------------------------------------ |
587| Promise\<Array\<[ReminderInfo](#reminderinfo12)>> | Promise对象,返回当前应用设置的所有有效(未过期)的代理提醒。 |
588
589**错误码:**
590
591以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
592
593| 错误码ID | 错误信息           |
594| -------- | ------------------ |
595| 201      | Permission denied. |
596
597**示例**:
598
599```ts
600import { BusinessError } from '@kit.BasicServicesKit';
601import { reminderAgentManager } from '@kit.BackgroundTasksKit';
602
603reminderAgentManager.getAllValidReminders().then((reminders: Array<reminderAgentManager.ReminderInfo>) => {
604  console.log("promise, getAllValidReminders length = " + reminders.length);
605  for (let i = 0; i < reminders.length; i++) {
606    console.log("getAllValidReminders, reminderId = " + reminders[i].reminderId);
607    console.log("getAllValidReminders, reminderType = " + reminders[i].reminderReq.reminderType);
608    const actionButton = reminders[i].reminderReq.actionButton || [];
609    for (let j = 0; j < actionButton.length; j++) {
610      console.log("getAllValidReminders, actionButton.title = " + actionButton[j]?.title);
611      console.log("getAllValidReminders, actionButton.type = " + actionButton[j]?.type);
612    }
613    console.log("getAllValidReminders, wantAgent.pkgName = " + reminders[i].reminderReq.wantAgent?.pkgName);
614    console.log("getAllValidReminders, wantAgent.abilityName = " + reminders[i].reminderReq.wantAgent?.abilityName);
615    console.log("getAllValidReminders, ringDuration = " + reminders[i].reminderReq.ringDuration);
616    console.log("getAllValidReminders, snoozeTimes = " + reminders[i].reminderReq.snoozeTimes);
617    console.log("getAllValidReminders, timeInterval = " + reminders[i].reminderReq.timeInterval);
618    console.log("getAllValidReminders, title = " + reminders[i].reminderReq.title);
619    console.log("getAllValidReminders, content = " + reminders[i].reminderReq.content);
620    console.log("getAllValidReminders, expiredContent = " + reminders[i].reminderReq.expiredContent);
621    console.log("getAllValidReminders, snoozeContent = " + reminders[i].reminderReq.snoozeContent);
622    console.log("getAllValidReminders, notificationId = " + reminders[i].reminderReq.notificationId);
623    console.log("getAllValidReminders, slotType = " + reminders[i].reminderReq.slotType);
624  }
625}).catch((err: BusinessError) => {
626  console.error("promise err code:" + err.code + " message:" + err.message);
627});
628```
629
630## reminderAgentManager.addExcludeDate<sup>12+</sup>
631
632addExcludeDate(reminderId: number, date: Date): Promise\<void>
633
634为指定id的周期性的日历提醒,添加不提醒日期(如每天提醒的日历,设置周二不提醒)。使用Promise异步回调。
635
636**系统能力**: SystemCapability.Notification.ReminderAgent
637
638**参数**:
639
640| 参数名     | 类型   | 必填 | 说明                               |
641| ---------- | ------ | ---- | ---------------------------------- |
642| reminderId | number | 是   | 需要添加不提醒日期的周期性日历id。 |
643| date       | Date   | 是   | 不提醒的日期。                     |
644
645**返回值**:
646
647| 类型           | 说明                      |
648| -------------- | ------------------------- |
649| Promise\<void> | 无返回结果的Promise对象。 |
650
651**错误码:**
652
653以下错误码的详细介绍请参见[reminderAgentManager错误码](errorcode-reminderAgentManager.md)和[通用错误码](../errorcode-universal.md)。
654
655| 错误码ID | 错误信息                                       |
656| -------- | ---------------------------------------------- |
657| 201      | Permission denied.                             |
658| 401      | If the input parameter is not valid parameter. |
659| 1700003  | The reminder does not exist.                   |
660
661**示例**:
662
663```ts
664import { BusinessError } from '@kit.BasicServicesKit';
665import { reminderAgentManager } from '@kit.BackgroundTasksKit';
666
667let reminderId: number = 1;
668let date = new Date();
669reminderAgentManager.addExcludeDate(reminderId, date).then(() => {
670  console.log("addExcludeDate promise");
671}).catch((err: BusinessError) => {
672  console.error("promise err code:" + err.code + " message:" + err.message);
673});
674```
675
676## reminderAgentManager.deleteExcludeDates<sup>12+</sup>
677
678deleteExcludeDates(reminderId: number): Promise\<void>
679
680为指定id的周期性的日历提醒,删除设置的所有不提醒日期。使用Promise异步回调。
681
682**系统能力**: SystemCapability.Notification.ReminderAgent
683
684**参数**:
685
686| 参数名     | 类型   | 必填 | 说明                               |
687| ---------- | ------ | ---- | ---------------------------------- |
688| reminderId | number | 是   | 需要删除不提醒日期的周期性日历id。 |
689
690**返回值**:
691
692| 类型           | 说明                      |
693| -------------- | ------------------------- |
694| Promise\<void> | 无返回结果的Promise对象。 |
695
696**错误码:**
697
698以下错误码的详细介绍请参见[reminderAgentManager错误码](errorcode-reminderAgentManager.md)和[通用错误码](../errorcode-universal.md)。
699
700| 错误码ID | 错误信息                     |
701| -------- | ---------------------------- |
702| 201      | Permission denied.           |
703| 1700003  | The reminder does not exist. |
704
705**示例**:
706
707```ts
708import { BusinessError } from '@kit.BasicServicesKit';
709import { reminderAgentManager } from '@kit.BackgroundTasksKit';
710
711let reminderId: number = 1;
712reminderAgentManager.deleteExcludeDates(reminderId).then(() => {
713  console.log("deleteExcludeDates promise");
714}).catch((err: BusinessError) => {
715  console.error("promise err code:" + err.code + " message:" + err.message);
716});
717```
718
719## reminderAgentManager.getExcludeDates<sup>12+</sup>
720
721getExcludeDates(reminderId: number): Promise\<Array\<Date>>
722
723为指定id的周期性的日历提醒,查询设置的所有不提醒日期。使用Promise异步回调。
724
725**系统能力**: SystemCapability.Notification.ReminderAgent
726
727**参数**:
728
729| 参数名     | 类型   | 必填 | 说明                               |
730| ---------- | ------ | ---- | ---------------------------------- |
731| reminderId | number | 是   | 需要查询不提醒日期的周期性日历id。 |
732
733**返回值**:
734
735| 类型                   | 说明                              |
736| ---------------------- | --------------------------------- |
737| Promise\<Array\<Date>> | Promise对象。返回特定日历设置的所有不提醒日期。 |
738
739**错误码:**
740
741以下错误码的详细介绍请参见[reminderAgentManager错误码](errorcode-reminderAgentManager.md)和[通用错误码](../errorcode-universal.md)。
742
743| 错误码ID | 错误信息                     |
744| -------- | ---------------------------- |
745| 201      | Permission denied.           |
746| 1700003  | The reminder does not exist. |
747
748**示例**:
749
750```ts
751import { BusinessError } from '@kit.BasicServicesKit';
752import { reminderAgentManager } from '@kit.BackgroundTasksKit';
753
754let reminderId: number = 1;
755reminderAgentManager.getExcludeDates(reminderId).then((dates) => {
756  console.log("getExcludeDates promise length: " + dates.length);
757  for (let i = 0; i < dates.length; i++) {
758	console.log("getExcludeDates promise date is: " + dates[i].toString());
759  }
760}).catch((err: BusinessError) => {
761  console.error("promise err code:" + err.code + " message:" + err.message);
762});
763```
764
765## reminderAgentManager.updateReminder<sup>20+</sup>
766
767updateReminder(reminderId: number, reminderReq: ReminderRequest): Promise\<void>
768
769更新指定id的代理提醒,使用Promise异步回调。仅[有效(未过期)](../../task-management/agent-powered-reminder.md#约束与限制)、未显示在通知中心的代理提醒支持更新。
770
771**需要权限**: ohos.permission.PUBLISH_AGENT_REMINDER
772
773**系统能力**: SystemCapability.Notification.ReminderAgent
774
775**参数**:
776
777| 参数名     | 类型   | 必填 | 说明                               |
778| ---------- | ------ | ---- | ---------------------------------- |
779| reminderId | number | 是   | 需要更新的代理提醒的id,id为[publishReminder](#reminderagentmanagerpublishreminder)返回值。 |
780| reminderReq | [ReminderRequest](#reminderrequest) | 是   | 代理提醒对象实例,用于设置提醒类型、响铃时长等具体信息。 |
781
782**返回值**:
783
784| 类型                   | 说明                              |
785| ---------------------- | --------------------------------- |
786| Promise\<void> | 无返回结果的Promise对象。 |
787
788**错误码:**
789
790以下错误码的详细介绍请参见[reminderAgentManager错误码](errorcode-reminderAgentManager.md)和[通用错误码](../errorcode-universal.md)。
791
792| 错误码ID | 错误信息                     |
793| -------- | ---------------------------- |
794| 201      | Permission denied.           |
795| 1700003  | The reminder does not exist. |
796| 1700007  | If the input parameter is not valid parameter. |
797
798**示例**:
799
800```ts
801import { reminderAgentManager } from '@kit.BackgroundTasksKit';
802import { BusinessError } from '@kit.BasicServicesKit';
803
804let timer: reminderAgentManager.ReminderRequestTimer = {
805  reminderType: reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER,
806  triggerTimeInSeconds: 10
807}
808
809let reminderId: number = 1;
810reminderAgentManager.updateReminder(reminderId, timer).then(() => {
811  console.info("update reminder succeed");
812}).catch((err: BusinessError) => {
813  console.error("promise err code:" + err.code + " message:" + err.message);
814});
815```
816
817## ActionButtonType
818
819提醒上的按钮的类型。
820
821**系统能力**:SystemCapability.Notification.ReminderAgent
822
823| 名称 | 值 | 说明 |
824| -------- | -------- | -------- |
825| ACTION_BUTTON_TYPE_CLOSE | 0 | 表示关闭提醒的按钮。 |
826| ACTION_BUTTON_TYPE_SNOOZE | 1 | 表示延时提醒的按钮,提醒次数和间隔通过 [ReminderRequest](#reminderrequest) 中snoozeTimes和timeInterval设置。 |
827
828## ReminderType
829
830提醒的类型。
831
832**系统能力**:SystemCapability.Notification.ReminderAgent
833
834| 名称 | 值 | 说明 |
835| -------- | -------- | -------- |
836| REMINDER_TYPE_TIMER | 0 | 表示提醒类型:倒计时。 |
837| REMINDER_TYPE_CALENDAR | 1 | 表示提醒类型:日历。 |
838| REMINDER_TYPE_ALARM | 2 | 表示提醒类型:闹钟。 |
839
840## RingChannel<sup>20+</sup>
841
842自定义提示音的音频播放通道。
843
844**系统能力**:SystemCapability.Notification.ReminderAgent
845
846| 名称 | 值 | 说明 |
847| -------- | -------- | -------- |
848| RING_CHANNEL_ALARM | 0 | 闹钟通道。 |
849| RING_CHANNEL_MEDIA | 1 | 媒体通道。 |
850
851
852## ActionButton
853
854弹出的提醒中按钮的类型和标题。
855
856**系统能力**:SystemCapability.Notification.ReminderAgent
857
858| 名称 | 类型 | 只读 | 可选 | 说明 |
859| -------- | -------- | -------- | -------- | -------- |
860| title | string | 否 | 否 | 按钮显示的标题。 |
861| titleResource<sup>11+</sup> | string | 否 | 是 | 标题的资源ID,用于切换系统语言后读取对应标题信息。 |
862| type | [ActionButtonType](#actionbuttontype) | 否 | 否 | 按钮的类型。 |
863
864
865## WantAgent
866
867跳转目标的ability信息。
868
869**系统能力**:SystemCapability.Notification.ReminderAgent
870
871
872| 名称 | 类型 | 只读 | 可选 | 说明 |
873| -------- | -------- | -------- | -------- | -------- |
874| pkgName | string | 否 | 否 | 指明跳转目标的包名。 |
875| abilityName | string | 否 | 否 | 指明跳转目标的ability名称。 |
876| parameters<sup>12+</sup> | Record\<string, Object> | 否 | 是 | 需要传递到目标的参数。 |
877| uri<sup>12+</sup> | string | 否 | 是 | 指明跳转目标的uri信息。 |
878
879
880## MaxScreenWantAgent
881
882通知中心弹出提醒时,全屏显示自动拉起目标的ability信息。该接口为预留接口,暂不支持使用。
883
884**系统能力**:SystemCapability.Notification.ReminderAgent
885
886| 名称 | 类型 | 只读 | 可选 | 说明 |
887| -------- | -------- | -------- | -------- | -------- |
888| pkgName | string | 否 | 否 | 指明提醒到达时自动拉起的目标包名(如果设备在使用中,则只弹出通知横幅框)。 |
889| abilityName | string | 否 | 否 | 指明提醒到达时自动拉起的目标ability名(如果设备在使用中,则只弹出通知横幅框)。 |
890
891
892## ReminderRequest
893
894代理提醒对象,用于设置提醒类型、响铃时长等具体信息。
895
896**系统能力**:SystemCapability.Notification.ReminderAgent
897
898| 名称 | 类型 | 只读 | 可选 | 说明 |
899| -------- | -------- | -------- | -------- | -------- |
900| reminderType | [ReminderType](#remindertype) | 否 | 否 | 指明代理提醒类型。 |
901| actionButton | [[ActionButton?, ActionButton?, ActionButton?]](#actionbutton) | 否 | 是 | 弹出的提醒通知中显示的按钮。<br>-普通应用:最多支持两个按钮。<br>-系统应用:API9最多支持两个按钮,在API10开始最多支持三个按钮。 |
902| wantAgent | [WantAgent](#wantagent) | 否 | 是 | 点击通知后需要跳转的目标ability信息。 |
903| maxScreenWantAgent | [MaxScreenWantAgent](#maxscreenwantagent) | 否 | 是 | 提醒到达时,全屏显示自动拉起目标的ability信息。如果设备正在使用中,则弹出一个通知横幅框。 <br> 说明:该接口为预留接口,暂不支持使用。|
904| ringDuration | number | 否 | 是 | 指明响铃时长(单位:秒),默认1秒。 |
905| snoozeTimes | number | 否 | 是 | 指明延时提醒次数,默认0次(不适用于倒计时提醒类型)。 |
906| timeInterval | number | 否 | 是 | 执行延时提醒间隔(单位:秒),最少30秒(不适用于倒计时提醒类型)。 |
907| title | string | 否 | 是 | 指明提醒标题。 |
908| titleResourceId<sup>18+</sup> | number | 否 | 是 | 指明提醒标题的资源ID。 |
909| content | string | 否 | 是 | 指明提醒内容。 |
910| contentResourceId<sup>18+</sup> | number | 否 | 是 | 指明提醒内容的资源ID。 |
911| expiredContent | string | 否 | 是 | 指明提醒过期后需要显示的内容。 |
912| expiredContentResourceId<sup>18+</sup> | number | 否 | 是 | 指明提醒过期后内容的资源ID。 |
913| snoozeContent | string | 否 | 是 | 指明延时提醒时需要显示的内容(不适用于倒计时提醒类型)。 |
914| snoozeContentResourceId<sup>18+</sup> | number | 否 | 是 | 指明延时提醒内容的资源ID。 |
915| notificationId | number | 否 | 是 | 指明提醒使用的通知的id号,需开发者传入,相同id号的提醒会覆盖。 |
916| groupId<sup>11+</sup> | string | 否 | 是 | 指明提醒使用相同的组id。相同组id中,一个提醒被点击不在提醒后,组内其他提醒也会被取消。 |
917| slotType | [notification.SlotType](../apis-notification-kit/js-apis-notificationManager.md#slottype) | 否 | 是 | 指明提醒的通道渠道类型。 |
918| tapDismissed<sup>10+</sup> | boolean | 否 | 是 | 通知是否自动清除,默认值为true,具体请参考[NotificationRequest.tapDismissed](../apis-notification-kit/js-apis-inner-notification-notificationRequest.md#notificationrequest-1)。<br> - true:点击通知消息或通知按钮后,自动删除当前通知。<br> - false:点击通知消息或通知按钮后,保留当前通知。 |
919| autoDeletedTime<sup>10+</sup> | number | 否 | 是 | 自动清除的时间,具体请参考[NotificationRequest.autoDeletedTime](../apis-notification-kit/js-apis-inner-notification-notificationRequest.md#notificationrequest-1)。 |
920| snoozeSlotType<sup>11+</sup> | [notification.SlotType](../apis-notification-kit/js-apis-notificationManager.md#slottype) | 否 | 是 | 指明延时提醒的通道渠道类型(不适用于倒计时提醒类型)。 |
921| customRingUri<sup>11+</sup> | string | 否 | 是 | 指明自定义提示音的uri,提示音文件必须放在resources/rawfile目录下,支持m4a、aac、mp3、ogg、wav、flac、amr等格式。 |
922| ringChannel<sup>20+</sup> | [RingChannel](#ringchannel20) | 否 | 是 | 指明自定义提示音的音频播放通道,默认为闹钟通道。|
923
924## ReminderRequestCalendar
925
926ReminderRequestCalendar extends ReminderRequest
927
928日历实例对象,用于设置提醒的时间。
929
930**系统能力**:SystemCapability.Notification.ReminderAgent
931
932| 名称 | 类型 | 只读 | 可选 | 说明 |
933| -------- | -------- | -------- | -------- | -------- |
934| dateTime | [LocalDateTime](#localdatetime) | 否 | 否 | 指明提醒的目标时间。 |
935| repeatMonths | Array\<number> | 否 | 是 | 指明重复提醒的月份。 |
936| repeatDays | Array\<number> | 否 | 是 | 指明重复提醒的日期。 |
937| daysOfWeek<sup>11+</sup> | Array\<number> | 否 | 是 | 指明每周哪几天需要重复提醒。范围为周一到周日,对应数字为1到7。 |
938| endDateTime<sup>12+</sup> | [LocalDateTime](#localdatetime) | 否 | 是 | 指明提醒的结束时间。 |
939
940
941## ReminderRequestAlarm
942
943ReminderRequestAlarm extends ReminderRequest
944
945闹钟实例对象,用于设置提醒的时间。
946
947**系统能力**:SystemCapability.Notification.ReminderAgent
948
949| 名称 | 类型 | 只读 | 可选 | 说明 |
950| -------- | -------- | -------- | -------- | -------- |
951| hour | number | 否 | 否 | 指明提醒的目标时刻。 |
952| minute | number | 否 | 否 | 指明提醒的目标分钟。 |
953| daysOfWeek | Array\<number> | 否 | 是 | 指明每周哪几天需要重复提醒。范围为周一到周日,对应数字为1到7。 |
954
955
956## ReminderRequestTimer
957
958ReminderRequestTimer extends ReminderRequest
959
960倒计时实例对象,用于设置提醒的时间。
961
962**系统能力**:SystemCapability.Notification.ReminderAgent
963
964| 名称 | 类型 | 只读 | 可选 | 说明 |
965| -------- | -------- | -------- | -------- | -------- |
966| triggerTimeInSeconds | number | 否 | 否 | 指明倒计时的秒数。 |
967
968
969## LocalDateTime
970
971用于日历类提醒设置时指定时间信息。
972
973**系统能力**:SystemCapability.Notification.ReminderAgent
974
975| 名称 | 类型 | 只读 | 可选 | 说明 |
976| -------- | -------- | -------- | -------- | -------- |
977| year | number | 否 | 否 | 年 |
978| month | number | 否 | 否 | 月,取值范围是[1, 12]。 |
979| day | number | 否 | 否 | 日,取值范围是[1, 31]。 |
980| hour | number | 否 | 否 | 时,取值范围是[0, 23]。 |
981| minute | number | 否 | 否 | 分,取值范围是[0, 59]。 |
982| second | number | 否 | 是 | 秒,取值范围是[0, 59]。 |
983
984## ReminderInfo<sup>12+</sup>
985
986代理提醒信息,包含 ReminderRequest 和 ReminderId。
987
988**系统能力**:SystemCapability.Notification.ReminderAgent
989
990| 名称        | 类型                                | 只读 | 可选 | 说明                 |
991| ----------- | ----------------------------------- | ---- | ---- | -------------------- |
992| reminderId  | number                              | 否   | 否   | 发布提醒后返回的id。 |
993| reminderReq | [ReminderRequest](#reminderrequest) | 否   | 否   | 代理提醒对象。       |
994
995