Reputation: 43
I have just started using the (https://www.npmjs.com/package/passkit-generator) NPM library, and I would really appreciate help with this. It is the first (and hopefully the last) time I am working with apple wallet, and it is just so confusing.
After copying one project, I have tried to run the code, and while it generated a .pkpass file, the file wasn't valid, at least according to the https://pkpassvalidator.azurewebsites.net/ checker.
The code of the app is pretty short:
const fs = require("fs");
const { PKPass } = require("passkit-generator");
try {
(async () => {
const pass = await PKPass.from(
{
model: "./passes/sample",
certificates: {
wwdr: fs.readFileSync("./certificates/awdrca.pem"),
signerCert: fs.readFileSync("./certificates/signerCert.pem"),
signerKey: fs.readFileSync("./certificates/signerKey.pem"),
signerKeyPassphrase: "[private passphrase]",
},
},
{
serialNumber: "[generated at random]",
}
);
pass.setBarcodes("36478105430"); // Random value
const buffer = pass.getAsBuffer();
fs.writeFileSync("output/pass.pkpass", buffer);
})();
} catch (err) {
console.log(err);
}
The pass.json I am using for this is one of the example ones provided by the apple documentation:
{
"formatVersion": 1,
"passTypeIdentifier": "[the pass type identifier]",
"serialNumber": "8j23fm3",
"webServiceURL": "https://example.com/passes/", // I don't entirely know what this is good for
"authenticationToken": "[generated randomly]",
"teamIdentifier": "[Apple dev team id]",
"barcode": {
"message": "123456789",
"format": "PKBarcodeFormatPDF417",
"messageEncoding": "iso-8859-1"
},
"organizationName": "[Org name of our company]",
"description": "Toy Town Membership",
"logoText": "Toy Town",
"foregroundColor": "rgb(255, 255, 255)",
"backgroundColor": "rgb(197, 31, 31)",
"generic": {[contents of the pass]}
}
I was trying to figure this out for the past several hours, but whatever I do, it seems like certificates might be the problem. I tried to test it on my Iphone (sending the generated pass to my email and opening it there) but it did not open. I tested the sample apple documentation pass and it did open perfectly.
I will be super thankful for any help.
Upvotes: 1
Views: 803