• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License"),
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit BackgroundTasksKit
19 */
20
21import { AsyncCallback } from './@ohos.base';
22import notification from './@ohos.notification';
23import { NotificationSlot } from './notification/notificationSlot';
24
25/**
26 * Providers static methods for managing reminders, including publishing or canceling a reminder.
27 * adding or removing a notification slot, and obtaining or cancelling all reminders of the current application.
28 *
29 * @namespace reminderAgent
30 * @syscap SystemCapability.Notification.ReminderAgent
31 * @since 7
32 * @deprecated since 9
33 * @useinstead reminderAgentManager
34 */
35declare namespace reminderAgent {
36  /**
37   * Publishes a scheduled reminder.
38   *
39   * @permission ohos.permission.PUBLISH_AGENT_REMINDER
40   * @param { ReminderRequest } reminderReq Indicates the reminder instance to publish.
41   * @param { AsyncCallback<number> } callback Indicates the callback function.
42   * @syscap SystemCapability.Notification.ReminderAgent
43   * @since 7
44   * @deprecated since 9
45   * @useinstead reminderAgentManager.publishReminder
46   */
47  function publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback<number>): void;
48
49  /**
50   * Publishes a scheduled reminder.
51   *
52   * @permission ohos.permission.PUBLISH_AGENT_REMINDER
53   * @param { ReminderRequest } reminderReq Indicates the reminder instance to publish.
54   * @returns { Promise<number> } reminder id.
55   * @syscap SystemCapability.Notification.ReminderAgent
56   * @since 7
57   * @deprecated since 9
58   * @useinstead reminderAgentManager.publishReminder
59   */
60  function publishReminder(reminderReq: ReminderRequest): Promise<number>;
61
62  /**
63   * Cancels a reminder.
64   *
65   * @param { number } reminderId Indicates the reminder id.
66   * @param { AsyncCallback<void> } callback Indicates the callback function.
67   * @syscap SystemCapability.Notification.ReminderAgent
68   * @since 7
69   * @deprecated since 9
70   * @useinstead reminderAgentManager.cancelReminder
71   */
72  function cancelReminder(reminderId: number, callback: AsyncCallback<void>): void;
73
74  /**
75   * Cancels a reminder.
76   *
77   * @param { number } reminderId Indicates the reminder id.
78   * @returns { Promise<void> }
79   * @syscap SystemCapability.Notification.ReminderAgent
80   * @since 7
81   * @deprecated since 9
82   * @useinstead reminderAgentManager.cancelReminder
83   */
84  function cancelReminder(reminderId: number): Promise<void>;
85
86  /**
87   * Obtains all the valid reminders of current application.
88   *
89   * @param { AsyncCallback<Array<ReminderRequest>> } callback Indicates the callback function.
90   * @syscap SystemCapability.Notification.ReminderAgent
91   * @since 7
92   * @deprecated since 9
93   * @useinstead reminderAgentManager.getValidReminders
94   */
95  function getValidReminders(callback: AsyncCallback<Array<ReminderRequest>>): void;
96
97  /**
98   * Obtains all the valid reminders of current application.
99   *
100   * @returns { Promise<Array<ReminderRequest>> } Reminder Common information.
101   * @syscap SystemCapability.Notification.ReminderAgent
102   * @since 7
103   * @deprecated since 9
104   * @useinstead reminderAgentManager.getValidReminders
105   */
106  function getValidReminders(): Promise<Array<ReminderRequest>>;
107
108  /**
109   * Cancels all the reminders of current application.
110   *
111   * @param { AsyncCallback<void> } callback Indicates the callback function.
112   * @syscap SystemCapability.Notification.ReminderAgent
113   * @since 7
114   * @deprecated since 9
115   * @useinstead reminderAgentManager.cancelAllReminders
116   */
117  function cancelAllReminders(callback: AsyncCallback<void>): void;
118
119  /**
120   * Cancels all the reminders of current application.
121   *
122   * @returns { Promise<void> }
123   * @syscap SystemCapability.Notification.ReminderAgent
124   * @since 7
125   * @deprecated since 9
126   * @useinstead reminderAgentManager.cancelAllReminders
127   */
128  function cancelAllReminders(): Promise<void>;
129
130  /**
131   * Add notification slot.
132   *
133   * @param { NotificationSlot } slot Indicates the slot.
134   * @param { AsyncCallback<void> } callback Indicates the callback function.
135   * @syscap SystemCapability.Notification.ReminderAgent
136   * @since 7
137   * @deprecated since 9
138   * @useinstead reminderAgentManager.addNotificationSlot
139   */
140  function addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback<void>): void;
141
142  /**
143   * Add notification slot.
144   *
145   * @param { NotificationSlot } slot Indicates the slot.
146   * @returns { Promise<void> }
147   * @syscap SystemCapability.Notification.ReminderAgent
148   * @since 7
149   * @deprecated since 9
150   * @useinstead reminderAgentManager.addNotificationSlot
151   */
152  function addNotificationSlot(slot: NotificationSlot): Promise<void>;
153
154  /**
155   * Deletes a created notification slot based on the slot type.
156   *
157   * @param { notification.SlotType } slotType Indicates the type of the slot.
158   * @param { AsyncCallback<void> } callback Indicates the callback function.
159   * @syscap SystemCapability.Notification.ReminderAgent
160   * @since 7
161   * @deprecated since 9
162   * @useinstead reminderAgentManager.removeNotificationSlot
163   */
164  function removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback<void>): void;
165
166  /**
167   * Deletes a created notification slot based on the slot type.
168   *
169   * @param { notification.SlotType } slotType Indicates the type of the slot.
170   * @returns { Promise<void> }
171   * @syscap SystemCapability.Notification.ReminderAgent
172   * @since 7
173   * @deprecated since 9
174   * @useinstead reminderAgentManager.removeNotificationSlot
175   */
176  function removeNotificationSlot(slotType: notification.SlotType): Promise<void>;
177
178  /**
179   * Declares action button type.
180   *
181   * @enum { number }
182   * @syscap SystemCapability.Notification.ReminderAgent
183   * @since 7
184   * @deprecated since 9
185   * @useinstead reminderAgentManager.ActionButtonType
186   */
187  export enum ActionButtonType {
188    /**
189     * Button for closing the reminder.
190     * @syscap SystemCapability.Notification.ReminderAgent
191     * @since 7
192     * @deprecated since 9
193     * @useinstead reminderAgentManager.ActionButtonType.ACTION_BUTTON_TYPE_CLOSE
194     */
195    ACTION_BUTTON_TYPE_CLOSE = 0,
196
197    /**
198     * Button for snoozing the reminder.
199     * @syscap SystemCapability.Notification.ReminderAgent
200     * @since 7
201     * @deprecated since 9
202     * @useinstead reminderAgentManager.ActionButtonType.ACTION_BUTTON_TYPE_SNOOZE
203     */
204    ACTION_BUTTON_TYPE_SNOOZE = 1
205  }
206
207  /**
208   * Declares reminder type.
209   *
210   * @enum { number }
211   * @syscap SystemCapability.Notification.ReminderAgent
212   * @since 7
213   * @deprecated since 9
214   * @useinstead reminderAgentManager.ReminderType
215   */
216  export enum ReminderType {
217    /**
218     * Countdown reminder.
219     * @syscap SystemCapability.Notification.ReminderAgent
220     * @since 7
221     * @deprecated since 9
222     * @useinstead reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER
223     */
224    REMINDER_TYPE_TIMER = 0,
225
226    /**
227     * Calendar reminder.
228     * @syscap SystemCapability.Notification.ReminderAgent
229     * @since 7
230     * @deprecated since 9
231     * @useinstead reminderAgentManager.ReminderType.REMINDER_TYPE_CALENDAR
232     */
233    REMINDER_TYPE_CALENDAR = 1,
234
235    /**
236     * Alarm reminder.
237     * @syscap SystemCapability.Notification.ReminderAgent
238     * @since 7
239     * @deprecated since 9
240     * @useinstead reminderAgentManager.ReminderType.REMINDER_TYPE_ALARM
241     */
242    REMINDER_TYPE_ALARM = 2
243  }
244
245  /**
246   * Action button information. The button will show on displayed reminder.
247   *
248   * @interface ActionButton
249   * @syscap SystemCapability.Notification.ReminderAgent
250   * @since 7
251   * @deprecated since 9
252   * @useinstead reminderAgentManager.ActionButton
253   */
254  interface ActionButton {
255    /**
256     * Text on the button.
257     * @type { string }
258     * @syscap SystemCapability.Notification.ReminderAgent
259     * @since 7
260     * @deprecated since 9
261     * @useinstead reminderAgentManager.ActionButton.title
262     */
263    title: string;
264
265    /**
266     * Button type.
267     * @type { ActionButtonType }
268     * @syscap SystemCapability.Notification.ReminderAgent
269     * @since 7
270     * @deprecated since 9
271     * @useinstead reminderAgentManager.ActionButton.type
272     */
273    type: ActionButtonType;
274  }
275
276  /**
277   * Want agent information.
278   * It will switch to target ability when you click the displayed reminder.
279   *
280   * @interface WantAgent
281   * @syscap SystemCapability.Notification.ReminderAgent
282   * @since 7
283   * @deprecated since 9
284   * @useinstead reminderAgentManager.WantAgent
285   */
286  interface WantAgent {
287    /**
288     * Name of the package redirected to when the reminder notification is clicked.
289     * @type { string }
290     * @syscap SystemCapability.Notification.ReminderAgent
291     * @since 7
292     * @deprecated since 9
293     * @useinstead reminderAgentManager.WantAgent.pkgName
294     */
295    pkgName: string;
296
297    /**
298     * Name of the ability that is redirected to when the reminder notification is clicked.
299     * @type { string }
300     * @syscap SystemCapability.Notification.ReminderAgent
301     * @since 7
302     * @deprecated since 9
303     * @useinstead reminderAgentManager.WantAgent.abilityName
304     */
305    abilityName: string;
306  }
307
308  /**
309   * Max screen want agent information.
310   *
311   * @interface MaxScreenWantAgent
312   * @syscap SystemCapability.Notification.ReminderAgent
313   * @since 7
314   * @deprecated since 9
315   * @useinstead reminderAgentManager.MaxScreenWantAgent
316   */
317  interface MaxScreenWantAgent {
318    /**
319     * Name of the package that is automatically started when the reminder arrives and the device is not in use.
320     * @type { string }
321     * @syscap SystemCapability.Notification.ReminderAgent
322     * @since 7
323     * @deprecated since 9
324     * @useinstead reminderAgentManager.MaxScreenWantAgent.pkgName
325     */
326    pkgName: string;
327
328    /**
329     * Name of the ability that is automatically started when the reminder arrives and the device is not in use.
330     * @type { string }
331     * @syscap SystemCapability.Notification.ReminderAgent
332     * @since 7
333     * @deprecated since 9
334     * @useinstead reminderAgentManager.MaxScreenWantAgent.abilityName
335     */
336    abilityName: string;
337  }
338
339  /**
340   * Reminder Common information.
341   *
342   * @interface ReminderRequest
343   * @syscap SystemCapability.Notification.ReminderAgent
344   * @since 7
345   * @deprecated since 9
346   * @useinstead reminderAgentManager.ReminderRequest
347   */
348  interface ReminderRequest {
349    /**
350     * Type of the reminder.
351     * @type { ReminderType }
352     * @syscap SystemCapability.Notification.ReminderAgent
353     * @since 7
354     * @deprecated since 9
355     * @useinstead reminderAgentManager.ReminderRequest.reminderType
356     */
357    reminderType: ReminderType;
358
359    /**
360     * Action button displayed on the reminder notification.
361     * (The parameter is optional. Up to two buttons are supported).
362     * @type { ?[ActionButton?, ActionButton?] }
363     * @syscap SystemCapability.Notification.ReminderAgent
364     * @since 7
365     * @deprecated since 9
366     * @useinstead reminderAgentManager.ReminderRequest.actionButton
367     */
368    actionButton?: [ActionButton?, ActionButton?];
369
370    /**
371     * Information about the ability that is redirected to when the notification is clicked.
372     * @type { ?WantAgent }
373     * @syscap SystemCapability.Notification.ReminderAgent
374     * @since 7
375     * @deprecated since 9
376     * @useinstead reminderAgentManager.ReminderRequest.wantAgent
377     */
378    wantAgent?: WantAgent;
379
380    /**
381     * Information about the ability that is automatically started when the reminder arrives.
382     * If the device is in use, a notification will be displayed.
383     * @type { ?MaxScreenWantAgent }
384     * @syscap SystemCapability.Notification.ReminderAgent
385     * @since 7
386     * @deprecated since 9
387     * @useinstead reminderAgentManager.ReminderRequest.maxScreenWantAgent
388     */
389    maxScreenWantAgent?: MaxScreenWantAgent;
390
391    /**
392     * Ringing duration.
393     * @type { ?number }
394     * @syscap SystemCapability.Notification.ReminderAgent
395     * @since 7
396     * @deprecated since 9
397     * @useinstead reminderAgentManager.ReminderRequest.ringDuration
398     */
399    ringDuration?: number;
400
401    /**
402     * Number of reminder snooze times.
403     * @type { ?number }
404     * @syscap SystemCapability.Notification.ReminderAgent
405     * @since 7
406     * @deprecated since 9
407     * @useinstead reminderAgentManager.ReminderRequest.snoozeTimes
408     */
409    snoozeTimes?: number;
410
411    /**
412     * Reminder snooze interval.
413     * @type { ?number }
414     * @syscap SystemCapability.Notification.ReminderAgent
415     * @since 7
416     * @deprecated since 9
417     * @useinstead reminderAgentManager.ReminderRequest.timeInterval
418     */
419    timeInterval?: number;
420
421    /**
422     * Reminder title.
423     * @type { ?string }
424     * @syscap SystemCapability.Notification.ReminderAgent
425     * @since 7
426     * @deprecated since 9
427     * @useinstead reminderAgentManager.ReminderRequest.title
428     */
429    title?: string;
430
431    /**
432     * Reminder content.
433     * @type { ?string }
434     * @syscap SystemCapability.Notification.ReminderAgent
435     * @since 7
436     * @deprecated since 9
437     * @useinstead reminderAgentManager.ReminderRequest.content
438     */
439    content?: string;
440
441    /**
442     * Content to be displayed when the reminder is expired.
443     * @type { ?string }
444     * @syscap SystemCapability.Notification.ReminderAgent
445     * @since 7
446     * @deprecated since 9
447     * @useinstead reminderAgentManager.ReminderRequest.expiredContent
448     */
449    expiredContent?: string;
450
451    /**
452     * Content to be displayed when the reminder is snoozing.
453     * @type { ?string }
454     * @syscap SystemCapability.Notification.ReminderAgent
455     * @since 7
456     * @deprecated since 9
457     * @useinstead reminderAgentManager.ReminderRequest.snoozeContent
458     */
459    snoozeContent?: string;
460
461    /**
462     * notification id. If there are reminders with the same ID, the later one will overwrite the earlier one.
463     * @type { ?number }
464     * @syscap SystemCapability.Notification.ReminderAgent
465     * @since 7
466     * @deprecated since 9
467     * @useinstead reminderAgentManager.ReminderRequest.notificationId
468     */
469    notificationId?: number;
470
471    /**
472     * Type of the slot used by the reminder.
473     * @type { ?notification.SlotType }
474     * @syscap SystemCapability.Notification.ReminderAgent
475     * @since 7
476     * @deprecated since 9
477     * @useinstead reminderAgentManager.ReminderRequest.slotType
478     */
479    slotType?: notification.SlotType;
480  }
481
482  /**
483   * @interface ReminderRequestCalendar
484   * @syscap SystemCapability.Notification.ReminderAgent
485   * @since 7
486   * @deprecated since 9
487   * @useinstead reminderAgentManager.ReminderRequestCalendar
488   */
489  interface ReminderRequestCalendar extends ReminderRequest {
490    /**
491     * Reminder time.
492     * @type { LocalDateTime }
493     * @syscap SystemCapability.Notification.ReminderAgent
494     * @since 7
495     * @deprecated since 9
496     * @useinstead reminderAgentManager.ReminderRequestCalendar.dateTime
497     */
498    dateTime: LocalDateTime;
499
500    /**
501     * Month in which the reminder repeats.
502     * @type { ?Array<number> }
503     * @syscap SystemCapability.Notification.ReminderAgent
504     * @since 7
505     * @deprecated since 9
506     * @useinstead reminderAgentManager.ReminderRequestCalendar.repeatMonths
507     */
508    repeatMonths?: Array<number>;
509
510    /**
511     * Date on which the reminder repeats.
512     * @type { ?Array<number> }
513     * @syscap SystemCapability.Notification.ReminderAgent
514     * @since 7
515     * @deprecated since 9
516     * @useinstead reminderAgentManager.ReminderRequestCalendar.repeatDays
517     */
518    repeatDays?: Array<number>;
519  }
520
521  /**
522   * Alarm reminder information.
523   *
524   * @interface ReminderRequestAlarm
525   * @syscap SystemCapability.Notification.ReminderAgent
526   * @since 7
527   * @deprecated since 9
528   * @useinstead reminderAgentManager.ReminderRequestAlarm
529   */
530  interface ReminderRequestAlarm extends ReminderRequest {
531    /**
532     * Hour portion of the reminder time.
533     * @type { number }
534     * @syscap SystemCapability.Notification.ReminderAgent
535     * @since 7
536     * @deprecated since 9
537     * @useinstead reminderAgentManager.ReminderRequestAlarm.hour
538     */
539    hour: number;
540
541    /**
542     * minute portion of the remidner time.
543     * @type { number }
544     * @syscap SystemCapability.Notification.ReminderAgent
545     * @since 7
546     * @deprecated since 9
547     * @useinstead reminderAgentManager.ReminderRequestAlarm.minute
548     */
549    minute: number;
550
551    /**
552     * Days of a week when the reminder repeates.
553     * @type { ?Array<number> }
554     * @syscap SystemCapability.Notification.ReminderAgent
555     * @since 7
556     * @deprecated since 9
557     * @useinstead reminderAgentManager.ReminderRequestAlarm.daysOfWeek
558     */
559    daysOfWeek?: Array<number>;
560  }
561
562  /**
563   * CountDown reminder information.
564   *
565   * @interface ReminderRequestTimer
566   * @syscap SystemCapability.Notification.ReminderAgent
567   * @since 7
568   * @deprecated since 9
569   * @useinstead reminderAgentManager.ReminderRequestTimer
570   */
571  interface ReminderRequestTimer extends ReminderRequest {
572    /**
573     * value of triggerTimeInSeconds.
574     * @type { number }
575     * @syscap SystemCapability.Notification.ReminderAgent
576     * @since 7
577     * @deprecated since 9
578     * @useinstead reminderAgentManager.ReminderRequestTimer.triggerTimeInSeconds
579     */
580    triggerTimeInSeconds: number;
581  }
582
583  /**
584   * Local DateTime information.
585   *
586   * @interface LocalDateTime
587   * @syscap SystemCapability.Notification.ReminderAgent
588   * @since 7
589   * @deprecated since 9
590   * @useinstead reminderAgentManager.ReminderRequestTimer
591   */
592  interface LocalDateTime {
593    /**
594     * value of year.
595     * @type { number }
596     * @syscap SystemCapability.Notification.ReminderAgent
597     * @since 7
598     * @deprecated since 9
599     * @useinstead reminderAgentManager.ReminderRequestTimer.year
600     */
601    year: number;
602
603    /**
604     * value of month.
605     * @type { number }
606     * @syscap SystemCapability.Notification.ReminderAgent
607     * @since 7
608     * @deprecated since 9
609     * @useinstead reminderAgentManager.ReminderRequestTimer.month
610     */
611    month: number;
612
613    /**
614     * value of day.
615     * @type { number }
616     * @syscap SystemCapability.Notification.ReminderAgent
617     * @since 7
618     * @deprecated since 9
619     * @useinstead reminderAgentManager.ReminderRequestTimer.day
620     */
621    day: number;
622
623    /**
624     * value of hour.
625     * @type { number }
626     * @syscap SystemCapability.Notification.ReminderAgent
627     * @since 7
628     * @deprecated since 9
629     * @useinstead reminderAgentManager.ReminderRequestTimer.hour
630     */
631    hour: number;
632
633    /**
634     * value of minute.
635     * @type { number }
636     * @syscap SystemCapability.Notification.ReminderAgent
637     * @since 7
638     * @deprecated since 9
639     * @useinstead reminderAgentManager.ReminderRequestTimer.minute
640     */
641    minute: number;
642
643    /**
644     * value of second.
645     * @type { ?number }
646     * @syscap SystemCapability.Notification.ReminderAgent
647     * @since 7
648     * @deprecated since 9
649     * @useinstead reminderAgentManager.ReminderRequestTimer.second
650     */
651    second?: number;
652  }
653}
654export default reminderAgent;
655