openharmony 鸿蒙 js-apis-reminderAgentManager

2025-06-12 浏览 (1)

@ohos.reminderAgentManager (Agent-Powered Reminders)

The reminderAgentManager module provides APIs related to agent-powered reminders. When your application is frozen or exits, the timing and notification functions of your application will be taken over by a system service running in the background. You can use the APIs to create scheduled reminders for countdown timers, calendar events, and alarm clocks.

NOTE

The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Modules to Import

import { reminderAgentManager } from '@kit.BackgroundTasksKit';

reminderAgentManager.publishReminder

publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback<number>): void

Publishes a reminder. This API uses an asynchronous callback to return the result.

NOTE

This API can be called only after the NotificationManager.requestEnableNotification permission is obtained.

Required permissions: ohos.permission.PUBLISH_AGENT_REMINDER

System capability: SystemCapability.Notification.ReminderAgent

Parameters

NameTypeMandatoryDescription
reminderReqReminderRequestYesRequest used for publishing the reminder.
callbackAsyncCallback<number>YesCallback used to return the published reminder's ID.

Error codes

For details about the error codes, see reminderAgentManager Error Codes and Universal Error Codes.

IDError Message
401If the input parameter is not valid parameter.
1700001Notification is not enabled.
1700002The number of reminders exceeds the limit.

Example

import { BusinessError } from '@kit.BasicServicesKit';

let timer: reminderAgentManager.ReminderRequestTimer = {
  reminderType: reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER,
  triggerTimeInSeconds: 10
}

reminderAgentManager.publishReminder(timer, (err: BusinessError, reminderId: number) => {
  if (err.code) {
    console.error("callback err code:" + err.code + " message:" + err.message);
  } else {
    console.log("callback, reminderId = " + reminderId);
  }
});

reminderAgentManager.publishReminder

publishReminder(reminderReq: ReminderRequest): Promise<number>

Publishes a reminder. This API uses a promise to return the result.

NOTE

This API can be called only after the NotificationManager.requestEnableNotification permission is obtained.

Required permissions: ohos.permission.PUBLISH_AGENT_REMINDER

System capability: SystemCapability.Notification.ReminderAgent

Parameters

NameTypeMandatoryDescription
reminderReqReminderRequestYesRequest used for publishing the reminder.

Return value

TypeDescription
Promise<number>Promise used to return the published reminder ID.

Error codes

For details about the error codes, see reminderAgentManager Error Codes and Universal Error Codes.

IDError Message
401If the input parameter is not valid parameter.
1700001Notification is not enabled.
1700002The number of reminders exceeds the limit.

Example

import { BusinessError } from '@kit.BasicServicesKit';

let timer: reminderAgentManager.ReminderRequestTimer = {
  reminderType: reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER,
  triggerTimeInSeconds: 10
}

reminderAgentManager.publishReminder(timer).then((reminderId: number) => {
  console.log("promise, reminderId = " + reminderId);
}).catch((err: BusinessError) => {
  console.error("promise err code:" + err.code + " message:" + err.message);
});

reminderAgentManager.cancelReminder

cancelReminder(reminderId: number, callback: AsyncCallback<void>): void

Cancels a reminder published. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Notification.ReminderAgent

Parameters

NameTypeMandatoryDescription
reminderIdnumberYesID of the reminder to cancel.
callbackAsyncCallback<void>YesCallback used to return the result. If the reminder is canceled, err is undefined. Otherwise, err is an error object.

Error codes

For details about the error codes, see reminderAgentManager Error Codes and Universal Error Codes.

IDError Message
401If the input parameter is not valid parameter.
1700003The reminder does not exist.
1700004The bundle name does not exist.

Example

import { BusinessError } from '@kit.BasicServicesKit';

let reminderId: number = 1;
reminderAgentManager.cancelReminder(reminderId, (err: BusinessError) => {
  if (err.code) {
    console.error("callback err code:" + err.code + " message:" + err.message);
  } else {
    console.log("cancelReminder callback");
  }
});

