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

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

问题描述

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

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?

我是否需要下载任何 JAR 库以使用 Java 代码向 FCM 发送通知?向Android发送推送通知中的示例代码显示需要使用 GCM 和服务器端 GCM JAR 文件发送推送通知.

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.

然而,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 吗?使用的 URL 是https://android.googleapis.com/gcm/send".FCM 的等效 URL 是什么?

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?

提前致谢.

推荐答案

服务器端编码有何不同?

由于没有太大区别,您也可以查看 GCM 的大多数示例服务器端代码.GCM 和 FCM 的主要区别在于,在使用 FCM 时,您可以使用它的新功能(如本答案).FCM 还有一个控制台,您可以在其中发送消息/通知,而无需拥有自己的应用服务器.

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.

使用的 URL 是https://android.googleapis.com/gcm/send".FCM 的等效 URL 是什么?

The URL used is "https://android.googleapis.com/gcm/send". What would be the equivalent URL for FCM?

FCM 的等效 URL 是 https://fcm.googleapis.com/fcm/send.您可以查看此doc了解更多详情.

The equivalent URL for FCM is https://fcm.googleapis.com/fcm/send. You can check out the this doc for more details.

干杯!:D

这篇关于使用 FCM 从服务器发送推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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