Does Firebase Cloud Messaging support VOIP pushkit

2020-01-31 03:02发布

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.

3条回答
甜甜的少女心
2楼-- · 2020-01-31 03:40

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.

查看更多
神经病院院长
3楼-- · 2020-01-31 03:44

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!");
    });
});
查看更多
Anthone
4楼-- · 2020-01-31 04:02

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

查看更多
登录 后发表回答