reminderAgentManager.cancelReminder

cancelReminder(reminderId: number): Promise<void>

Cancels a reminder published. This API uses a promise to return the result.

System capability: SystemCapability.Notification.ReminderAgent

Parameters

NameTypeMandatoryDescription
reminderIdnumberYesID of the reminder to cancel.

Return value

TypeDescription
Promise<void>Promise that returns no value.

Error codes

For details about the error codes, see reminderAgentManager Error Codes and Universal Error Codes.

IDError Message
401If the input parameter is not valid parameter.
1700003The reminder does not exist.
1700004The bundle name does not exist.

Example

import { BusinessError } from '@kit.BasicServicesKit';

let reminderId: number = 1;
reminderAgentManager.cancelReminder(reminderId).then(() => {
  console.log("cancelReminder promise");
}).catch((err: BusinessError) => {
  console.error("promise err code:" + err.code + " message:" + err.message);
});

reminderAgentManager.getValidReminders

getValidReminders(callback: AsyncCallback<Array<ReminderRequest>>): void

Obtains all valid (not yet expired) reminders set by the current application. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Notification.ReminderAgent

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<Array<ReminderRequest>>YesCallback used to return all the valid reminders.

Error codes

For details about the error codes, see reminderAgentManager Error Codes and Universal Error Codes.

IDError Message
401If the input parameter is not valid parameter.
1700004The bundle name does not exist.

Example

import { BusinessError } from '@kit.BasicServicesKit';

reminderAgentManager.getValidReminders((err: BusinessError, reminders: Array<reminderAgentManager.ReminderRequest>) => {
  if (err.code) {
    console.error("callback err code:" + err.code + " message:" + err.message);
  } else {
    console.log("callback, getValidReminders length = " + reminders.length);
    for (let i = 0; i < reminders.length; i++) {
      console.log("getValidReminders = " + reminders[i]);
      console.log("getValidReminders, reminderType = " + reminders[i].reminderType);
      const actionButton = reminders[i].actionButton||[];
      for (let j = 0; j < actionButton.length; j++) {
        console.log("getValidReminders, actionButton.title = " + actionButton[j]?.title);
        console.log("getValidReminders, actionButton.type = " + actionButton[j]?.type);
      }
      console.log("getValidReminders, wantAgent.pkgName = " + reminders[i].wantAgent?.pkgName);
      console.log("getValidReminders, wantAgent.abilityName = " + reminders[i].wantAgent?.abilityName);
      console.log("getValidReminders, ringDuration = " + reminders[i].ringDuration);
      console.log("getValidReminders, snoozeTimes = " + reminders[i].snoozeTimes);
      console.log("getValidReminders, timeInterval = " + reminders[i].timeInterval);
      console.log("getValidReminders, title = " + reminders[i].title);
      console.log("getValidReminders, content = " + reminders[i].content);
      console.log("getValidReminders, expiredContent = " + reminders[i].expiredContent);
      console.log("getValidReminders, snoozeContent = " + reminders[i].snoozeContent);
      console.log("getValidReminders, notificationId = " + reminders[i].notificationId);
      console.log("getValidReminders, slotType = " + reminders[i].slotType);
    }
  }
});

reminderAgentManager.getValidReminders

getValidReminders(): Promise<Array<ReminderRequest>>

Obtains all valid (not yet expired) reminders set by the current application. This API uses a promise to return the result.

System capability: SystemCapability.Notification.ReminderAgent

Return value

TypeDescription
Promise<Array<ReminderRequest>>Promise used to return all the valid reminders.

Error codes

For details about the error codes, see reminderAgentManager Error Codes and Universal Error Codes.

IDError Message
401If the input parameter is not valid parameter.
1700004The bundle name does not exist.

Example

import { BusinessError } from '@kit.BasicServicesKit';

