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