I have generated successfully apple wallet passes with passkit-generator library. Now i have to update generated passes.
Can anyone please explain what kind of steps i need to take to accomplish this? So my wallet's passes can be updated easily.
Here is my code snippet, which i tried to integrate it first:-
const jwt = require("jsonwebtoken");
const fs = require("fs");
const axios = require("axios");
const teamId = "";
const keyId = "";
const privateKey = fs.readFileSync("./certs/AuthKey.p8", "utf8");
const jwtoken = jwt.sign({}, privateKey, {
algorithm: "ES256",
expiresIn: "24h",
issuer: teamId,
header: { alg: "ES256", kid: keyId },
});
module.exports = {
updatePass: async (req, res) => {
let serialNumber = '9876543210'
try {
const pushToken = ""; //
const bundleId = "pass.walletpass"; //
const apnsURL = `/${pushToken}`;
const response = await axios.post(
apnsURL,
{},
{
headers: {
"Authorization": `Bearer ${jwtoken}`,
"apns-topic": bundleId,
"Content-Type": "application/json"
}
}
);
console.log(response);
} catch (error) {
console.error("Error sending push notification:", error);
}
console.log(`Push notification sent for pass ${serialNumber}`);
res.send("Pass update triggered.");
}
}
But i am not able to achieve what i want. so can anyone Please Help how wallet can be updated dynamically?