简体   繁体   English

从android发送推送通知

[英]Send Push notification from android

I want to show push notification in my Android app.我想在我的 Android 应用中显示推送通知。 I have read online about this Firebase Cloud Messaging (Formerly known as GCM) but can't understand it properly.我在网上阅读了有关此 Firebase Cloud Messaging(以前称为 GCM)的信息,但无法正确理解它。 In every tutorial they are using some sort of console on webpage to send notifications to all users or a particular user.在每个教程中,他们都使用网页上的某种控制台向所有用户或特定用户发送通知。 What i want is to send notification automatically when a message is sent to some user(A send message to B and B gets a Notification) not from some console.我想要的是在向某个用户发送消息时自动发送通知(A 向 B 发送消息,B 收到通知)而不是来自某个控制台。

Any help?有什么帮助吗?

Push notifications can't go from user to user, ie from User A to User B.推送通知不能从用户到用户,即从用户 A 到用户 B。

The message must go from User A , to your server , and then from your server , to User B消息必须从User A发送到your server ,然后从your server发送到User B

If your messages are not too frequent (like emails, for example), you can build a Service that will poll messages from the server regularly and display a notification using the NotificationManager .如果您的消息不是太频繁(例如电子邮件),您可以构建一个Service ,该Service将定期从服务器轮询消息并使用NotificationManager显示NotificationManager

Otherwise you should stick to Firebase and create a server-side code to interact with the firebase API to notify your users... Firebase API for servers are explained here .否则,您应该坚持使用 Firebase 并创建一个服务器端代码来与 firebase API 交互以通知您的用户... 此处解释 用于服务器的 Firebase API。

Sticking with firebase is IMHO the better option...坚持使用firebase是恕我直言更好的选择......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM