• 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     * @syscap SystemCapability.Notification.ReminderAgent
258     * @since 7
259     * @deprecated since 9
260     * @useinstead reminderAgentManager.ActionButton.title
261     */
262    title: string;
263
264    /**
265     * Button type.
266     * @syscap SystemCapability.Notification.ReminderAgent
267     * @since 7
268     * @deprecated since 9
269     * @useinstead reminderAgentManager.ActionButton.type
270     */
271    type: ActionButtonType;
272  }
273
274  /**
275   * Want agent information.
276   * It will switch to target ability when you click the displayed reminder.
277   *
278   * @interface WantAgent
279   * @syscap SystemCapability.Notification.ReminderAgent
280   * @since 7
281   * @deprecated since 9
282   * @useinstead reminderAgentManager.WantAgent
283   */
284  interface WantAgent {
285    /**
286     * Name of the package redirected to when the reminder notification is clicked.
287     * @syscap SystemCapability.Notification.ReminderAgent
288     * @since 7
289     * @deprecated since 9
290     * @useinstead reminderAgentManager.WantAgent.pkgName
291     */
292    pkgName: string;
293
294    /**
295     * Name of the ability that is redirected to when the reminder notification is clicked.
296     * @syscap SystemCapability.Notification.ReminderAgent
297     * @since 7
298     * @deprecated since 9
299     * @useinstead reminderAgentManager.WantAgent.abilityName
300     */
301    abilityName: string;
302  }
303
304  /**
305   * Max screen want agent information.
306   *
307   * @interface MaxScreenWantAgent
308   * @syscap SystemCapability.Notification.ReminderAgent
309   * @since 7
310   * @deprecated since 9
311   * @useinstead reminderAgentManager.MaxScreenWantAgent
312   */
313  interface MaxScreenWantAgent {
314    /**
315     * Name of the package that is automatically started when the reminder arrives and the device is not in use.
316     * @syscap SystemCapability.Notification.ReminderAgent
317     * @since 7
318     * @deprecated since 9
319     * @useinstead reminderAgentManager.MaxScreenWantAgent.pkgName
320     */
321    pkgName: string;
322
323    /**
324     * Name of the ability that is automatically started when the reminder arrives and the device is not in use.
325     * @syscap SystemCapability.Notification.ReminderAgent
326     * @since 7
327     * @deprecated since 9
328     * @useinstead reminderAgentManager.MaxScreenWantAgent.abilityName
329     */
330    abilityName: string;
331  }
332
333  /**
334   * Reminder Common information.
335   *
336   * @interface ReminderRequest
337   * @syscap SystemCapability.Notification.ReminderAgent
338   * @since 7
339   * @deprecated since 9
340   * @useinstead reminderAgentManager.ReminderRequest
341   */
342  interface ReminderRequest {
343    /**
344     * Type of the reminder.
345     * @syscap SystemCapability.Notification.ReminderAgent
346     * @since 7
347     * @deprecated since 9
348     * @useinstead reminderAgentManager.ReminderRequest.reminderType
349     */
350    reminderType: ReminderType;
351
352    /**
353     * Action button displayed on the reminder notification.
354     * (The parameter is optional. Up to two buttons are supported).
355     * @syscap SystemCapability.Notification.ReminderAgent
356     * @since 7
357     * @deprecated since 9
358     * @useinstead reminderAgentManager.ReminderRequest.actionButton
359     */
360    actionButton?: [ActionButton?, ActionButton?];
361
362    /**
363     * Information about the ability that is redirected to when the notification is clicked.
364     * @syscap SystemCapability.Notification.ReminderAgent
365     * @since 7
366     * @deprecated since 9
367     * @useinstead reminderAgentManager.ReminderRequest.wantAgent
368     */
369    wantAgent?: WantAgent;
370
371    /**
372     * Information about the ability that is automatically started when the reminder arrives.
373     * If the device is in use, a notification will be displayed.
374     * @syscap SystemCapability.Notification.ReminderAgent
375     * @since 7
376     * @deprecated since 9
377     * @useinstead reminderAgentManager.ReminderRequest.maxScreenWantAgent
378     */
379    maxScreenWantAgent?: MaxScreenWantAgent;
380
381    /**
382     * Ringing duration.
383     * @syscap SystemCapability.Notification.ReminderAgent
384     * @since 7
385     * @deprecated since 9
386     * @useinstead reminderAgentManager.ReminderRequest.ringDuration
387     */
388    ringDuration?: number;
389
390    /**
391     * Number of reminder snooze times.
392     * @syscap SystemCapability.Notification.ReminderAgent
393     * @since 7
394     * @deprecated since 9
395     * @useinstead reminderAgentManager.ReminderRequest.snoozeTimes
396     */
397    snoozeTimes?: number;
398
399    /**
400     * Reminder snooze interval.
401     * @syscap SystemCapability.Notification.ReminderAgent
402     * @since 7
403     * @deprecated since 9
404     * @useinstead reminderAgentManager.ReminderRequest.timeInterval
405     */
406    timeInterval?: number;
407
408    /**
409     * Reminder title.
410     * @syscap SystemCapability.Notification.ReminderAgent
411     * @since 7
412     * @deprecated since 9
413     * @useinstead reminderAgentManager.ReminderRequest.title
414     */
415    title?: string;
416
417    /**
418     * Reminder content.
419     * @syscap SystemCapability.Notification.ReminderAgent
420     * @since 7
421     * @deprecated since 9
422     * @useinstead reminderAgentManager.ReminderRequest.content
423     */
424    content?: string;
425
426    /**
427     * Content to be displayed when the reminder is expired.
428     * @syscap SystemCapability.Notification.ReminderAgent
429     * @since 7
430     * @deprecated since 9
431     * @useinstead reminderAgentManager.ReminderRequest.expiredContent
432     */
433    expiredContent?: string;
434
435    /**
436     * Content to be displayed when the reminder is snoozing.
437     * @syscap SystemCapability.Notification.ReminderAgent
438     * @since 7
439     * @deprecated since 9
440     * @useinstead reminderAgentManager.ReminderRequest.snoozeContent
441     */
442    snoozeContent?: string;
443
444    /**
445     * notification id. If there are reminders with the same ID, the later one will overwrite the earlier one.
446     * @syscap SystemCapability.Notification.ReminderAgent
447     * @since 7
448     * @deprecated since 9
449     * @useinstead reminderAgentManager.ReminderRequest.notificationId
450     */
451    notificationId?: number;
452
453    /**
454     * Type of the slot used by the reminder.
455     * @syscap SystemCapability.Notification.ReminderAgent
456     * @since 7
457     * @deprecated since 9
458     * @useinstead reminderAgentManager.ReminderRequest.slotType
459     */
460    slotType?: notification.SlotType;
461  }
462
463  /**
464   * @interface ReminderRequestCalendar
465   * @syscap SystemCapability.Notification.ReminderAgent
466   * @since 7
467   * @deprecated since 9
468   * @useinstead reminderAgentManager.ReminderRequestCalendar
469   */
470  interface ReminderRequestCalendar extends ReminderRequest {
471    /**
472     * Reminder time.
473     * @syscap SystemCapability.Notification.ReminderAgent
474     * @since 7
475     * @deprecated since 9
476     * @useinstead reminderAgentManager.ReminderRequestCalendar.dateTime
477     */
478    dateTime: LocalDateTime;
479
480    /**
481     * Month in which the reminder repeats.
482     * @syscap SystemCapability.Notification.ReminderAgent
483     * @since 7
484     * @deprecated since 9
485     * @useinstead reminderAgentManager.ReminderRequestCalendar.repeatMonths
486     */
487    repeatMonths?: Array<number>;
488
489    /**
490     * Date on which the reminder repeats.
491     * @syscap SystemCapability.Notification.ReminderAgent
492     * @since 7
493     * @deprecated since 9
494     * @useinstead reminderAgentManager.ReminderRequestCalendar.repeatDays
495     */
496    repeatDays?: Array<number>;
497  }
498
499  /**
500   * Alarm reminder information.
501   *
502   * @interface ReminderRequestAlarm
503   * @syscap SystemCapability.Notification.ReminderAgent
504   * @since 7
505   * @deprecated since 9
506   * @useinstead reminderAgentManager.ReminderRequestAlarm
507   */
508  interface ReminderRequestAlarm extends ReminderRequest {
509    /**
510     * Hour portion of the reminder time.
511     * @syscap SystemCapability.Notification.ReminderAgent
512     * @since 7
513     * @deprecated since 9
514     * @useinstead reminderAgentManager.ReminderRequestAlarm.hour
515     */
516    hour: number;
517
518    /**
519     * minute portion of the remidner time.
520     * @syscap SystemCapability.Notification.ReminderAgent
521     * @since 7
522     * @deprecated since 9
523     * @useinstead reminderAgentManager.ReminderRequestAlarm.minute
524     */
525    minute: number;
526
527    /**
528     * Days of a week when the reminder repeates.
529     * @syscap SystemCapability.Notification.ReminderAgent
530     * @since 7
531     * @deprecated since 9
532     * @useinstead reminderAgentManager.ReminderRequestAlarm.daysOfWeek
533     */
534    daysOfWeek?: Array<number>;
535  }
536
537  /**
538   * CountDown reminder information.
539   *
540   * @interface ReminderRequestTimer
541   * @syscap SystemCapability.Notification.ReminderAgent
542   * @since 7
543   * @deprecated since 9
544   * @useinstead reminderAgentManager.ReminderRequestTimer
545   */
546  interface ReminderRequestTimer extends ReminderRequest {
547    /**
548     * value of triggerTimeInSeconds.
549     * @syscap SystemCapability.Notification.ReminderAgent
550     * @since 7
551     * @deprecated since 9
552     * @useinstead reminderAgentManager.ReminderRequestTimer.triggerTimeInSeconds
553     */
554    triggerTimeInSeconds: number;
555  }
556
557  /**
558   * Local DateTime information.
559   *
560   * @interface LocalDateTime
561   * @syscap SystemCapability.Notification.ReminderAgent
562   * @since 7
563   * @deprecated since 9
564   * @useinstead reminderAgentManager.ReminderRequestTimer
565   */
566  interface LocalDateTime {
567    /**
568     * value of year.
569     * @syscap SystemCapability.Notification.ReminderAgent
570     * @since 7
571     * @deprecated since 9
572     * @useinstead reminderAgentManager.ReminderRequestTimer.year
573     */
574    year: number;
575
576    /**
577     * value of month.
578     * @syscap SystemCapability.Notification.ReminderAgent
579     * @since 7
580     * @deprecated since 9
581     * @useinstead reminderAgentManager.ReminderRequestTimer.month
582     */
583    month: number;
584
585    /**
586     * value of day.
587     * @syscap SystemCapability.Notification.ReminderAgent
588     * @since 7
589     * @deprecated since 9
590     * @useinstead reminderAgentManager.ReminderRequestTimer.day
591     */
592    day: number;
593
594    /**
595     * value of hour.
596     * @syscap SystemCapability.Notification.ReminderAgent
597     * @since 7
598     * @deprecated since 9
599     * @useinstead reminderAgentManager.ReminderRequestTimer.hour
600     */
601    hour: number;
602
603    /**
604     * value of minute.
605     * @syscap SystemCapability.Notification.ReminderAgent
606     * @since 7
607     * @deprecated since 9
608     * @useinstead reminderAgentManager.ReminderRequestTimer.minute
609     */
610    minute: number;
611
612    /**
613     * value of second.
614     * @syscap SystemCapability.Notification.ReminderAgent
615     * @since 7
616     * @deprecated since 9
617     * @useinstead reminderAgentManager.ReminderRequestTimer.second
618     */
619    second?: number;
620  }
621}
622export default reminderAgent;
623