From 0a6b3f75288843ff66b205370afe23c9c21a30f3 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Sat, 16 Oct 2021 23:41:47 +0200 Subject: [PATCH] Added icon reading and setting in scratch example --- examples/scratch.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/examples/scratch.ts b/examples/scratch.ts index f41c69e..51f1d24 100644 --- a/examples/scratch.ts +++ b/examples/scratch.ts @@ -5,8 +5,13 @@ import app from "./webserver"; import path from "path"; +import { promises as fs } from "fs"; import { PKPass } from "passkit-generator"; +const iconFromModel = await fs.readFile( + path.resolve(__dirname, "models/exampleBooking.pass/icon.png"), +); + app.all(async function manageRequest(request, response) { const passName = request.params.modelName + @@ -56,6 +61,16 @@ app.all(async function manageRequest(request, response) { }, ); + /** + * Required by Apple. If one is not available, a + * pass might be openable on a Mac but not on a + * specific iPhone model + */ + + pass.addBuffer("icon.png", iconFromModel); + pass.addBuffer("icon@2x.png", iconFromModel); + pass.addBuffer("icon@3x.png", iconFromModel); + const stream = pass.getAsStream(); response.set({