npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@capacitor-ohos/local-notifications

v8.0.0

Published

The Local Notifications API provides a way to schedule device notifications locally (i.e. without a server sending push notifications).

Readme

@capacitor/local-notifications

zh-CN en

本项目基于 @capacitor/[email protected] 开发。

简介

本地通知 API 提供了一种在本地安排设备通知的方式。本插件是 capacitor 生态系统中的核心插件,为跨平台应用开发提供设备差异化适配能力,兼容 capacitor 的 Android、iOS 等主流移动平台及浏览器环境中使用,本文档仅说明在 OpenHarmony 系统中的使用情况。

定时通知中,普通应用如果没有代理提醒的权限,提醒数量为 0,单个普通应用提醒数量不超过 30 个。

支持平台

  • OpenHarmony:5.0+

下载安装

通过命令行或手动引入即可快速安装插件,支持从npm仓库获取。

命令行安装(推荐)

安装hionic CLI:

npm install -g hionic

以下两种方式中任选其一即可,无需重复操作:

npm安装:

# 安装插件
npm install @capacitor/local-notifications

# 同步插件
hionic sync

hionic CLI安装:

hionic plugin add @capacitor/local-notifications

手动引入安装

根据插件源码中 plugin.xml 配置在项目中引入插件:

1. 添加插件配置

根据 plugin.xmlconfig-json 项,找到 entry 模块中 capacitor.plugins.json 文件,并根据 param 标签添加配置如下:

[
  {
    "pkg": "@capacitor/local-notifications",
    "classpath": "LocalNotifications"
  }
]

2. 修改 CMake 配置

根据 plugin.xmlCMakeLists 项,找到 capacitor 模块,路径为 target 字段的 CMakeLists.txt 文件,并添加 add_subdirectorytarget_link_libraries 如下:

// ...
add_subdirectory(LocalNotifications)
// ...

// ...
target_link_libraries(capacitor PUBLIC
  "-Wl,--whole-archive"
  // ...
  LocalNotifications
  // ...
  "-Wl,--no-whole-archive"
// ...
)

3. 复制源码文件

根据 plugin.xmlsource-file 项,根据 src 字段找到需要复制的文件,并复制到对应的目录:

将源码中 src/main/cpp/LocalNotifications 目录下的 LocalNotifications.h、LocalNotifications.cpp、CMakeLists.txt 文件引入到 capacitor 模块中 src/main/cpp/LocalNotifications 目录下。

将源码中 src/main/ets/components/LocalNotifications 目录下的 LocalNotifications.ets、LocalNotificationModel.ets、NotificationStorage.ets、NotificationAction.ets 文件引入到 capacitor 模块中 src/main/ets/components/LocalNotifications 目录下。

capacitor 模块的 build-profile.json5 文件中,buildOption/arkOptions/runtimeOnly/sources 配置项数组中加入拷贝的 ets 文件路径:

"buildOption": {
  // ...
  "arkOptions": {
    "runtimeOnly": [
      // ...
      "./src/main/ets/components/LocalNotifications/LocalNotifications.ets"
      // ...
    ]
  }
}

卸载

# 卸载 local-notifications 插件
hionic plugin remove @capacitor/local-notifications

约束与限制

兼容性

在以下版本中已测试通过:

  1. SDK: 5.0.5(17); IDE: DevEco Studio: 6.0.0; ROM: 5.1.0.150;

权限要求

不需要额外权限。

配置

以下配置可用:

| 数据 | 类型 | 描述 | | ------------- | --------- | -------------- | | channelId | Channel | 决定通知的展示通道 |

示例

capacitor.config.json

位置:capacitor.config.json

{
  "plugins": {
    "localNotifications": {
      "channelId": 1
    }
  }
}

使用示例

基础示例 1:安排一个或多个本地通知

import { LocalNotifications } from '@capacitor/local-notifications';

const handleSchedule = async (params = notificationParams.value.schedule) => {
  try {
    const notifId = params.id || Math.floor(Date.now() / 1000);

    // 自动将生成的 ID 赋值给取消和移除操作的参数
    notificationParams.value.cancel.id = notifId;
    notificationParams.value.removeDelivered.id = notifId;

    // 处理调度时间
    let schedule = params.schedule;
    const scheduleAt = (params as any).scheduleAt;
    if (scheduleAt) {
      schedule = {
        at: new Date(scheduleAt)
      };
    }

    await LocalNotifications.schedule({
      notifications: [
        {
          title: params.title,
          body: params.body,
          largeBody: params.largeBody,
          id: notifId,
          smallIcon: params.smallIcon,
          largeIcon: params.largeIcon,
          extra: params.extra ? JSON.parse(params.extra) : undefined,
          channelId: params.channelId,
          ongoing: params.ongoing,
          autoCancel: params.autoCancel,
          inboxList: params.inboxList ? params.inboxList.split(',') : undefined,
          schedule: schedule
        }
      ]
    });
    apiButtonSectionRef.value?.updateButtonResult('schedule', {
      status: 'success',
      data: {
        rawResponse: {}
      },
      message: `将在 ${schedule.at ? new Date(schedule.at).toLocaleString() : '指定时间'} 发送通知,ID: ${notifId}`
    });
  } catch (error) {
    apiButtonSectionRef.value?.updateButtonResult('schedule', {
      status: 'error',
      data: {
        rawResponse: error
      },
      message: `安排通知失败: ${error instanceof Error ? error.message : String(error)}`
    });
  }
};

基础示例 2:获取待处理的通知

const handleGetPending = async () => {
  try {
    const pending = await LocalNotifications.getPending();
    apiButtonSectionRef.value?.updateButtonResult('get-pending', {
      status: 'success',
      data: {
        result: pending,
        rawResponse: pending
      },
      message: `待处理通知数量: ${pending.notifications.length}`
    });
  } catch (error) {
    apiButtonSectionRef.value?.updateButtonResult('get-pending', {
      status: 'error',
      data: {
        rawResponse: error
      },
      message: `获取待处理通知失败: ${error instanceof Error ? error.message : String(error)}`
    });
  }
};

基础示例 3:注册通知显示时要执行的操作

const handleRegisterActionTypes = async (params = notificationParams.value.registerActionTypes) => {
  try {
    // 处理 actions 参数,将 JSON 字符串转换为对象
    let actions: any = params.actions;
    if (typeof actions === 'string') {
      actions = JSON.parse(actions);
    }

    await LocalNotifications.registerActionTypes({
      types: [
        {
          id: params.typeId,
          actions: actions
        }
      ]
    });

    apiButtonSectionRef.value?.updateButtonResult('register-action-types', {
      status: 'success',
      data: {
        rawResponse: {}
      },
      message: '操作类型已注册'
    });
  } catch (error) {
    apiButtonSectionRef.value?.updateButtonResult('register-action-types', {
      status: 'error',
      data: {
        rawResponse: error
      },
      message: `注册操作类型失败: ${error instanceof Error ? error.message : String(error)}`
    });
  }
};

基础示例 4:取消某个定时提醒

const handleCancel = async (params = notificationParams.value.cancel) => {
  try {
    await LocalNotifications.cancel({
      notifications: [{ id: params.id }]
    });
    apiButtonSectionRef.value?.updateButtonResult('cancel', {
      status: 'success',
      data: {
        rawResponse: {}
      },
      message: `已取消通知,ID: ${params.id}`
    });
  } catch (error) {
    apiButtonSectionRef.value?.updateButtonResult('cancel', {
      status: 'error',
      data: {
        rawResponse: error
      },
      message: `取消通知失败: ${error instanceof Error ? error.message : String(error)}`
    });
  }
};

基础示例 5:检查本地通知是否可用

const handleAreEnabled = async () => {
  try {
    const result = await LocalNotifications.areEnabled();
    apiButtonSectionRef.value?.updateButtonResult('are-enabled', {
      status: 'success',
      data: {
        result,
        rawResponse: result
      },
      message: `通知是否启用: ${result.value ? '是' : '否'}`
    });
  } catch (error) {
    apiButtonSectionRef.value?.updateButtonResult('are-enabled', {
      status: 'error',
      data: {
        rawResponse: error
      },
      message: `检查通知状态失败: ${error instanceof Error ? error.message : String(error)}`
    });
  }
};

基础示例 6:检查本地通知权限是否已授予

const handleCheckPermissions = async () => {
  try {
    const result = await LocalNotifications.checkPermissions();
    apiButtonSectionRef.value?.updateButtonResult('check-permissions', {
      status: 'success',
      data: {
        result,
        rawResponse: result
      },
      message: `通知权限: ${result.display}`
    });
  } catch (error) {
    apiButtonSectionRef.value?.updateButtonResult('check-permissions', {
      status: 'error',
      data: {
        rawResponse: error
      },
      message: `检查权限失败: ${error instanceof Error ? error.message : String(error)}`
    });
  }
};

基础示例 7:本地通知请求权限

const handleRequestPermissions = async () => {
  try {
    const result = await LocalNotifications.requestPermissions();
    apiButtonSectionRef.value?.updateButtonResult('request-permissions', {
      status: 'success',
      data: {
        result,
        rawResponse: result
      },
      message: `请求权限结果: ${result.display}`
    });
  } catch (error) {
    apiButtonSectionRef.value?.updateButtonResult('request-permissions', {
      status: 'error',
      data: {
        rawResponse: error
      },
      message: `请求权限失败: ${error instanceof Error ? error.message : String(error)}`
    });
  }
};

基础示例 8:删除所有状态栏上的通知

const handleRemoveAllDeliveredNotifications = async () => {
  try {
    await LocalNotifications.removeAllDeliveredNotifications();
    apiButtonSectionRef.value?.updateButtonResult('remove-all-delivered', {
      status: 'success',
      message: '已移除所有已送达的通知'
    });
  } catch (error) {
    apiButtonSectionRef.value?.updateButtonResult('remove-all-delivered', {
      status: 'error',
      data: {
        rawResponse: error
      },
      message: `移除已送达通知失败: ${error instanceof Error ? error.message : String(error)}`
    });
  }
};

基础示例 9:删除状态栏上的某个通知

const handleRemoveDeliveredNotifications = async (params = notificationParams.value.removeDelivered) => {
  try {
    await LocalNotifications.removeDeliveredNotifications({
      notifications: [{ 
        id: params.id,
        title: params.title || 'Notification',
        body: params.body || 'Notification body'
      }]
    });
    apiButtonSectionRef.value?.updateButtonResult('remove-delivered', {
      status: 'success',
      data: {
        rawResponse: {}
      },
      message: `已移除通知,ID: ${params.id}`
    });
  } catch (error) {
    apiButtonSectionRef.value?.updateButtonResult('remove-delivered', {
      status: 'error',
      data: {
        rawResponse: error
      },
      message: `移除已送达通知失败: ${error instanceof Error ? error.message : String(error)}`
    });
  }
};

基础示例 10:获取状态栏上的全部通知

const handleGetDeliveredNotifications = async () => {
  try {
    const result = await LocalNotifications.getDeliveredNotifications();
    apiButtonSectionRef.value?.updateButtonResult('get-delivered', {
      status: 'success',
      data: {
        result,
        rawResponse: result
      },
      message: `已送达通知数量: ${result.notifications.length}`
    });
  } catch (error) {
    apiButtonSectionRef.value?.updateButtonResult('get-delivered', {
      status: 'error',
      data: {
        rawResponse: error
      },
      message: `获取已送达通知失败: ${error instanceof Error ? error.message : String(error)}`
    });
  }
};

使用说明

接口方法

| 方法名 | 返回类型 | 描述 | | ------------------------------------------------------------------- | --------------------------------------- | ------------------------ | | schedule(options: ScheduleOptions | Promise<ScheduleResult> | 安排一个或多个本地通知。 || | getPending() | Promise<PendingResult]> | 获取待触发的通知。 | | registerActionTypes(options: RegisterActionTypesOptions) | Promise | 注册在显示通知时要采取的操作。 | | cancel(options: CancelOptions) | Promise | 取消待处理通知。 | | areEnabled() | Promise<EnabledResult]> | 检查通知是否已启用。 | | getDeliveredNotifications() | Promise<DeliveredNotifications]> | 获取通知屏幕上可见的通知列表。 | | removeDeliveredNotifications(delivered: DeliveredNotifications) | Promise | 从通知屏幕上移除指定的通知。 | | removeAllDeliveredNotifications() | Promise | 从通知屏幕移除所有通知。 | | createChannel(channel: Channel) | Promise | 暂不支持。 | | deleteChannel(args: { id: string; }) | Promise | 暂不支持。 | | listChannels() | Promise<ListChannelsResult]> | 暂不支持。 | | checkPermissions() | Promise<PermissionStatus]> | 检查显示本地通知的权限。 | | requestPermissions() | Promise<PermissionStatus]> | 请求显示本地通知的权限。 | | changeExactNotificationSetting() | Promise<SettingsPermissionStatus]> | 暂不支持。 | | checkExactNotificationSetting() | Promise<SettingsPermissionStatus]> | 暂不支持。 | | addListener('localNotificationReceived', ...) | Promise<PluginListenerHandle]> | 暂不支持。 | | addListener('localNotificationActionPerformed', ...) | Promise<PluginListenerHandle]> | 暂不支持。 | | removeAllListeners() | Promise | 暂不支持。 |

数据结构

ScheduleResult

| Prop | Type | Description | | ------------------- | ------------------------------- | ----------- | | notifications | LocalNotificationDescriptor[] | 预定通知列表。 |

LocalNotificationDescriptor

描述本地通知的对象。

| Prop | Type | Description | | -------- | -------- | ----------- | | id | number | 通知标识符。 |

ScheduleOptions

| Prop | Type | Description | |---------------------|-----------------------------|-------------| | notifications | LocalNotificationSchema[] | 要安排的通知列表。 |

LocalNotificationSchema

| Prop | Type | Description | |------------------------|----------------|--------------------------------------------------------------------------------------------------| | title | string | 通知的标题。 | | body | string | 通知正文,显示在标题下方,普通文本内容。 | | largeBody | string | 通知正文,显示在标题下方,长文本内容。 | | summaryText | string | 暂不支持。 | | id | string | 通知标识符。(仅存在即刻通知中,在定时通知中,schedule返回的id是取用取消待触发的通知) | | schedule | Schedule | 稍后安排此通知。 | | sound | string | 通知的响铃声,资源需放在resources/rawfile目录下(仅在即刻通知中生效)。 | | smallIcon | string | 通知状态栏上的图标,资源需放在resources/base/media目录下(仅在即刻通知中生效,且API小于20)。 | | largeIcon | string | 通知框中的一个大图标,图标应放置于应用的resources/base/media文件夹内(仅在即刻通知中生效) 。 | | iconColor | string | 暂不支持。 | | attachments | Attachment[] | 暂不支持。 | | actionTypeId | string | 将此通知与一种操作类型相关联。 | | extra | any | 设置额外数据以存储在此通知中(仅在即刻通知中生效) 。 | | threadIdentifier | string | 暂不支持。 | | summaryArgument | string | 暂不支持。 | | group | string | 即刻通知中支持。 | | groupSummary | string | 暂不支持。 | | channelId | Channel | 通知槽类型。默认值为OTHER_TYPES。(仅在即刻通知中生效,且需要在capacitor.config文件中配置) | | ongoing | boolean | 预留功能,暂不支持。 | | autoCancel | boolean | 通知是否自动清除。此参数仅在通知携带wantAgent或actionButtons时有效。 true(默认):点击通知或按钮后,当前通知自动清除。 false:点击通知或按钮后,当前通知保留。 | | inboxList | string[] | 通知正文,显示在标题下方。最多可显示三行内容,每行内容超长后以“...”截断。用在contentType是NOTIFICATION_CONTENT_MULTILINE的情况下是必填项 | | silent | string | 暂不支持。 |

Schedule

代表一个通知的时间表,使用“at”、“on”或“every”来安排通知。

| Prop | Type | Description | |----------------------|-----------------|------------------------------------------------------------------| | at | Date | 在特定日期和时间安排通知。格式如:2026-02-11T16:22:15,如果时间早于当前时间则立刻发送,定时最少延迟1分钟之后 | | repeats | boolean | 暂不支持。 | | allowWhileIdle | boolean | 暂不支持。 | | on | ScheduleOn | 暂不支持。 | | every | ScheduleEvery | 暂不支持。 | | count | number | 暂不支持。 |

Date

启用日期和时间的基本存储和检索。

| Prop | Type | Description | |--------------------------|----------------|--------------------------------------------------------| | toString | () => string | 返回日期的字符串表示形式。字符串的格式取决于区域设置。 | | toDateString | () => string | 将日期作为字符串值返回。 | | toTimeString | () => string | 返回一个作为字符串值的时间。 | | toLocaleString | () => string | 返回一个适合主机环境当前区域设置的字符串值。 | | toLocaleDateString | () => string | 返回一个适合主机环境当前区域设置的字符串形式的日期。 | | toLocaleTimeString | () => string | 返回一个适合主机环境当前区域设置的时间字符串值。 | | valueOf | () => string | 返回自1970年1月1日午夜(UTC)以来以毫秒为单位存储的时间值。 | | getTime | () => string | 获取以毫秒为单位的时间值。 | | getFullYear | () => string | 获取年份,使用本地时间。 | | getUTCFullYear | () => string | 使用协调世界时(UTC)获取年份。 | | getMonth | () => string | 获取月份,使用本地时间。 | | getUTCMonth | () => string | 使用协调世界时(UTC)获取Date对象的月份。 | | getDate | () => string | 获取当月的第几天,使用本地时间。 | | getUTCDate | () => string | 获取当月的第几天,使用协调世界时(UTC)。 | | getDay | () => string | 获取星期几,使用本地时间。 | | getUTCDay | () => string | 使用协调世界时(UTC)获取星期几。 | | getHours | () => string | 获取日期中的小时数,使用本地时间。 | | getUTCHours | () => string | 使用协调世界时(UTC)获取Date对象中的小时值。 | | getMinutes | () => string | 获取Date对象的分钟数,使用本地时间。 | | getUTCMinutes | () => string | 使用协调世界时(UTC)获取日期对象的分钟数。 | | getSeconds | () => string | 获取Date对象的秒数,使用本地时间。 | | getUTCSeconds | () => string | 使用协调世界时(UTC)获取日期对象的秒数。 | | getMilliseconds | () => string | 使用本地时间获取日期的毫秒数。 | | getUTCMilliseconds | () => string | 使用协调世界时(UTC)获取Date对象的毫秒数。 | | getTimezoneOffset | () => string | 获取本地计算机时间与协调世界时(UTC)之间的分钟差。 | | setTime | () => string | 设置Date对象中的日期和时间值。 | | setMilliseconds | () => string | 使用本地时间设置Date对象中的毫秒值。 | | setUTCMilliseconds | () => string | 使用世界协调时间(UTC)设置Date对象中的毫秒值。 | | setSeconds | () => string | 使用本地时间设置Date对象中的秒数值。 | | setUTCSeconds | () => string | 使用世界协调时间(UTC)设置Date对象中的秒数值。 | | setMinutes | () => string | 使用本地时间设置Date对象中的分钟值。 | | setUTCMinutes | () => string | 使用世界协调时间(UTC)设置Date对象中的分钟值。 | | setHours | () => string | 使用本地时间设置Date对象中的小时值。 | | setUTCHours | () => string | 使用协调世界时(UTC)设置Date对象中的小时值。 | | setDate | () => string | 使用本地时间设置日期对象的月份中的数字日值。 | | setUTCDate | () => string | 使用世界协调时间(UTC)在Date对象中设置月份的数字日期。 | | setMonth | () => string | 使用本地时间设置Date对象中的月份值。 | | setUTCMonth | () => string | 使用世界协调时间(UTC)设置Date对象中的月份值。 | | setFullYear | () => string | 使用本地时间设置Date对象的年份。 | | setUTCFullYear | () => string | 使用世界协调时间(UTC)设置Date对象中的年份值。 | | toUTCString | () => string | 返回一个使用协调世界时(UTC)转换为字符串的日期。 | | toISOString | () => string | 返回一个以ISO格式表示的日期字符串值。 | | toJSON | () => string | JSON.stringify方法用于将对象的数据转换为JavaScript对象表示法(JSON)序列化格式。 |

ScheduleOn(暂不支持)

| Prop | Type | |---------------|-----------| | year | number | | month | number | | day | number | | weekday | Weekday | | hour | number | | minute | number | | second | number |

Attachment(暂不支持)

| Prop | Type | Description | |---------------|----------|-------------------------------------------------------------| | id | string | 附件标识符。 | | url | string | 附件的URL。使用res方案引用网络资源,例如res:///assets/img/icon.png。也接受文件URL。 | | options | string | 附件选项。 |

AttachmentOptions(暂不支持)

| Prop | Type | Description | |------------------------------------------------------------------|----------|-------------| | iosUNNotificationAttachmentOptionsTypeHintKey | string | 不支持。 | | iosUNNotificationAttachmentOptionsThumbnailHiddenKey | string | 不支持。 | | iosUNNotificationAttachmentOptionsThumbnailClippingRectKey | string | 不支持。 | | iosUNNotificationAttachmentOptionsThumbnailTimeKey | string | 不支持。 |

PendingResult

| Prop | Type | Description | |---------------------|------------------------------------|-------------| | notifications | PendingLocalNotificationSchema[] | 待处理通知列表 |

PendingLocalNotificationSchema

