1

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!

Bill
  • 4,614
  • 13
  • 77
  • 132

1 Answers1

1

After messing around for way too long i simply commented out the

 res.sendStatus(200);

leaving

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);
});

Then just make sure the .pkpass file realy has been updated

Bill
  • 4,614
  • 13
  • 77
  • 132
  • do you know why that was interfering? I'm trying to work out a similar code in php... Also do you know if the .pkpass file can be sent as a downloadable complete version for the update? – Michael Sep 01 '17 at 10:54