reminderAgentManager.getValidReminders().then((reminders: Array<reminderAgentManager.ReminderRequest>) => {
  console.log("promise, getValidReminders length = " + reminders.length);
  for (let i = 0; i < reminders.length; i++) {
    console.log("getValidReminders = " + reminders[i]);
    console.log("getValidReminders, reminderType = " + reminders[i].reminderType);
    const actionButton = reminders[i].actionButton||[];
    for (let j = 0; j < actionButton.length; j++) {
      console.log("getValidReminders, actionButton.title = " + actionButton[j]?.title);
      console.log("getValidReminders, actionButton.type = " + actionButton[j]?.type);
    }
    console.log("getValidReminders, wantAgent.pkgName = " + reminders[i].wantAgent?.pkgName);
    console.log("getValidReminders, wantAgent.abilityName = " + reminders[i].wantAgent?.abilityName);
    console.log("getValidReminders, ringDuration = " + reminders[i].ringDuration);
    console.log("getValidReminders, snoozeTimes = " + reminders[i].snoozeTimes);
    console.log("getValidReminders, timeInterval = " + reminders[i].timeInterval);
    console.log("getValidReminders, title = " + reminders[i].title);
    console.log("getValidReminders, content = " + reminders[i].content);
    console.log("getValidReminders, expiredContent = " + reminders[i].expiredContent);
    console.log("getValidReminders, snoozeContent = " + reminders[i].snoozeContent);
    console.log("getValidReminders, notificationId = " + reminders[i].notificationId);
    console.log("getValidReminders, slotType = " + reminders[i].slotType);
  }
}).catch((err: BusinessError) => {
  console.error("promise err code:" + err.code + " message:" + err.message);
}); 

reminderAgentManager.cancelAllReminders

cancelAllReminders(callback: AsyncCallback<void>): void

Cancels all reminders set by the current application. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Notification.ReminderAgent

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<void>YesCallback used to return the result. If all the reminders are canceled, err is undefined. Otherwise, err is an error object.

Error codes

For details about the error codes, see reminderAgentManager Error Codes and Universal Error Codes.

IDError Message
401If the input parameter is not valid parameter.
1700004The bundle name does not exist.

Example

import { BusinessError } from '@kit.BasicServicesKit';

reminderAgentManager.cancelAllReminders((err: BusinessError) =>{
  if (err.code) {
    console.error("callback err code:" + err.code + " message:" + err.message);
  } else {
    console.log("cancelAllReminders callback")
  }
});

reminderAgentManager.cancelAllReminders

cancelAllReminders(): Promise<void>

Cancels all reminders set by the current application. This API uses a promise to return the result.

System capability: SystemCapability.Notification.ReminderAgent

Return value

TypeDescription
Promise<void>Promise that returns no value.

Error codes

For details about the error codes, see reminderAgentManager Error Codes and Universal Error Codes.

IDError Message
401If the input parameter is not valid parameter.
1700004The bundle name does not exist.

Example

import { BusinessError } from '@kit.BasicServicesKit';

reminderAgentManager.cancelAllReminders().then(() => {
  console.log("cancelAllReminders promise")
}).catch((err: BusinessError) => {
  console.error("promise err code:" + err.code + " message:" + err.message);
});

reminderAgentManager.addNotificationSlot

addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback<void>): void

Adds a notification slot. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Notification.ReminderAgent

Parameters

NameTypeMandatoryDescription
slotNotificationSlotYesnotificationManager.slot instance. Only notificationType can be set.
callbackAsyncCallback<void>YesCallback used to return the result. If the notification slot is added, err is undefined. Otherwise, err is an error object.

Error codes

For details about the error codes, see Universal Error Codes.

IDError Message
401If the input parameter is not valid parameter.

Example

import { notificationManager } from '@kit.NotificationKit';
import { BusinessError } from '@kit.BasicServicesKit';

let mySlot: notificationManager.NotificationSlot = {
  notificationType: notificationManager.SlotType.SOCIAL_COMMUNICATION
}

reminderAgentManager.addNotificationSlot(mySlot, (err: BusinessError) => {
  if (err.code) {
    console.error("callback err code:" + err.code + " message:" + err.message);
  } else {
    console.log("addNotificationSlot callback");
  }
});

