【发布时间】:2020-09-03 00:09:33
【问题描述】:
我想从 Firebase Cloud Function 向我的 iPhone 发送 VoIP 推送通知,但出现错误:
TypeError [ERR_INVALID_URL]: Invalid URL: api.development.push.apple.com
我需要知道这样做是否正确
这是我的代码
var functions = require("firebase-functions");
const http2 = require('http2');
exports.sendVoip = functions.https.onRequest((request, response) => {
const { Storage } = require('@google-cloud/storage');
const storage = new Storage();
const cert = storage.bucket('certificate').file('voip.pem');
const key = storage.bucket('certificate').file('key.pem');
const bundleID = 'com.cvit.albyrak'
const deviceToken = '287f063372970c602cf80f889e74d0000e06649e6872c077f24fe8ce7b624b9c'
const headers = {
'apns-topic': bundleID
};
const options = {
protocol: 'https:',
method: 'POST',
hostname: 'api.development.push.apple.com',
path: '/3/device/' + deviceToken,
headers: headers,
cert: cert,
key: key,
passphrase: ""
};
const client = http2.connect('api.development.push.apple.com').request(options).setEncoding('utf8').on('response', (headers, flags) => {
console.log(headers)
});
let data = ''
req.on('data', (d) => data += d)
req.on('end', () => client.destroy())
req.end()
response.send(request.body);
});
【问题讨论】:
标签: ios firebase google-cloud-functions google-cloud-storage voip