简体   繁体   中英

Updating Apple Wallet .pkpass file stored in Cloud Storage from Firebase Cloud Functions to device

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM