使用FCM从服务器发送推送通知 [英] Send push notifications from server with FCM
问题描述
我需要下载任何JAR库发送通知到FCM使用Java代码? 向Android发送推送通知的示例代码显示发送推送通知使用GCM和服务器端GCM JAR文件是必需的。
然而,另一个例子在 https ://www.quora.com/How-do-I-make-a-post-request-to-a-GCM-server-in-Java-to-push-a-notification-to-the-client-app 显示使用GCM发送推送通知,没有服务器端GCM JAR文件是必需的,因为它只是通过HTTP连接发送。 FCM可以使用相同的代码吗?使用的网址是 https://android.googleapis.com/gcm/send 。 FCM的等效URL是什么?
在此先感谢。
服务器端编码有多不同?
没有太大的区别,您可以查看大多数GCM示例服务器端代码。关于GCM和FCM的主要区别在于,当使用FCM时,您可以使用它的新功能(如本回答 的)。 FCM还有一个控制台,您可以在其中发送消息/通知,而无需拥有自己的应用服务器。
注意:创建您自己的应用程序服务器取决于您。只需说明您可以通过控制台发送消息/通知。
使用的URL是 https://android.googleapis.com/gcm/send 。什么是FCM的等效URL?
FCM的等效URL是 https://fcm.googleapis.com/fcm/send 。您可以查看这个文档了解更多详情。
干杯! :D
Recently I asked a question on sending push notifications using GCM: Send push notifications to Android. Now that there is FCM, I am wondering how different it would be from the server side development. Coding wise, are they the same? Where can I find example FCM codes showing sending push notifications from server to Android device?
Do I need to download any JAR library for sending notifications to FCM using Java codes? The example codes in Send push notifications to Android shows sending push notifications using GCM and a server side GCM JAR file is required.
However, another example in https://www.quora.com/How-do-I-make-a-post-request-to-a-GCM-server-in-Java-to-push-a-notification-to-the-client-app shows sending push notifications using GCM and no server side GCM JAR file is required since it is just sending via an HTTP connection. Can the same codes be used for FCM? The URL used is "https://android.googleapis.com/gcm/send". What would be the equivalent URL for FCM?
Thanks in advance.
How different is server-side coding?
Since there is not much difference, you can just check out most of the example server-side codes for GCM as well. Main difference with regards to GCM and FCM is that when using FCM, you can use the new features with it (as mentioned in this answer). FCM also has a Console where you can send the Message/Notification from, without having your own app server.
NOTE: Creating your own app server is up to you. Just stating that you can send a message/notification via the console.
The URL used is "https://android.googleapis.com/gcm/send". What would be the equivalent URL for FCM?
The equivalent URL for FCM is https://fcm.googleapis.com/fcm/send. You can check out the this doc for more details.
Cheers! :D
这篇关于使用FCM从服务器发送推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!