@belongnet/capacitor-pass-to-wallet

中文文档
8.0.4发布于 2026/03/14MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 4105

Allow to add .pkpass files to Apple Wallet

原始使用文档
文档目录20 节
  1. Overview
  2. Quick start
  3. Basic usage
  4. Add pass from base64
  5. Add pass from local file
  6. Add multiple passes
  7. Check if pass already exists
  8. Compatibility
  9. Requirements (Capacitor 8)
  10. References
  11. API
  12. addToWallet(...)
  13. addMultipleToWallet(...)
  14. passExists(...)
  15. _experimental_passExistsById(...)
  16. _experimental_canAddPasses()
  17. _experimental_openPassInWallet(...)
  18. _experimental_removePass(...)
  19. _experimental_listPasses()
  20. Interfaces

@belongnet/capacitor-pass-to-wallet

Capacitor plugin to add .pkpass files to Apple Wallet.

npm downloads

Demo

Overview

Adds .pkpass files to Apple Wallet from a Capacitor app, using either base64 content or a local file URI.

  • addToWallet for a single pass
  • addMultipleToWallet for multiple passes
  • passExists to check whether a pass is already in Wallet

Quick start

bun add @belongnet/capacitor-pass-to-wallet
bunx cap sync

Basic usage

For step-by-step tutorials, see Adding Apple Wallet Passes and Creating Apple Wallet Passes.

Add pass from base64

import { CapacitorPassToWallet } from '@belongnet/capacitor-pass-to-wallet';

await CapacitorPassToWallet.addToWallet({
  base64: passBase64,
});

Add pass from local file

import { Filesystem, Directory } from '@capacitor/filesystem';
import { CapacitorPassToWallet } from '@belongnet/capacitor-pass-to-wallet';

const { uri } = await Filesystem.getUri({
  directory: Directory.Cache,
  path: 'passes/example.pkpass',
});

await CapacitorPassToWallet.addToWallet({
  filePath: uri,
});

Add multiple passes

// base64 mode
await CapacitorPassToWallet.addMultipleToWallet({
  base64: [base64Pass1, base64Pass2],
});

// file mode
await CapacitorPassToWallet.addMultipleToWallet({
  filePaths: [uri1, uri2],
});

Check if pass already exists

const result = await CapacitorPassToWallet.passExists({
  filePath: uri,
});

console.log(result.passExists);

[!NOTE] iOS is implemented. Android implementation in this repository is currently a placeholder.

Compatibility

Capacitor VersionPlugin Version
7.xpackage (v7)
8.x8.x

Requirements (Capacitor 8)

  • @capacitor/core >=8.0.0
  • iOS deployment target: 15.0+
  • Android minSdkVersion: 24+
  • Android build defaults in this plugin: compileSdkVersion 36, targetSdkVersion 36, Java 21

References

API

addToWallet(...)

addToWallet(options: AddToWalletOptions) => Promise<AddToWalletResult>

Opens Apple Wallet sheet for a single .pkpass.

ParamType
optionsAddToWalletOptions

Returns: Promise<AddToWalletResult>


addMultipleToWallet(...)

addMultipleToWallet(options: AddMultipleToWalletOptions) => Promise<AddToWalletResult>

Opens Apple Wallet sheet for multiple .pkpass files.

ParamType
optionsAddMultipleToWalletOptions

Returns: Promise<AddToWalletResult>


passExists(...)

passExists(options: AddToWalletOptions) => Promise<PassExistsResult>

Checks whether a pass already exists in Apple Wallet.

ParamType
optionsAddToWalletOptions

Returns: Promise<PassExistsResult>


_experimental_passExistsById(...)

_experimental_passExistsById(options: PassIdentifierOptions) => Promise<PassExistsResult>

Checks whether a pass exists by identifier and optional serial number.

ParamType
optionsPassIdentifierOptions

Returns: Promise<PassExistsResult>


_experimental_canAddPasses()

_experimental_canAddPasses() => Promise<CanAddPassesResult>

Returns whether device can add passes.

Returns: Promise<CanAddPassesResult>


_experimental_openPassInWallet(...)

_experimental_openPassInWallet(options: PassIdentifierOptions) => Promise<OpenPassInWalletResult>

Opens an existing pass in Apple Wallet by identifier.

ParamType
optionsPassIdentifierOptions

Returns: Promise<OpenPassInWalletResult>


_experimental_removePass(...)

_experimental_removePass(options: PassIdentifierOptions) => Promise<RemovePassResult>

Removes an existing pass from Apple Wallet by identifier.

ParamType
optionsPassIdentifierOptions

Returns: Promise<RemovePassResult>


_experimental_listPasses()

_experimental_listPasses() => Promise<ListPassesResult>

Lists wallet passes visible to the app.

Returns: Promise<ListPassesResult>


Interfaces

AddToWalletResult

PropTypeDescription
valuestringOperation status. Returns "added" when the pass sheet is presented.

AddToWalletOptions

PropTypeDescription
base64stringBase64-encoded .pkpass file content. Optional when filePath is provided.
filePathstringNative file path/URI to a .pkpass file (for example from Filesystem.getUri). Optional when base64 is provided.

AddMultipleToWalletOptions

PropTypeDescription
base64string[]List of base64-encoded .pkpass file contents. Optional when filePaths is provided.
filePathsstring[]List of native file paths/URIs to .pkpass files. Optional when base64 is provided.

PassExistsResult

PropTypeDescription
passExistsbooleantrue if the pass is already available in Apple Wallet.

PassIdentifierOptions

PropTypeDescription
passTypeIdentifierstringWallet pass type identifier (for example pass.com.example.membership).
serialNumberstringOptional serial number to target a specific pass instance.

CanAddPassesResult

PropTypeDescription
canAddPassesbooleantrue when the device can present add-to-wallet flow.

OpenPassInWalletResult

PropTypeDescription
openedbooleantrue when a matching pass was found and open action was started.

RemovePassResult

PropTypeDescription
removedbooleantrue when a matching pass was removed from wallet.

ListPassesResult

PropTypeDescription
passesWalletPassSummary[]Passes currently visible in the wallet library.

WalletPassSummary

PropTypeDescription
passTypeIdentifierstringWallet pass type identifier (for example pass.com.example.membership).
serialNumberstringPass serial number.
organizationNamestringOrganization name from pass payload when available.

License: MIT

版本与发布记录

@belongnet/capacitor-pass-to-wallet 共发布 5 个版本,首次发布于 2026/03/07;过去 12 个月发布了 5 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.0.4latest2026/03/147 个月前
8.0.32026/03/147 个月前
8.0.22026/03/107 个月前
8.0.12026/03/078 个月前
8.0.02026/03/078 个月前

关于 @belongnet/capacitor-pass-to-wallet 的常见问题

@belongnet/capacitor-pass-to-wallet 是什么?

Allow to add .pkpass files to Apple Wallet

如何安装 @belongnet/capacitor-pass-to-wallet?

在项目目录运行 npm install @belongnet/capacitor-pass-to-wallet,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@belongnet/capacitor-pass-to-wallet 支持 TypeScript 吗?

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

@belongnet/capacitor-pass-to-wallet 支持 ESM 还是 CommonJS?

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

@belongnet/capacitor-pass-to-wallet 可以商用吗?

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

@belongnet/capacitor-pass-to-wallet 的下载量有多少?

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

@belongnet/capacitor-pass-to-wallet 还在维护吗?

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