reminderAgentManager.addNotificationSlot

addNotificationSlot(slot: NotificationSlot): Promise<void>

Adds a notification slot. This API uses a promise to return the result.

System capability: SystemCapability.Notification.ReminderAgent

Parameters

NameTypeMandatoryDescription
slotNotificationSlotYesnotificationManager.slot instance. Only notificationType can be set.

Return value

TypeDescription
Promise<void>Promise that returns no value.

Error codes

For details about the error codes, see Universal Error Codes.

IDError Message
401If the input parameter is not valid parameter.

Example

import { notificationManager } from '@kit.NotificationKit';
import { BusinessError } from '@kit.BasicServicesKit';

let mySlot: notificationManager.NotificationSlot = {
  notificationType: notificationManager.SlotType.SOCIAL_COMMUNICATION
}
reminderAgentManager.addNotificationSlot(mySlot).then(() => {
  console.log("addNotificationSlot promise");
}).catch((err: BusinessError) => {
  console.error("promise err code:" + err.code + " message:" + err.message);
});

reminderAgentManager.removeNotificationSlot

removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback<void>): void

Removes a notification slot. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Notification.ReminderAgent

Parameters

NameTypeMandatoryDescription
slotTypenotification.SlotTypeYesType of the notification slot.
callbackAsyncCallback<void>YesCallback used to return the result. If the notification slot is removed, err is undefined. Otherwise, err is an error object.

Error codes

For details about the error codes, see Universal Error Codes.

IDError Message
401If the input parameter is not valid parameter.

Example

import { notificationManager } from '@kit.NotificationKit';
import { BusinessError } from '@kit.BasicServicesKit';

reminderAgentManager.removeNotificationSlot(notificationManager.SlotType.CONTENT_INFORMATION,
  (err: BusinessError) => {
  if (err.code) {
    console.error("callback err code:" + err.code + " message:" + err.message);
  } else {
    console.log("removeNotificationSlot callback");
  }
});

reminderAgentManager.removeNotificationSlot

removeNotificationSlot(slotType: notification.SlotType): Promise<void>

Removes a notification slot. This API uses a promise to return the result.

System capability: SystemCapability.Notification.ReminderAgent

Parameters

NameTypeMandatoryDescription
slotTypenotification.SlotTypeYesType of the notification slot.

Return value

TypeDescription
Promise<void>Promise that returns no value.

Error codes

For details about the error codes, see Universal Error Codes.

IDError Message
401If the input parameter is not valid parameter.

Example

import { notificationManager } from '@kit.NotificationKit';
import { BusinessError } from '@kit.BasicServicesKit';

reminderAgentManager.removeNotificationSlot(notificationManager.SlotType.CONTENT_INFORMATION).then(() => {
  console.log("removeNotificationSlot promise");
}).catch((err: BusinessError) => {
  console.error("promise err code:" + err.code + " message:" + err.message);
});

reminderAgentManager.getAllValidReminders12+

getAllValidReminders(): Promise<Array<ReminderInfo>>

Obtains all valid (not yet expired) reminders set by the current application. This API uses a promise to return the result.

System capability: SystemCapability.Notification.ReminderAgent

Return value

TypeDescription
Promise<Array<ReminderInfo>>Promise used to return all the valid reminders.

Error codes

For details about the error codes, see Universal Error Codes.

IDError Message
201Permission denied.

Example

import { BusinessError } from '@kit.BasicServicesKit';

