1

Im trying to update a pass in a wallet, I only need the final step:

In Apples docs it says:

"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."

functions.https.onRequest((request, response) => {

First of all, I dont know how exactly the data should be sent

    let file = bucket.file('Event.pkpass');

            file.createReadStream()
                .on('error', function(err) {
                    console.log("file get Error", err);
                })
                .on('response', function(resp) {
                // Server connected and responded with the specified status and headers.
                    console.log("file get response", resp);
                })
                .on('end', function() {
                    console.log("File is downloaded");
                    // The file is fully downloaded.
                })
            .pipe(response);

My question, what exactly does the device expect? How should this pkpass be send? Im not an Nodejs programmer (iOS programmer), so bear over with me.

kragekjaer
  • 232
  • 4
  • 10

1 Answers1

1
let file = bucket.file('Event_1.pkpass');
            file.createReadStream()
                .on('error', function(err) {
                    console.log("File get Error", err);
                    response.status(501).send();
                })
                .on('response', function(resp) {
                    console.log("File get response", resp);
                })
                .on('end', function() {
                    console.log("File is downloaded");
                    response.status(200).send();
                })
            .pipe(response);

I figured it myself. Also remember to set the right header for Content-Type

kragekjaer
  • 232
  • 4
  • 10
  • could you help me with generating pkpass file in firebase functions? May be you know article with useful information? – andreich Oct 17 '19 at 07:16
  • @andreich Its not something I did before. I generated the pass´es locally then uploaded to Storage. But it would be useful to know how in Cloud functions. – kragekjaer Feb 01 '20 at 19:27