最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Update Apple-wallet pass - Stack Overflow

programmeradmin4浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论