【发布时间】:2016-09-16 12:35:03
【问题描述】:
有没有人知道Firebase Cloud Messaging 支持VOIP pushkit 服务。
如果是,那么有人可以提供相同的指导。
在 Skype / Hangout / WhatsApp 或任何其他基于 VOIP 的应用程序中实现的相同。
提前致谢。
【问题讨论】:
标签: ios push-notification firebase google-cloud-messaging pushkit
有没有人知道Firebase Cloud Messaging 支持VOIP pushkit 服务。
如果是,那么有人可以提供相同的指导。
在 Skype / Hangout / WhatsApp 或任何其他基于 VOIP 的应用程序中实现的相同。
提前致谢。
【问题讨论】:
标签: ios push-notification firebase google-cloud-messaging pushkit
在撰写本文时(FirebaseMessaging 1.1.0/Firebase 3.2.0)FCM 在 iOS 底层使用常规 APN,因此不支持 PushKit 通知。
【讨论】:
这对我有用!不要忘记在您的目录中添加 Authkey_xxxx.p8 文件,并且不要忘记在通知主题中将 .voip 添加到您的捆绑包 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!");
});
});
【讨论】:
我让 PushKit + Firebase 通过 node-apn 工作。 只需通过 npm 将其安装到您的云函数文件夹即可。 你可以从你的 firestore 或类似的地方获取令牌,但我认为这是不言自明的......
这是一些虚拟代码:
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!");
});
});
【讨论】: