[英]Updating Apple Wallet .pkpass file stored in Cloud Storage from Firebase Cloud Functions to device
我正在嘗試更新錢包中的通行證,我只需要最后一步:
在 Apples 文檔中,它說:
“您的服務器返回 pass 數據或 HTTP 狀態 304 Not Modified 如果 pass 沒有更改。支持此端點上的 If-Modified-Since 緩存機制。”
functions.https.onRequest((request, response) => {
首先,我不知道應該如何發送數據
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);
我的問題是,該設備到底期望什么? 這個pkpass應該怎么發送? 我不是 Nodejs 程序員(iOS 程序員),所以請耐心等待。
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);
我自己想出來的。 還要記得為 Content-Type 設置正確的 header
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.