mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 14:25:17 +00:00
Added icon reading and setting in scratch example
This commit is contained in:
@@ -5,8 +5,13 @@
|
|||||||
|
|
||||||
import app from "./webserver";
|
import app from "./webserver";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
import { promises as fs } from "fs";
|
||||||
import { PKPass } from "passkit-generator";
|
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) {
|
app.all(async function manageRequest(request, response) {
|
||||||
const passName =
|
const passName =
|
||||||
request.params.modelName +
|
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();
|
const stream = pass.getAsStream();
|
||||||
|
|
||||||
response.set({
|
response.set({
|
||||||
|
|||||||
Reference in New Issue
Block a user