Firebase Cloud Messaging是否支持VOIP pushkit服务?

时间:2016-05-19 14:34:01

标签: ios push-notification firebase google-cloud-messaging pushkit

是否有人了解Firebase Cloud Messaging支持VOIP pushkit服务。

如果是,那么请有人为此提供指导。

同样的事情在Skype / Hangout / WhatsApp或任何其他基于VOIP的应用程序中实现。

提前致谢。

3 个答案:

答案 0 :(得分:13)

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

答案 1 :(得分:1)

我通过node-apn使PushKit + Firebase工作。 只需通过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!");
        });
    });

Link to node-apn

答案 2 :(得分:0)

这对我有用!不要忘记在目录中添加Authkey_xxxx.p8文件,也不要忘记在通知主题中的捆绑包ID中添加.voip。

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