0

我已经实现了苹果钱包它的生成卡第一次工作正常,现在我试图将新的更改推送到现有卡。

当我发送新更改请求的推送通知时。我收到序列号请求,然后再次收到更新卡的 GET 请求。'/v1/passes/:passTypeIdentifie/:serialNumber'</p>

我正在使用第一次生成卡片的卡片生成 API 来提供新的更改。我不确定这个好主意,但有些它是如何不起作用的,也许我在 nodejs 中做得不对。

当我从浏览器发送请求时,它让我下载 myfile.pkpass 下载后我将 .pkpass 扩展名更改为 zip 它不起作用显示错误“无法打开文件 c:\myfile.zip 作为存档”看起来像

我没有正确打包 pkpass 文件

请帮我找到问题请参阅下面我附加的代码端点

我正在使用 nodejs restify

    routerInstance.get('/v1/passes/:passTypeIdentifie/:serialNumber', async (req, res) => {
    try {
        console.log('Starting pkpass API call');
        const options = {
            hostname: 'localhost',
            //port: 443,
            path: '/api/localapi/passgen/c1',
            method: 'GET'
        }


        const getfile = https.request(options, fileres => {
            console.log(`statusCode: ${fileres.statusCode}`);
            var result = '';

            fileres.on('data', pkpass => {
                result += pkpass.toString();
            });

            fileres.on('end', () => {
                console.log('Response ended');
                res.header('x-timestamp', Date.now());
                res.header('x-sent', true);
                res.header('Content-Type', 'application/vnd.apple.pkpass');
                res.header('Content-disposition', 'attachment; filename=myfile.pkpass');

                res.send(result);
            });

            fileres.on('error', (err) => {
                console.error('Error receiving pkpass', err.toString());
                throw new Error("Error receiving pkpass");
            })

        });
        getfile.on('error', error => {
            console.error('Error making GET call', error);
            throw new Error('Error making GET call');
        })

        getfile.end();
    } catch (ex) {
        console.error('Uncaught PKPASS error', ex.toString());
        res.send('Error');
    }
});

控制台输出:

statusCode: 200


Response ended
 Starting pkpass API call
 statusCode: 200



{"logs":["[2021-02-24 13:41:54 -0800] Get pass task (pass type pass.com.localhost, serial number MB982H, if-modified-since (null); with web service url https:\/\/localhost\/) encountered error: Received invalid pass data (The pass cannot be read because it isn’t valid.)"]}
4

0 回答 0