【问题标题】:Does Firebase Cloud Messaging support VOIP pushkit services?Firebase 云消息传递是否支持 VOIP 推送服务?
【发布时间】:2016-09-16 12:35:03
【问题描述】:

有没有人知道Firebase Cloud Messaging 支持VOIP pushkit 服务。

如果是,那么有人可以提供相同的指导。

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

提前致谢。

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

    • 据我了解,是的,FMC 确实可以与 PushKit 一起使用,因为从服务器实例不需要任何更改!它确实通过 APN。这是在 iOS 中实现的方式(不同的回调),与常规推送通知不同。如果您通过 PushKit 获取您的标识符并将其输入 FCM,则它命中的服务和有效负载是相同的。它只是通过不同的回调再次到达 iOS 设备。我没有测试过它,但我愿意打赌它有效。我没有看到将推送到 PushKit 的 PHP 脚本与将执行简单推送通知的 PHP 脚本有任何区别。
    • @EdGs 这不仅仅是客户端上的不同回调。对于 PushKit 通知,发送到 Apple 服务器的“主题”是不同的,Firebase 服务器必须知道发送正确的主题。现在有来自 Apple 的通用推送证书,因此您应该能够创建支持它的证书,但除非 Firebase 发送正确的主题,否则它将是常规 APN 而不是 PushKit。
    • 我昨天刚刚向 Google 询问了有关通过 FCM 支持 VoIP 通知的问题,他们告诉我它不受支持,并且仍在他们的功能请求列表中,没有 eta。
    • 它仍然不受支持吗?
    • 它仍然不受支持吗?我们正在网上搜索以使用它,但我没有得到任何有用的链接。
    【解决方案2】:

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

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

    【讨论】:

    • 我在通知主题中的捆绑 ID 上缺少 .voip
    • 这是否意味着客户端也需要订阅主题'com.your.app.voip'才能收到通知?
    • @marouan azizi 所以使用这个服务器代码,应用程序的 PKPushRegistry:didReceiveIncomingPushWithPayload() 方法被调用而不是 UIApplication:didReceiveRemoteNotification() ?
    【解决方案3】:

    我让 PushKit + Firebase 通过 node-apn 工作。 只需通过 npm 将其安装到您的云函数文件夹即可。 你可以从你的 firestore 或类似的地方获取令牌,但我认为这是不言自明的......

    这是一些虚拟代码:

    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

    【讨论】:

    • 所以使用这个服务器代码,应用程序的 PKPushRegistry:didReceiveIncomingPushWithPayload() 方法被调用而不是 UIApplication:didReceiveRemoteNotification() ?
    • 这种行为是有意为之的,因为 pushkit 通知与常规远程通知无关...如果这就是您的意思...?
    猜你喜欢
    • 1970-01-01
    • 2016-12-13
    • 1970-01-01
    • 2017-11-17
    • 2017-11-18
    • 1970-01-01
    • 2020-08-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多