Does Firebase Cloud Messaging support VOIP pushkit services?

柔情痞子 提交于 2019-12-18 12:17:16

问题


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.


回答1:


At time of writing (FirebaseMessaging 1.1.0/Firebase 3.2.0) FCM uses regular APNs underneath on iOS, so there isn't support for PushKit notifications.




回答2:


I got PushKit + Firebase working via node-apn. Simply install it via npm to your cloud functions folder. You could get the tokens from your firestore or something like that, but I think that's self-explanatory...

Here is some dummy code:

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




回答3:


This worked for me! Don't forget to add the Authkey_xxxx.p8 file in your directory and don't forget to add .voip to your bundle id in the notification topic.

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


来源:https://stackoverflow.com/questions/37326450/does-firebase-cloud-messaging-support-voip-pushkit-services

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!