1/* 2 * Copyright (c) 2021 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 16import { AsyncCallback } from './basic'; 17import notification from './@ohos.notification'; 18import { NotificationSlot } from './notification/notificationSlot'; 19 20/** 21 * Providers static methods for managing reminders, including publishing or canceling a reminder. 22 * adding or removing a notification slot, and obtaining or cancelling all reminders of the current application. 23 * 24 * @since 7 25 * @syscap SystemCapability.Notification.ReminderAgent 26 * @import reminderAgent from '@ohos.reminderAgent'; 27 */ 28declare namespace reminderAgent { 29 /** 30 * Publishes a scheduled reminder. 31 * 32 * @since 7 33 * @syscap SystemCapability.Notification.ReminderAgent 34 * @permission ohos.permission.PUBLISH_AGENT_REMINDER 35 * @param reminderReq Indicates the reminder instance to publish. 36 * @param callback Indicates the callback function. 37 * @returns reminder id. 38 */ 39 function publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback<number>): void; 40 function publishReminder(reminderReq: ReminderRequest): Promise<number>; 41 42 /** 43 * Cancels a reminder. 44 * 45 * @since 7 46 * @syscap SystemCapability.Notification.ReminderAgent 47 * @param reminderId Indicates the reminder id. 48 * @param callback Indicates the callback function. 49 */ 50 function cancelReminder(reminderId: number, callback: AsyncCallback<void>): void; 51 function cancelReminder(reminderId: number): Promise<void>; 52 53 /** 54 * Obtains all the valid reminders of current application. 55 * 56 * @since 7 57 * @syscap SystemCapability.Notification.ReminderAgent 58 * @param callback Indicates the callback function. 59 */ 60 function getValidReminders(callback: AsyncCallback<Array<ReminderRequest>>): void; 61 function getValidReminders(): Promise<Array<ReminderRequest>>; 62 63 /** 64 * Cancels all the reminders of current application. 65 * 66 * @since 7 67 * @syscap SystemCapability.Notification.ReminderAgent 68 * @param callback Indicates the callback function. 69 */ 70 function cancelAllReminders(callback: AsyncCallback<void>): void; 71 function cancelAllReminders(): Promise<void>; 72 73 /** 74 * Add notification slot. 75 * 76 * @since 7 77 * @syscap SystemCapability.Notification.ReminderAgent 78 * @param slot Indicates the slot. 79 * @param callback Indicates the callback function. 80 */ 81 function addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback<void>): void; 82 function addNotificationSlot(slot: NotificationSlot): Promise<void>; 83 84 /** 85 * Deletes a created notification slot based on the slot type. 86 * 87 * @since 7 88 * @syscap SystemCapability.Notification.ReminderAgent 89 * @param slotType Indicates the type of the slot. 90 * @param callback Indicates the callback function. 91 */ 92 function removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback<void>): void; 93 function removeNotificationSlot(slotType: notification.SlotType): Promise<void>; 94 95 /** 96 * Declares action button type. 97 * 98 * @since 7 99 * @syscap SystemCapability.Notification.ReminderAgent 100 */ 101 export enum ActionButtonType { 102 /** 103 * Button for closing the reminder. 104 * @since 7 105 * @syscap SystemCapability.Notification.ReminderAgent 106 */ 107 ACTION_BUTTON_TYPE_CLOSE = 0, 108 109 /** 110 * Button for snoozing the reminder. 111 * @since 7 112 * @syscap SystemCapability.Notification.ReminderAgent 113 */ 114 ACTION_BUTTON_TYPE_SNOOZE = 1 115 } 116 117 /** 118 * Declares reminder type. 119 * 120 * @since 7 121 * @syscap SystemCapability.Notification.ReminderAgent 122 */ 123 export enum ReminderType { 124 /** 125 * Countdown reminder. 126 * @since 7 127 * @syscap SystemCapability.Notification.ReminderAgent 128 */ 129 REMINDER_TYPE_TIMER = 0, 130 131 /** 132 * Calendar reminder. 133 * @since 7 134 * @syscap SystemCapability.Notification.ReminderAgent 135 */ 136 REMINDER_TYPE_CALENDAR = 1, 137 138 /** 139 * Alarm reminder. 140 * @since 7 141 * @syscap SystemCapability.Notification.ReminderAgent 142 */ 143 REMINDER_TYPE_ALARM = 2 144 } 145 146 /** 147 * Action button information. The button will show on displayed reminder. 148 * 149 * @since 7 150 * @syscap SystemCapability.Notification.ReminderAgent 151 */ 152 interface ActionButton { 153 /** 154 * Text on the button. 155 * @since 7 156 * @syscap SystemCapability.Notification.ReminderAgent 157 */ 158 title: string; 159 160 /** 161 * Button type. 162 * @since 7 163 * @syscap SystemCapability.Notification.ReminderAgent 164 */ 165 type: ActionButtonType; 166 } 167 168 /** 169 * Want agent information. 170 * It will switch to target ability when you click the displayed reminder. 171 * 172 * @since 7 173 * @syscap SystemCapability.Notification.ReminderAgent 174 */ 175 interface WantAgent { 176 /** 177 * Name of the package redirected to when the reminder notification is clicked. 178 * @since 7 179 * @syscap SystemCapability.Notification.ReminderAgent 180 */ 181 pkgName: string; 182 183 /** 184 * Name of the ability that is redirected to when the reminder notification is clicked. 185 * @since 7 186 * @syscap SystemCapability.Notification.ReminderAgent 187 */ 188 abilityName: string; 189 } 190 191 /** 192 * Max screen want agent information. 193 * 194 * @since 7 195 * @syscap SystemCapability.Notification.ReminderAgent 196 */ 197 interface MaxScreenWantAgent { 198 /** 199 * Name of the package that is automatically started when the reminder arrives and the device is not in use. 200 * @since 7 201 * @syscap SystemCapability.Notification.ReminderAgent 202 */ 203 pkgName: string; 204 205 /** 206 * Name of the ability that is automatically started when the reminder arrives and the device is not in use. 207 * @since 7 208 * @syscap SystemCapability.Notification.ReminderAgent 209 */ 210 abilityName: string; 211 } 212 213 /** 214 * Reminder Common information. 215 * 216 * @since 7 217 * @syscap SystemCapability.Notification.ReminderAgent 218 */ 219 interface ReminderRequest { 220 /** 221 * Type of the reminder. 222 * @since 7 223 * @syscap SystemCapability.Notification.ReminderAgent 224 */ 225 reminderType: ReminderType; 226 227 /** 228 * Action button displayed on the reminder notification. 229 * (The parameter is optional. Up to two buttons are supported). 230 * @since 7 231 * @syscap SystemCapability.Notification.ReminderAgent 232 */ 233 actionButton?: [ActionButton?, ActionButton?]; 234 235 /** 236 * Information about the ability that is redirected to when the notification is clicked. 237 * @since 7 238 * @syscap SystemCapability.Notification.ReminderAgent 239 */ 240 wantAgent?: WantAgent; 241 242 /** 243 * Information about the ability that is automatically started when the reminder arrives. 244 * If the device is in use, a notification will be displayed. 245 * @since 7 246 * @syscap SystemCapability.Notification.ReminderAgent 247 */ 248 maxScreenWantAgent?: MaxScreenWantAgent; 249 250 /** 251 * Ringing duration. 252 * @since 7 253 * @syscap SystemCapability.Notification.ReminderAgent 254 */ 255 ringDuration?: number; 256 257 /** 258 * Number of reminder snooze times. 259 * @since 7 260 * @syscap SystemCapability.Notification.ReminderAgent 261 */ 262 snoozeTimes?: number; 263 264 /** 265 * Reminder snooze interval. 266 * @since 7 267 * @syscap SystemCapability.Notification.ReminderAgent 268 */ 269 timeInterval?: number; 270 271 /** 272 * Reminder title. 273 * @since 7 274 * @syscap SystemCapability.Notification.ReminderAgent 275 */ 276 title?: string; 277 278 /** 279 * Reminder content. 280 * @since 7 281 * @syscap SystemCapability.Notification.ReminderAgent 282 */ 283 content?: string; 284 285 /** 286 * Content to be displayed when the reminder is expired. 287 * @since 7 288 * @syscap SystemCapability.Notification.ReminderAgent 289 */ 290 expiredContent?: string; 291 292 /** 293 * Content to be displayed when the reminder is snoozing. 294 * @since 7 295 * @syscap SystemCapability.Notification.ReminderAgent 296 */ 297 snoozeContent?: string; 298 299 /** 300 * notification id. If there are reminders with the same ID, the later one will overwrite the earlier one. 301 * @since 7 302 * @syscap SystemCapability.Notification.ReminderAgent 303 */ 304 notificationId?: number; 305 306 /** 307 * Type of the slot used by the reminder. 308 * @since 7 309 * @syscap SystemCapability.Notification.ReminderAgent 310 */ 311 slotType?: notification.SlotType; 312 } 313 314 interface ReminderRequestCalendar extends ReminderRequest { 315 /** 316 * Reminder time. 317 * @since 7 318 * @syscap SystemCapability.Notification.ReminderAgent 319 */ 320 dateTime: LocalDateTime; 321 322 /** 323 * Month in which the reminder repeats. 324 * @since 7 325 * @syscap SystemCapability.Notification.ReminderAgent 326 */ 327 repeatMonths?: Array<number>; 328 329 /** 330 * Date on which the reminder repeats. 331 * @since 7 332 * @syscap SystemCapability.Notification.ReminderAgent 333 */ 334 repeatDays?: Array<number>; 335 } 336 337 /** 338 * Alarm reminder information. 339 * 340 * @since 7 341 * @syscap Define alarm reminder object. 342 */ 343 interface ReminderRequestAlarm extends ReminderRequest { 344 /** 345 * Hour portion of the reminder time. 346 * @since 7 347 * @syscap SystemCapability.Notification.ReminderAgent 348 */ 349 hour: number; 350 351 /** 352 * minute portion of the remidner time. 353 * @since 7 354 * @syscap SystemCapability.Notification.ReminderAgent 355 */ 356 minute: number; 357 358 /** 359 * Days of a week when the reminder repeates. 360 * @since 7 361 * @syscap SystemCapability.Notification.ReminderAgent 362 */ 363 daysOfWeek?: Array<number>; 364 } 365 366 /** 367 * CountDown reminder information. 368 * 369 * @since 7 370 * @syscap SystemCapability.Notification.ReminderAgent 371 */ 372 interface ReminderRequestTimer extends ReminderRequest { 373 triggerTimeInSeconds: number; 374 } 375 376 interface LocalDateTime { 377 /** 378 * value of year. 379 * @since 7 380 * @syscap SystemCapability.Notification.ReminderAgent 381 */ 382 year: number; 383 384 /** 385 * value of month. 386 * @since 7 387 * @syscap SystemCapability.Notification.ReminderAgent 388 */ 389 month: number; 390 391 /** 392 * value of day. 393 * @since 7 394 * @syscap SystemCapability.Notification.ReminderAgent 395 */ 396 day: number; 397 398 /** 399 * value of hour. 400 * @since 7 401 * @syscap SystemCapability.Notification.ReminderAgent 402 */ 403 hour: number; 404 405 /** 406 * value of minute. 407 * @since 7 408 * @syscap SystemCapability.Notification.ReminderAgent 409 */ 410 minute: number; 411 412 /** 413 * value of second. 414 * @since 7 415 * @syscap SystemCapability.Notification.ReminderAgent 416 */ 417 second?: number; 418 } 419} 420export default reminderAgent; 421