@capawesome/capacitor-wallet
v0.1.1
Published
Capacitor plugin for adding passes to Apple Wallet and Google Wallet on Android and iOS.
Maintainers
Readme
Capacitor Wallet Plugin
Capacitor plugin for adding passes to Apple Wallet and Google Wallet.
Features
- 🍎 Apple Wallet: Add passes such as tickets, loyalty cards, coupons and boarding passes to Apple Wallet.
- 🤖 Google Wallet: Save passes to Google Wallet using the official "Save to Wallet" flow.
- ✅ Availability check: Check whether passes can be added on the current device before showing the UI.
- 📦 CocoaPods & SPM: Supports CocoaPods and Swift Package Manager for iOS.
- 🔁 Up-to-date: Always supports the latest Capacitor version.
Missing a feature? Just open an issue and we'll take a look!
Use Cases
The Wallet plugin is typically used to hand digital passes to the user's wallet app, for example:
- Boarding passes: Add flight or train boarding passes so travelers have them ready at the gate.
- Event tickets: Add tickets for concerts, sports events, or the cinema.
- Loyalty cards: Let customers store membership and loyalty cards in their wallet.
- Coupons: Distribute coupons and vouchers that users can redeem in store.
Compatibility
| Plugin Version | Capacitor Version | Status | | -------------- | ----------------- | -------------- | | 0.x.x | >=8.x.x | Active support |
Installation
You can use our AI-Assisted Setup to install the plugin. Add the Capawesome Skills to your AI tool using the following command:
npx skills add capawesome-team/skills --skill capacitor-pluginsThen use the following prompt:
Use the `capacitor-plugins` skill from `capawesome-team/skills` to install the `@capawesome/capacitor-wallet` plugin in my project.If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:
npm install @capawesome/capacitor-wallet
npx cap syncThis plugin presents passes only. Passes must be created and signed on your server. See Creating Passes below.
iOS
Adding passes to Apple Wallet via PKAddPassesViewController does not require any special entitlement. The com.apple.developer.pass-type-identifiers entitlement is only needed if you want to read or manage passes that your app owns, which is out of scope for this plugin.
Android
No additional permissions or Gradle variables are required. The plugin opens the Google Wallet "Save to Wallet" flow, which is handled by the Google Wallet app or the device's browser.
Configuration
No configuration required for this plugin.
Usage
The following examples show how to check whether passes can be added, add passes to Apple Wallet, and save a pass to Google Wallet.
Check whether passes can be added
On some devices (e.g. certain iPads) or when adding passes is restricted, passes cannot be added to Apple Wallet. Use this method to gate the UI that triggers addPasses(...). Only available on iOS:
import { Wallet } from '@capawesome/capacitor-wallet';
const canAddPasses = async () => {
const { canAdd } = await Wallet.canAddPasses();
return canAdd;
};Add passes to Apple Wallet
Present the system add-pass sheet with one or more passes. Each pass must be a base64-encoded .pkpass file that was created and signed on your server (see Creating Passes). Only available on iOS:
import { Wallet } from '@capawesome/capacitor-wallet';
const addPasses = async (passes: string[]) => {
// `passes` are base64-encoded `.pkpass` files that were signed on your server.
await Wallet.addPasses({ passes });
};Save a pass to Google Wallet
Open the Google Wallet "Save to Wallet" flow with a signed JWT that was created on your server (see Creating Passes). Only available on Android:
import { Wallet } from '@capawesome/capacitor-wallet';
const saveToGoogleWallet = async (jwt: string) => {
// `jwt` is a signed Google Wallet JWT that was created on your server.
await Wallet.saveToGoogleWallet({ jwt });
};API
addPasses(...)
addPasses(options: AddPassesOptions) => Promise<void>Add one or more passes to Apple Wallet.
The passes must be created and signed on your server. This method only presents the system add-pass sheet with the provided passes.
Only available on iOS.
| Param | Type |
| ------------- | ------------------------------------------------------------- |
| options | AddPassesOptions |
Since: 0.1.0
canAddPasses()
canAddPasses() => Promise<CanAddPassesResult>Check whether passes can be added to Apple Wallet.
This may return false on some devices (e.g. certain iPads) or when adding
passes is restricted. Use this to gate the UI that triggers addPasses.
Only available on iOS.
Returns: Promise<CanAddPassesResult>
Since: 0.1.0
saveToGoogleWallet(...)
saveToGoogleWallet(options: SaveToGoogleWalletOptions) => Promise<void>Save a pass to Google Wallet.
This opens the Google Wallet "Save to Wallet" flow using the provided JWT. The JWT must be created and signed on your server.
Note: With the URL-based flow there is no completion signal, so the promise resolves as soon as the flow is launched, not when the pass is actually saved.
Only available on Android.
| Param | Type |
| ------------- | ------------------------------------------------------------------------------- |
| options | SaveToGoogleWalletOptions |
Since: 0.1.0
Interfaces
AddPassesOptions
| Prop | Type | Description | Since |
| ------------ | --------------------- | --------------------------------------------------------------------------------------------------------------------- | ----- |
| passes | string[] | The passes to add to Apple Wallet. Each entry must be a base64-encoded .pkpass file that was signed on your server. | 0.1.0 |
CanAddPassesResult
| Prop | Type | Description | Since |
| ------------ | -------------------- | -------------------------------------------- | ----- |
| canAdd | boolean | Whether passes can be added to Apple Wallet. | 0.1.0 |
SaveToGoogleWalletOptions
| Prop | Type | Description | Since |
| --------- | ------------------- | ------------------------------------------------------------- | ----- |
| jwt | string | The signed Google Wallet JWT that was created on your server. | 0.1.0 |
Creating Passes
This plugin only presents passes to the user. Creating and signing passes must happen on your server, because it requires private keys and certificates that must never be shipped inside your app.
Apple Wallet
A pass is a signed .pkpass bundle. Build and sign it on your server using your Pass Type ID certificate, then send the resulting file to your app as a base64-encoded string and pass it to addPasses(...). See Apple's Wallet documentation for details on building and signing passes.
Google Wallet
A pass is represented by a signed JWT. Create and sign the JWT on your server using your Google Wallet service account, then send it to your app and pass it to saveToGoogleWallet(...). See Google's Wallet API documentation for details on creating passes and JWTs.
Note: With the URL-based "Save to Wallet" flow used by this plugin, there is no completion signal, so saveToGoogleWallet(...) resolves as soon as the flow is launched, not when the pass is actually saved.
FAQ
How is this plugin different from other similar plugins?
It covers both Apple Wallet and Google Wallet from a single fully typed API, presenting signed .pkpass passes on iOS and opening the official Google Wallet "Save to Wallet" flow on Android, with an availability check to gate your UI beforehand. It keeps a clean security boundary by presenting passes only — signing stays on your server, where your keys belong — and the README links the official Apple and Google guidance for creating them. The plugin is actively maintained against the latest Capacitor and OS versions.
Can this plugin create passes for me?
No, this plugin only presents passes to the user. Creating and signing passes must happen on your server, because it requires private keys and certificates that must never be shipped inside your app. See Creating Passes for details and links to the official Apple and Google documentation.
Which methods are available on which platform?
The addPasses(...) and canAddPasses() methods are only available on iOS, where they interact with Apple Wallet. The saveToGoogleWallet(...) method is only available on Android, where it opens the Google Wallet "Save to Wallet" flow.
Why does saveToGoogleWallet resolve before the pass is saved?
The plugin uses the URL-based "Save to Wallet" flow, which does not provide a completion signal. The promise therefore resolves as soon as the flow is launched, not when the pass is actually saved.
Do I need a special entitlement to add passes on iOS?
No, adding passes via the system add-pass sheet does not require any special entitlement. The com.apple.developer.pass-type-identifiers entitlement is only needed if you want to read or manage passes that your app owns, which is out of scope for this plugin.
Why does canAddPasses return false?
The canAddPasses() method may return false on some devices (e.g. certain iPads) or when adding passes is restricted. Use it to hide or disable the UI that triggers addPasses(...) in these cases.
Can I use this plugin with Ionic, React, Vue or Angular?
Yes, the plugin is framework-agnostic. It works in any Capacitor app regardless of the web framework, including Ionic with Angular, React, or Vue, as well as plain JavaScript projects.
Related Plugins
- Purchases: Support in-app purchases in your Capacitor app.
- Square Mobile Payments: Accept payments with the Square Mobile Payments SDK.
Newsletter
Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our Capawesome Newsletter.
Changelog
See CHANGELOG.md.
License
See LICENSE.