| Prop | Type | Description | |----------------|------------|-----------------| | title | string | 通知的标题。 | | body | string | 通知正文,显示在标题下方。 | | id | number | 通知标识符。 | | schedule | schedule | 稍后安排此通知。。 | | extra | any | 设置额外数据以存储在此通知中。 |

Channel

| 支柱 | 类型 | 描述 | 默认 | 自从 | | ----------------- | ------------ | ------------------------------------------------------------ | ---- | ----- | | id | string | 频道标识符。 | | 1.0.0 | | name | string | 该频道的易读名称(向用户显示)。 | | 1.0.0 | | description | string | 本频道的描述(向用户显示)。 | | 1.0.0 | | sound | string | 此频道发布的通知应播放声音。重要性至少为 1 的通知频道3应有声音。声音文件的文件名应相对于 Android 应用目录指定res/raw。如果未提供声音文件或找不到声音文件,则不会播放声音。 | | 1.0.0 | | importance | Importance | 此频道发布的通知的中断级别。 | 3 | 1.0.0 | | visibility | Visibility | 此设置控制发布到此频道的通知是否显示在锁屏界面,以及如果显示,是否以隐藏信息的形式显示。 | | 1.0.0 | | lights | boolean | 是否在支持此功能的设备上显示发布到此频道的通知指示灯。 | | 1.0.0 | | lightColor | string | 此频道发布的通知的灯光颜色。仅当此频道启用灯光功能且设备支持时才可用。支持的颜色格式为#RRGGBB#RRGGBBAA。 | | 1.0.0 | | vibration | boolean | 是否应使发布到此频道的通知振动。 | | 1.0.0 |

ListChannelsResult

| 支柱 | 类型 | 描述 | 自从 | | -------------- | ----------- | -------------- | ----- | | channels | Channel[] | 通知渠道列表。 | 1.0.0 |

PermissionStatus

| 支柱 | 类型 | 描述 | 自从 | | ------------- | ----------------- | -------------------- | ----- | | display | PermissionState | 显示通知的权限状态。 | 1.0.0 |

SettingsPermissionStatus

| 支柱 | 类型 | 描述 | 自从 | | ----------------- | ----------------- | ------------------------ | ----- | | exact_alarm | PermissionState | 使用精确警报的权限状态。 | 6.0.0 |

PluginListenerHandle

| 支柱 | 类型 | | ------------ | --------------------- | | remove | () => Promise<void> |

ActionPerformed

| 支柱 | 类型 | 描述 | 自从 | | ------------------ | ------------------------- | ------------------------------------------------------------ | ----- | | actionId | string | 已执行操作的标识符。 | 1.0.0 | | inputValue | string | 用户在通知中输入的值。仅适用于 iOS 上input设置为 的通知true。 | 1.0.0 | | notification | LocalNotificationSchema | 原始通知架构。 | 1.0.0 |

类型别名

ScheduleEvery

'year' | 'month' | 'two-weeks' | 'week' | 'day' | 'hour' | 'minute' | 'second'

Importance

重要性级别。更多详情,请参阅Android 开发者文档。

1 | 2 | 3 | 4 | 5

Visibility

通知可见性。更多详情,请参阅Android 开发者文档。

-1 | 0 | 1

PermissionState

'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'

枚举

Weekday

| 成员 | 价值 | | --------------- | ---- | | Sunday | 1 | | Monday | 2 | | Tuesday | 3 | | Wednesday | 4 | | Thursday | 5 | | Friday | 6 | | Saturday | 7 |

目录结构

|---- 项目根目录
|     |---- src
|           |---- main
|                 |---- cpp
|                       |---- LocalNotifications   # 插件核心 C++ 实现
|                             |---- LocalNotifications.cpp
|                             |---- LocalNotifications.h
|                             |---- CMakeLists.txt
|                 |---- ets  # 插件核心 ets 实现
|                       |---- components
|                               |---- LocalNotifications
|                                     |---- LocalNotifications.ets
|                                     |---- LocalNotificationModel.ets
|                                     |---- NotificationStorage.ets
|                                     |---- NotificationAction.ets
|     |---- README.md          # 说明文档
|     |---- package.json       # npm 配置文件
|     |---- plugin.xml         # capacitor 插件配置
|     |---- LICENSE            # 许可证文件

贡献代码

使用过程中发现任何问题都可以提 Issue,当然,也非常欢迎发 PR 共建。

许可证

本插件基于 MIT License 开源,详见 LICENSE 文件。