@kyzegs/expo-wallet
v0.2.0
Published
Unified Apple Wallet and Google Wallet API for Expo
Maintainers
Readme
expo-wallet
Unified React Native API for Apple Wallet (iOS / PassKit) and Google Wallet (Android / Google Pay Wallet API), built with the Expo Modules API (Swift + Kotlin).
Networking stays in JavaScript: download .pkpass files with expo-file-system (or your HTTP client), then pass file:// URIs or base64 to iOS. On Android, pass the JWT string from your issuer backend (one JWT can encode multiple passes).
Installation
In an app that uses Expo dev/build clients:
npx expo install expo-walletFor Android, add Google Play Services Pay to the library (already declared in this package’s android/build.gradle):
implementation("com.google.android.gms:play-services-pay:16.5.0")(Rebuild the native app after installing the module.)
API
import {
canAddPass,
addPass,
hasPass,
downloadAndAddPass,
} from 'expo-wallet';canAddPass()— Whether the device can show the native add-pass flow (PKAddPassesViewController/ Pay API availability).addPass(options)— Platform-specific options:- iOS:
options.ios.passand/oroptions.ios.passeswithlocalUri(file://...) and/orbase64(raw.pkpassbytes, base64-encoded). - Android:
options.android.jwt— signed JWT from your Google Wallet issuer backend (supports one or many passes in a single token).
- iOS:
hasPass(options)— iOS: checks the pass library via PassKit when you providepassTypeIdentifier+serialNumber. Android: not supported on-device; logs a warning and returnsfalse(use the Google Wallet REST API from your backend).downloadAndAddPass(url, androidJwt?)— Optional helper: downloads a remote.pkpasswithexpo-file-system, then callsaddPass. Requiresexpo-file-systemin your app.
iOS: hasPass and entitlements
hasPass uses PKPassLibrary. To query passes your app did not issue, Apple expects the com.apple.developer.pass-type-identifiers entitlement (and correct setup in the developer portal). Without it, behavior may be limited.
Android: checking if a pass exists
There is no supported client-side check in the Pay / Wallet SDK comparable to PKPassLibrary. You must use the Google Wallet REST API (from a secure backend) to inspect object state.
Example app (example/)
The example app is configured with TypeScript path aliases to ../src and expo-file-system for download demos.
From the repo root:
cd example npm installiOS: set a real HTTPS
.pkpassURL (or use your ownaddPasscall with a localfile://URI).Android: paste a real issuer JWT from your backend (the placeholder string will fail until replaced).
Run:
npx expo run:ios # or npx expo run:android
Multiple passes
- iOS: pass several entries via
options.ios.passes, or combinepass+passes(they are merged into one native batch). - Android: encode multiple pass objects in one JWT; the native module still calls
savePassesJwtonce.
Development
npm install
npm run buildLicense
MIT
