@aparajita/capacitor-ios-silent-notifications

中文文档
3.0.0发布于 2025/10/31MITTypeScriptESM + CJS近 30 天下载 4538

Capacitor 7+ plugin that provides silent notification support for iOS

原始使用文档
文档目录3 节
  1. Installation
  2. Usage
  3. 1. Add a listener in your app

capacitor-ios-silent-notifications

This plugin for Capacitor 7+ provides support for silent (data only) notifications on iOS.

Installation

pnpm add @aparajita/capacitor-ios-silent-notifications # npm install, yarn add

Not using pnpm? You owe it to yourself to give it a try. It’s faster, better with monorepos, and uses way, way less disk space than the alternatives.

This plugin assumes you have already configured your app for push notifications.

Usage

There are two small steps to using this plugin:

1. Add a listener in your app

Add the following code during your app’s initialization:

import { IosSilentNotifications } from '@aparajita/capacitor-ios-silent-notifications'

// `const { remove }` is optional. If you are never going to remove the listener,
// you can omit it.
const { remove } = await IosSilentNotifications.addListener(
  'onSilentNotification',
  (notification: Notification) => {
    // Do something with the notification
  },
)

Note that on Android, this plugin does nothing, since the same functionality is already provided by the @capacitor/push-notifications plugin. If you wish, you can skip the call to addListener on Android:

if (Capacitor.getPlatform() === 'ios') {
  await IosSilentNotifications.addListener(
    'onSilentNotification',
    (notification: Notification) => {
      // Do something with the notification
    },
  )
}

2. Forward the notification to the plugin

In your app’s AppDelegate.swift file, add the following code to the AppDelegate class:

  func application(_ application: UIApplication,
                   didReceiveRemoteNotification userInfo: [AnyHashable: Any],
                   fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    NotificationCenter.default.post(name:Notification.Name("silentNotification"), object: userInfo);
    completionHandler(UIBackgroundFetchResult.newData)
  }

版本与发布记录

@aparajita/capacitor-ios-silent-notifications 共发布 5 个版本,首次发布于 2024/03/08;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.0.0latest2025/10/311 年前
2.0.12024/07/182 年前
2.0.02024/04/222 年前
1.0.12024/04/182 年前
1.0.02024/03/082 年前

关于 @aparajita/capacitor-ios-silent-notifications 的常见问题

@aparajita/capacitor-ios-silent-notifications 是什么?

Capacitor 7+ plugin that provides silent notification support for iOS

如何安装 @aparajita/capacitor-ios-silent-notifications?

在项目目录运行 npm install @aparajita/capacitor-ios-silent-notifications,或使用 pnpm add / yarn add / bun add。

@aparajita/capacitor-ios-silent-notifications 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@aparajita/capacitor-ios-silent-notifications 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@aparajita/capacitor-ios-silent-notifications 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@aparajita/capacitor-ios-silent-notifications 可以商用吗?

@aparajita/capacitor-ios-silent-notifications 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@aparajita/capacitor-ios-silent-notifications 的下载量有多少?

根据 npm 官方下载统计,@aparajita/capacitor-ios-silent-notifications 在 2026/10/06 – 2026/11/04 这 30 天内被下载 4,538 次,日均约 151 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@aparajita/capacitor-ios-silent-notifications 还在维护吗?

最新版本 3.0.0 发布于 2025/10/31(1 年前);至今共发布 5 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/03/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。