reminderAgentManager.getAllValidReminders().then((reminders: Array<reminderAgentManager.ReminderInfo>) => {
  console.log("promise, getAllValidReminders length = " + reminders.length);
  for (let i = 0; i < reminders.length; i++) {
    console.log("getAllValidReminders, reminderId = " + reminders[i].reminderId);
    console.log("getAllValidReminders, reminderType = " + reminders[i].reminderReq.reminderType);
    const actionButton = reminders[i].reminderReq.actionButton||[];
    for (let j = 0; j < actionButton.length; j++) {
      console.log("getAllValidReminders, actionButton.title = " + actionButton[j]?.title);
      console.log("getAllValidReminders, actionButton.type = " + actionButton[j]?.type);
    }
    console.log("getAllValidReminders, wantAgent.pkgName = " + reminders[i].reminderReq.wantAgent?.pkgName);
    console.log("getAllValidReminders, wantAgent.abilityName = " + reminders[i].reminderReq.wantAgent?.abilityName);
    console.log("getAllValidReminders, ringDuration = " + reminders[i].reminderReq.ringDuration);
    console.log("getAllValidReminders, snoozeTimes = " + reminders[i].reminderReq.snoozeTimes);
    console.log("getAllValidReminders, timeInterval = " + reminders[i].reminderReq.timeInterval);
    console.log("getAllValidReminders, title = " + reminders[i].reminderReq.title);
    console.log("getAllValidReminders, content = " + reminders[i].reminderReq.content);
    console.log("getAllValidReminders, expiredContent = " + reminders[i].reminderReq.expiredContent);
    console.log("getAllValidReminders, snoozeContent = " + reminders[i].reminderReq.snoozeContent);
    console.log("getAllValidReminders, notificationId = " + reminders[i].reminderReq.notificationId);
    console.log("getAllValidReminders, slotType = " + reminders[i].reminderReq.slotType);
  }
}).catch((err: BusinessError) => {
  console.error("promise err code:" + err.code + " message:" + err.message);
}); 

reminderAgentManager.addExcludeDate12+

addExcludeDate(reminderId: number, date: Date): Promise<void>

Adds a non-reminder date for a recurring calendar reminder with a specific ID. For example, configure a daily reminder to skip notifications on Tuesdays. This API uses a promise to return the result.

System capability: SystemCapability.Notification.ReminderAgent

Parameters

NameTypeMandatoryDescription
reminderIdnumberYesID of the recurring calendar reminder.
dateDateYesNon-reminder date.

Return value

TypeDescription
Promise<void>Promise that returns no value.

Error codes

For details about the error codes, see reminderAgentManager Error Codes and Universal Error Codes.

IDError Message
201Permission denied.
401If the input parameter is not valid parameter.
1700003The reminder does not exist.

Example

import { BusinessError } from '@kit.BasicServicesKit';

let reminderId: number = 1;
let date = new Date();
reminderAgentManager.addExcludeDate(reminderId, date).then(() => {
  console.log("addExcludeDate promise");
}).catch((err: BusinessError) => {
  console.error("promise err code:" + err.code + " message:" + err.message);
});

reminderAgentManager.deleteExcludeDates12+

deleteExcludeDates(reminderId: number): Promise<void>

Deletes all non-reminder dates for a recurring calendar reminder with a specific ID. This API uses a promise to return the result.

System capability: SystemCapability.Notification.ReminderAgent

Parameters

NameTypeMandatoryDescription
reminderIdnumberYesID of the recurring calendar reminder.

Return value

TypeDescription
Promise<void>Promise that returns no value.

Error codes

For details about the error codes, see reminderAgentManager Error Codes and Universal Error Codes.

IDError Message
201Permission denied.
1700003The reminder does not exist.

Example

import { BusinessError } from '@kit.BasicServicesKit';

let reminderId: number = 1;
reminderAgentManager.deleteExcludeDates(reminderId).then(() => {
  console.log("deleteExcludeDates promise");
}).catch((err: BusinessError) => {
  console.error("promise err code:" + err.code + " message:" + err.message);
});

reminderAgentManager.getExcludeDates12+

getExcludeDates(reminderId: number): Promise<Array<Date>>

Obtains all non-reminder dates for a recurring calendar reminder with a specific ID. This API uses a promise to return the result.

System capability: SystemCapability.Notification.ReminderAgent

Parameters

NameTypeMandatoryDescription
reminderIdnumberYesID of the recurring calendar reminder.

