feat(native): booking passes go straight into Apple Wallet

Opening a .pkpass in the iOS app brought up the generic share sheet. It now
shows Wallet's own sheet with the pass and "Add", and a pass that is already in
Wallet opens there instead of being offered twice (TrekShell.addToWallet,
feature wallet). A broken pass or a device without Wallet falls back to the
share sheet as before.

Passes carry an "Apple Wallet" badge in the trip's files and a wallet icon
where they hang on a booking, so it is clear what a tap does.
This commit is contained in:
Maurice
2026-11-07 10:08:05 +01:00
parent 7b8bd4b166
commit 794da3be72
8 changed files with 185 additions and 14 deletions
+4 -9
View File
@@ -1,14 +1,7 @@
import { Directory, Filesystem } from '@capacitor/filesystem';
import { Share } from '@capacitor/share';
function toBase64(blob: Blob): Promise<string> {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => resolve(String(reader.result).slice(String(reader.result).indexOf(',') + 1));
reader.onerror = () => reject(reader.error);
reader.readAsDataURL(blob);
});
}
import { toBase64 } from './blobBase64';
import { addToWallet, isWalletPassName } from './wallet';
/** Readable, but safe as a single path segment inside the cache directory. */
export function cacheFileName(filename: string): string {
@@ -34,6 +27,8 @@ export function fileNameFromUrl(url: string): string {
* saving it to Files, opening it in another app or sending it on.
*/
export async function shareFile(blob: Blob, filename: string): Promise<void> {
// A Wallet pass goes to Apple Wallet's own sheet, not to the generic share sheet.
if (isWalletPassName(filename) && (await addToWallet(blob))) return;
const { uri } = await Filesystem.writeFile({
path: cacheFileName(filename),
data: await toBase64(blob),