'Does Firebase Cloud Messaging support VOIP pushkit services?
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.
Solution 1:[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:[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:[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!");
});
});
Solution 4:[4]
Writing in 2022
TL;DR
No, it is not possible at the moment.
Why?
Theoretically, as per apple apns request specifications, it seems like all we need to specify the following in the headers:
apns-push-type: "voip",
apns-topic: "<app-bundle-id>.voip"
and this will send a voip notification via PushKit (of course we have to enable PushKit and Background notification capabilities)
Setting these headers in FCM message can be set possible as per FCM docs like:
{
"message": {
"token": "fcm-token",
"apns": {
"headers": {
"apns-push-type": "voip",
"apns-topic": "<app-bundle-id>.voip"
},
"payload": {
"aps": {
"contentAvailable": 1
},
"customKey": "customValue"
}
}
}
}
Here FCM sends the message.apns.payload
object as it is to the APNs server along with the headers
.
But:
Problem comes with certificate and key. Apple does not allow a single key or certificate to have both APNs and VoIP permission scopes and FCM does not allow multiple keys or certificates to be uploaded for the same project.
So, FCM can be used (theoretically) with PushKit but not with APNs at the same time. Although Apple specifies that PushKit uses APNs underneath, but it uses different authentication.
We can either create two different project (very difficult to manage) or use other services for PushKit. I am using serverless architecture but APNs server is not serverless friendly as it needs a persistent connection to be maintained.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Ian Barber |
Solution 2 | marouan azizi |
Solution 3 | p.wiesinger |
Solution 4 | Anubhab Maji |