Firebase Cloud Messaging 是否支持 VOIP pushkit 服务?
Does Firebase Cloud Messaging support VOIP pushkit services?
有没有人知道 Firebase Cloud Messaging support VOIP pushkit 服务。
如果是,请有人提供相同的指南。
在 Skype / Hangout / WhatsApp 或任何其他基于 VOIP 的应用程序中实施的相同内容。
提前致谢。
在撰写本文时 (FirebaseMessaging 1.1.0/Firebase 3.2.0) FCM 在 iOS 下使用常规 APN,因此不支持 PushKit 通知。
我通过 node-apn 安装了 PushKit + Firebase。
只需通过 npm 将其安装到您的云功能文件夹即可。
您可以从您的 firestore 或类似的东西中获取令牌,但我认为那是 self-explanatory...
这是一些虚拟代码:
export const test = functions.https.onRequest((request, response) => {
const config = {
production: false, /* change this when in production */
cert: 'yourCERT.pem',
key: 'yourKey.pem',
};
const apnProvider = new apn.Provider(config);
const notification = new apn.Notification();
const recepients: string[] = [];
recepients.push(apn.token('SOME PUSHKIT TOKEN'));
recepients.push(apn.token('ANOTHER PUSHKIT TOKEN'));
notification.topic = 'com.your.app.voip'; // you have to add the .voip here!!
notification.payload = {
// some payload
};
return apnProvider.send(notification, recepients).then((reponse) => {
console.log(reponse);
return response.send("finished!");
});
});
这对我有用!不要忘记在您的目录中添加 Authkey_xxxx.p8 文件,并且不要忘记在通知主题中将 .voip 添加到您的 bundle id。
export const test = functions.https.onRequest((request, response) => {
const config = {
production: false, /* change this when in production */
token: {
key: "./AuthKey_xxxx.p8",
keyId: "xxxx",
teamId: "yyyy"
}
};
const apnProvider = new apn.Provider(config);
const notification = new apn.Notification();
const recepients: string[] = [];
recepients.push(apn.token('SOME PUSHKIT TOKEN'));
recepients.push(apn.token('ANOTHER PUSHKIT TOKEN'));
notification.topic = 'com.your.app.voip'; // you have to add the .voip here!!
notification.payload = {
// some payload
};
return apnProvider.send(notification, recepients).then((reponse) => {
console.log(reponse);
return response.send("finished!");
});
});
2022 年写作
TL;DR
不,目前不可能。
为什么?
理论上,按照苹果 apns request specifications,似乎我们只需要在 headers 中指定以下内容:
apns-push-type: "voip",
apns-topic: "<app-bundle-id>.voip"
这将通过 PushKit 发送 voip 通知(当然我们必须启用 PushKit 和后台通知功能)
在 FCM 消息中设置这些 headers 可以根据 FCM docs 进行设置,例如:
{
"message": {
"token": "fcm-token",
"apns": {
"headers": {
"apns-push-type": "voip",
"apns-topic": "<app-bundle-id>.voip"
},
"payload": {
"aps": {
"contentAvailable": 1
},
"customKey": "customValue"
}
}
}
}
此处 FCM 将 message.apns.payload
object 与 headers
.
一起发送到 APNs 服务器
但是:
证书和密钥有问题。 Apple 不允许单个密钥或证书同时具有 APN 和 VoIP 权限范围,FCM 不允许为同一项目上传多个密钥或证书。
因此,FCM 可以(理论上)与 PushKit 一起使用,但不能同时与 APNs 一起使用。虽然 Apple specifies PushKit 在底层使用了 APNs,但它使用不同的身份验证。
我们可以创建两个不同的项目(很难管理),也可以为 PushKit 使用其他服务。我正在使用无服务器架构,但 APNs 服务器对无服务器不友好,因为它需要保持持久连接。
有没有人知道 Firebase Cloud Messaging support VOIP pushkit 服务。
如果是,请有人提供相同的指南。
在 Skype / Hangout / WhatsApp 或任何其他基于 VOIP 的应用程序中实施的相同内容。
提前致谢。
在撰写本文时 (FirebaseMessaging 1.1.0/Firebase 3.2.0) FCM 在 iOS 下使用常规 APN,因此不支持 PushKit 通知。
我通过 node-apn 安装了 PushKit + Firebase。 只需通过 npm 将其安装到您的云功能文件夹即可。 您可以从您的 firestore 或类似的东西中获取令牌,但我认为那是 self-explanatory...
这是一些虚拟代码:
export const test = functions.https.onRequest((request, response) => {
const config = {
production: false, /* change this when in production */
cert: 'yourCERT.pem',
key: 'yourKey.pem',
};
const apnProvider = new apn.Provider(config);
const notification = new apn.Notification();
const recepients: string[] = [];
recepients.push(apn.token('SOME PUSHKIT TOKEN'));
recepients.push(apn.token('ANOTHER PUSHKIT TOKEN'));
notification.topic = 'com.your.app.voip'; // you have to add the .voip here!!
notification.payload = {
// some payload
};
return apnProvider.send(notification, recepients).then((reponse) => {
console.log(reponse);
return response.send("finished!");
});
});
这对我有用!不要忘记在您的目录中添加 Authkey_xxxx.p8 文件,并且不要忘记在通知主题中将 .voip 添加到您的 bundle id。
export const test = functions.https.onRequest((request, response) => {
const config = {
production: false, /* change this when in production */
token: {
key: "./AuthKey_xxxx.p8",
keyId: "xxxx",
teamId: "yyyy"
}
};
const apnProvider = new apn.Provider(config);
const notification = new apn.Notification();
const recepients: string[] = [];
recepients.push(apn.token('SOME PUSHKIT TOKEN'));
recepients.push(apn.token('ANOTHER PUSHKIT TOKEN'));
notification.topic = 'com.your.app.voip'; // you have to add the .voip here!!
notification.payload = {
// some payload
};
return apnProvider.send(notification, recepients).then((reponse) => {
console.log(reponse);
return response.send("finished!");
});
});
2022 年写作
TL;DR
不,目前不可能。
为什么?
理论上,按照苹果 apns request specifications,似乎我们只需要在 headers 中指定以下内容:
apns-push-type: "voip",
apns-topic: "<app-bundle-id>.voip"
这将通过 PushKit 发送 voip 通知(当然我们必须启用 PushKit 和后台通知功能)
在 FCM 消息中设置这些 headers 可以根据 FCM docs 进行设置,例如:
{
"message": {
"token": "fcm-token",
"apns": {
"headers": {
"apns-push-type": "voip",
"apns-topic": "<app-bundle-id>.voip"
},
"payload": {
"aps": {
"contentAvailable": 1
},
"customKey": "customValue"
}
}
}
}
此处 FCM 将 message.apns.payload
object 与 headers
.
但是:
证书和密钥有问题。 Apple 不允许单个密钥或证书同时具有 APN 和 VoIP 权限范围,FCM 不允许为同一项目上传多个密钥或证书。
因此,FCM 可以(理论上)与 PushKit 一起使用,但不能同时与 APNs 一起使用。虽然 Apple specifies PushKit 在底层使用了 APNs,但它使用不同的身份验证。
我们可以创建两个不同的项目(很难管理),也可以为 PushKit 使用其他服务。我正在使用无服务器架构,但 APNs 服务器对无服务器不友好,因为它需要保持持久连接。