从设备到设备的Firebase Google Cloud消息传递 [英] Firebase Google Cloud messaging from device to device

查看:98
本文介绍了从设备到设备的Firebase Google Cloud消息传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法理解如何将消息从iOS设备发送到另一台iOS设备,并试图了解两者之间的区别 Firebase通知和Google Cloud Messaging.

I couldn't understand how can i send message from iOS device to another iOS device, and trying to understand the difference between Firebase Notifications and Google Cloud Messaging.

Firebase通知是从服务器发送的,您可以向设备发送消息.

Firebase Notifications say's from the server you can send a message to devices.

Google Cloud Messaging :它将消息从服​​务器发送到设备(下游)或从设备发送到服务器(上游)!

Google Cloud Messaging: it sends messages from server to devices(downstream) or device to server(upstream) !!

上游示例:

[[FIRMessaging message]sendMessage:(nonnull NSDictionary *)message
                                to:(nonnull NSString *)receiver
                     withMessageID:(nonnull NSString *)messageID
                        timeToLive:(int64_t)ttl;

如果我需要在设备之间发送推送消息怎么办!这意味着在设备向服务器发送消息后,我必须对Firebase服务器进行编程才能将推送发送给客户端吗?真是令人困惑!

What about if i need to send a push message from device to device ! Does it means after the device sends a messages to server, i have to program the firebase server to send push to client ? its really confusing !

推荐答案

不,您不能使用Firebase在iOS上执行此操作,您应该做的是在Firebase上调用服务,该服务会将通知发送到另一台设备. APNS和GCM在服务器设置方面有所不同.

No you cannot do this on iOS using firebase, what you should do is call a service on your firebase which will send a notification to the other device. APNS and GCM are a little different in terms of the server setup.

对于GCM,您只需将API密钥添加到您对 https:/进行的POST调用中/android.googleapis.com/gcm/send (可以在服务器,移动设备等任何地方完成).您需要的只是目标设备的设备令牌和API密钥.

For GCM you just need the API key to be added in the POST call you make to https://android.googleapis.com/gcm/send which can be done anywhere server, mobile device, etc. All you need is the target devices device token and the API key.

APNS的工作方式不同,您需要附加在Apple开发人员门户上创建的服务器SSL证书,以对自己进行身份验证并将推送通知发送到设备.我不确定如何在iOS设备上实现此目标.

APNS works differently you need attach the server SSL cert that you create on the Apple developer portal to authenticate yourself and send a push notification to a device. I am not sure how you could achieve this on an iOS device.

该线程阐明了GCM和Firebase之间的真正区别,

This thread clarifies the real difference between GCM and Firebase,

使用Firebase实时推送通知

https://firebase.google.com/support/faq/#gcm -不是

Firebase和GCM不同,但是它们可用于实现相同的目标.希望对您有帮助.

Firebase and GCM are different but they can be used to achieve the same goals. Hope it helps you.

这篇关于从设备到设备的Firebase Google Cloud消息传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