将存储在Cloud Storage中的Apple Wallet .pkpass文件从Firebase Cloud Functions更新到设备
我正在尝试更新钱包中的通行证,我只需要最后一步:
在Apple文档中它说:
“如果传递未更改,您的服务器将返回传递数据或HTTP状态304未修改。在此端点上支持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设置正确的标题
将存储在Cloud Storage中的Apple Wallet .pkpass文件从Firebase Cloud Functions更新到设备
我正在尝试更新钱包中的通行证,我只需要最后一步:
在Apple文档中它说:
“如果传递未更改,您的服务器将返回传递数据或HTTP状态304未修改。在此端点上支持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设置正确的标题