Return value

TypeDescription
Promise<Array<Date>>Promise used to return all the non-reminder dates.

Error codes

For details about the error codes, see reminderAgentManager Error Codes and Universal Error Codes.

IDError Message
201Permission denied.
1700003The reminder does not exist.

Example

import { BusinessError } from '@kit.BasicServicesKit';

let reminderId: number = 1;
reminderAgentManager.getExcludeDates(reminderId).then((dates) => {
  console.log("getExcludeDates promise length: " + dates.length);
  for (let i = 0; i < dates.length; i++) {
	console.log("getExcludeDates promise date is: " + dates[i].toString());
  }
}).catch((err: BusinessError) => {
  console.error("promise err code:" + err.code + " message:" + err.message);
});

ActionButtonType

Enumerates the types of buttons displayed for a reminder.

System capability: SystemCapability.Notification.ReminderAgent

NameValueDescription
ACTION_BUTTON_TYPE_CLOSE0Button for closing the reminder.
ACTION_BUTTON_TYPE_SNOOZE1Button for snoozing the reminder, with the frequency and timing configured via snoozeTimes and timeInterval in the ReminderRequest struct.

ReminderType

Enumerates the reminder types.

System capability: SystemCapability.Notification.ReminderAgent

NameValueDescription
REMINDER_TYPE_TIMER0Countdown reminder.
REMINDER_TYPE_CALENDAR1Calendar reminder.
REMINDER_TYPE_ALARM2Alarm reminder.

ActionButton

Describes the button displayed for a reminder.

System capability: SystemCapability.Notification.ReminderAgent

NameTypeMandatoryDescription
titlestringYesText on the button.
titleResource11+stringNoResource ID of the title. This parameter is used to read the title information after the system language is switched.
typeActionButtonTypeYesButton type.

WantAgent

Defines the information about the redirected-to ability.

System capability: SystemCapability.Notification.ReminderAgent

NameTypeMandatoryDescription
pkgNamestringYesName of the target package.
abilityNamestringYesName of the target ability.
parameters12+Record<string, Object>NoParameters to be transferred to the target.
uri12+stringNoURI of the target ability.

MaxScreenWantAgent

Describes the information about the ability that is started automatically and displayed in full-screen mode when a reminder is displayed in the notification center. This API is reserved.

System capability: SystemCapability.Notification.ReminderAgent

NameTypeMandatoryDescription
pkgNamestringYesName of the target package. (If the device is in use, only a notification banner is displayed.)
abilityNamestringYesName of the target ability. (If the device is in use, only a notification banner is displayed.)

ReminderRequest

Defines the request for publishing a reminder.

System capability: SystemCapability.Notification.ReminderAgent

NameTypeMandatoryDescription
reminderTypeReminderTypeYesType of the reminder.
actionButton[ActionButton?, ActionButton?, ActionButton?]NoButtons displayed for the reminder notification.
- For common applications, a maximum of two buttons are supported.
- For system applications, a maximum of two buttons are supported in API version 9, and a maximum of three buttons are supported in API version 10 and later versions.
wantAgentWantAgentNoInformation about the ability that is redirected to when the reminder is clicked.
maxScreenWantAgentMaxScreenWantAgentNoInformation about the ability that is started automatically and displayed in full-screen mode when the reminder arrives. If the device is in use, only a notification banner is displayed.
This API is reserved.
ringDurationnumberNoRinging duration, in seconds. The default value is 1.
snoozeTimesnumberNoNumber of reminder snooze times. The default value is 0. (It is not applicable to countdown reminders.)
timeIntervalnumberNoReminder snooze interval, in seconds. The minimum value is 5 minutes. (It is not applicable to countdown reminders.)
titlestringNoReminder title.
titleResourceId18+numberNoResource ID of the reminder title.
contentstringNoReminder content.
contentResourceId18+numberNoResource ID of the reminder content.
expiredContentstringNoContent to be displayed after the reminder expires.
expiredContentResourceId18+numberNoResource ID of the content to be displayed after the reminder expires.
snoozeContentstringNoContent to be displayed when the reminder is snoozing. (It is not applicable to countdown reminders.)
snoozeContentResourceId18+numberNoResource ID of the content to be displayed when the reminder is snoozing.
notificationIdnumberNoNotification ID used by the reminder. You must pass in a notification ID. If there are reminders with the same notification ID, the later one will overwrite the earlier one.
groupId11+stringNoGroup ID used for the reminder. If "Don't ask again" or similar information is selected for the reminder, other reminders with the same group ID are also canceled.
slotTypenotification.SlotTypeNoType of the slot used by the reminder.
tapDismissed10+booleanNoWhether the reminder is automatically cleared. For details, see NotificationRequest.tapDismissed.
autoDeletedTime10+numberNoTime when the reminder is automatically cleared. For details, see NotificationRequest.autoDeletedTime.
snoozeSlotType11+notification.SlotTypeNoType of the slot used by the snoozed reminder. (It is not applicable to countdown reminders.)
customRingUri11+stringNoURI of the custom prompt tone. The prompt tone file must be stored in the resources/rawfile directory and supports formats such as M4A, AAC, MP3, OGG, WAV, FLAC, and AMR.

ReminderRequestCalendar

ReminderRequestCalendar extends ReminderRequest

Defines a reminder for a calendar event.

System capability: SystemCapability.Notification.ReminderAgent

NameTypeMandatoryDescription
dateTimeLocalDateTimeYesReminder time.
repeatMonthsArray<number>NoMonth in which the reminder repeats.
repeatDaysArray<number>NoDate on which the reminder repeats.
daysOfWeek11+Array<number>NoDays of a week when the reminder repeats. The value ranges from 1 to 7, corresponding to the data from Monday to Sunday.
endDateTime12+LocalDateTimeNoEnd time of the reminder.

ReminderRequestAlarm

ReminderRequestAlarm extends ReminderRequest

Defines a reminder for an alarm.

System capability: SystemCapability.Notification.ReminderAgent

NameTypeMandatoryDescription
hournumberYesHour portion of the reminder time.
minutenumberYesMinute portion of the reminder time.
daysOfWeekArray<number>NoDays of a week when the reminder repeats. The value ranges from 1 to 7, corresponding to the data from Monday to Sunday.

ReminderRequestTimer

ReminderRequestTimer extends ReminderRequest

Defines a reminder for a scheduled timer.

System capability: SystemCapability.Notification.ReminderAgent

NameTypeMandatoryDescription
triggerTimeInSecondsnumberYesNumber of seconds in the countdown timer.

LocalDateTime

Defines the time information for a calendar reminder.

System capability: SystemCapability.Notification.ReminderAgent

NameTypeMandatoryDescription
yearnumberYesYear.
monthnumberYesMonth. The value ranges from 1 to 12.
daynumberYesDay. The value ranges from 1 to 31.
hournumberYesHour. The value ranges from 0 to 23.
minutenumberYesMinute. The value ranges from 0 to 59.
secondnumberNoSecond. The value ranges from 0 to 59.

ReminderInfo12+

Defines the reminder information.

System capability: SystemCapability.Notification.ReminderAgent

NameTypeRead OnlyOptionalDescription
reminderIdnumberNoNoID of the reminder.
reminderReqReminderRequestNoNoRequest used for publishing the reminder.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Background Tasks Kit

harmony 鸿蒙BackgroundProcessManager

harmony 鸿蒙TransientTask

harmony 鸿蒙TransientTask_DelaySuspendInfo

harmony 鸿蒙background_process_manager.h

harmony 鸿蒙DeviceUsageStatistics Error Codes

harmony 鸿蒙backgroundTaskManager Error Codes

harmony 鸿蒙reminderAgentManager Error Codes

harmony 鸿蒙workScheduler Error Codes

harmony 鸿蒙@ohos.WorkSchedulerExtensionAbility (Deferred Task Scheduling Callbacks)

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/ajFha2