使用FCM从服务器发送推送通知 [英] Send push notifications from server with FCM

查看:944
本文介绍了使用FCM从服务器发送推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我问了一个使用GCM发送推送通知的问题:发送推送通知到Android 。现在有FCM,我想知道如何从服务器端开发不同。编码明智,他们是一样的吗?我在哪里可以找到示例FCM代码显示发送推送通知从服务器到Android设备?

我需要下载任何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屋!

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