34

Does anyone has an idea about Firebase Cloud Messaging support VOIP pushkit services.

If yes then can someone please do provide guidelines for same.

Same thing which is implemented in Skype / Hangout / WhatsApp or any other VOIP based apps.

Thanks in advance.

4

3 回答 3

20

在撰写本文时(FirebaseMessaging 1.1.0/Firebase 3.2.0)FCM 在 iOS 上使用常规 APN,因此不支持 PushKit 通知。

于 2016-05-19T20:59:25.910 回答
4

这对我有用!不要忘记在您的目录中添加 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!");
    });
});
于 2019-07-01T13:08:20.017 回答
2

我让 PushKit + Firebase 通过 node-apn 工作。只需通过 npm 将其安装到您的云函数文件夹即可。你可以从你的火库或类似的地方获得令牌,但我认为这是不言自明的......

这是一些虚拟代码:

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!");
        });
    });

链接到 node-apn

于 2019-06-09T15:34:54.807 回答