Reading the Apple PassKit documentation here or here in the section titled "Getting the Latest Version of a Pass" or "Devices Ask for Latest Version of Passes" the two documents above simply suggest...
respond with a 200 and a payload of the data pass
or
Your server returns the pass data or the HTTP status 304 Not Modified if the pass hasn’t changed. Support the If-Modified-Since caching mechanism on this endpoint.
I'm assuming this is asking me to send the .pkpass file? With any headers? I feel I need to send some headers but the documentation isn't clear as to which ones?
I don't want to send a 304, in this instance as there is an update. The domain has a valid SSL cert.
I'm using express to send the response and I've tried a few responses such as ..
app.get('/passUpdate/v1/passes/*', function(req, res){
console.log('Getting the Latest Version of a Pass');
var path = req.path;
var parts = path.split("/");
var deviceLibraryIdentifier = parts[4];
var passTypeIdentifier = parts[5];
var authorization = req.headers.authorization;
var file = __dirname + '/public/pass/mytest.pkpass';
res.setHeader('Content-type', 'application/vnd.apple.pkpass');
res.setHeader('Last-Modified', 'Mon, 03 Apr 2016 19:01:35 GMT');
//res.download(file);
//res.attachment(file);
res.sendFile(file);
// res.attachment(https://www.mywebsite.com/pass/mytest.pkpass);
// res.sendfile(https://www.mywebsite.com/pass/mytest.pkpass);
// res.download(https://www.mywebsite.com/pass/mytest.pkpass);
res.sendStatus(200);
console.log(res.headersSent);
});
But the pass keeps making this request to the web service and on the phone at the top of the pass it reports "Couldn't Update Pass".
on a side note if i do respond with a 304
res.sendStatus(304);
the pass then displays the message "updated yesterday"
But I do want to update the pass! And its not clear what I should send, as you can see from the commented sections above I have tried more than a few thing.
Any ideas or pointers are most welcome!
答案 0 :(得分:1)
经过太长时间的讨论后,我只是评论了
res.sendStatus(200);
离开
app.get('/passUpdate/v1/passes/*', function(req, res){
console.log('Getting the Latest Version of a Pass');
var path = req.path;
var parts = path.split("/");
var deviceLibraryIdentifier = parts[4];
var passTypeIdentifier = parts[5];
var authorization = req.headers.authorization;
var file = __dirname + '/public/pass/mytest.pkpass';
res.setHeader('Content-type', 'application/vnd.apple.pkpass');
res.setHeader('Last-Modified', 'Mon, 03 Apr 2016 19:01:35 GMT');
res.sendFile(file);
});
然后确保.pkpass文件真的已经更新