Does Firebase Cloud Messaging support VOIP pushkit services?

20,383

Solution 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.

Solution 2

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

Solution 3

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

Share:
20,383
Hasya
Author by

Hasya

#SOreadytohelp Swift / Objective C Mobile application development consulting VOIP App ( Socket, Pushkit, WebRTC ) JSON / XML / SQlite / Core data Enterprise apps SAP Mobility Project Manager, CSM®, CSPO® @ Brainvire

Updated on July 09, 2022

Comments

  • Hasya
    Hasya almost 2 years

    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.