简体   繁体   English

Android:将通知从php服务器发送到通知栏到android应用程序

[英]Android: Send a notification to notification bar from php server to android application

I wanted to send a notification to android client from the server(php), which will be displayed to the user through notification bar. 我想从服务器(php)向Android客户端发送通知,该通知将通过通知栏显示给用户。 How can I do this! 我怎样才能做到这一点! please provide a good tutorial on this Thanks :) 请为此提供一个很好的教程:)

From the 26th of June, 2012 Google has deprecated C2DM in favour of Google Cloud Messaging for Android (GCM). 从2012年6月26日起,Google弃用了C2DM,转而使用Android的Google Cloud Messaging(GCM)。

All the docs and info relating to GCM can be found at http://developer.android.com/guide/google/gcm/index.html including details on how to migrate from C2DM to GCM. 有关GCM的所有文档和信息都可以在http://developer.android.com/guide/google/gcm/index.html上找到,包括有关如何从C2DM迁移到GCM的详细信息。

The solution I can think of is to use Cloud to Device Messaging (C2DM), the Android equivalent push notifications. 我能想到的解决方案是使用Cloud to Device Messaging(C2DM),即Android等效的推送通知。

For that you will have to: 为此,您将必须:

  1. Register for C2DM. 注册C2DM。
  2. Register your device to C2DM. 将设备注册到C2DM。
  3. A registration ID is returned through a broadcast. 通过广播返回注册ID。 (Server should track this device registration ID) (服务器应跟踪此设备注册ID)
  4. Get an authentication token for your server. 获取服务器的身份验证令牌。
  5. Server shall use the authentication token and the device registration ID to send messages to your device 服务器应使用身份验证令牌和设备注册ID将消息发送到您的设备
  6. Setup your device to receive broadcast messages from C2DM and create a notification to show up in your notifications bar. 设置设备以接收来自C2DM的广播消息,并创建一个通知以显示在通知栏中。

The above steps are just an overview, I personally learned C2DM using this tutorial and suggest you do the same. 上面的步骤只是一个概述,我个人是使用本教程学习C2DM的,建议您这样做。 Try running the code he has provided. 尝试运行他提供的代码。

the easiest way to get push notification from server is to use c2dm server. 从服务器获取推送通知的最简单方法是使用c2dm服务器。 Using c2dm server you can push message to any android device. 使用c2dm服务器,您可以将消息推送到任何android设备。 The best tutorial for c2dm is, 对于c2dm最好的教程是

http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html

you can get detailed information regarding c2dm over here. 您可以在此处获取有关c2dm的详细信息。

And you can check this post to register application server with c2dm and to send message from server to android device via c2dm server, C2DM implementation PHP code 您可以检查此帖子以向c2dm注册应用服务器,并通过c2dm服务器( C2DM实现PHP代码)将消息从服​​务器发送到android设备

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

相关问题 如何从一个 android 应用程序向其他 android 应用程序发送通知? - How to send notification from one android application to other android application? 从Java服务器向服务器发送推送通知 - Send push notification from server to android device in Java 如何使用GCM从Java服务器向Android应用程序发送通知? - How to send notification to Android app from Java server using GCM? 从我的 Java Web 服务器向 Android 手机发送推送通知 - Send Push Notification to Android mobiles from my Java Web Server Android使用GCM和PHP将通知从设备发送到其他设备 - Android send notification from device to other device using GCM and PHP 间隔发送一次android通知 - Send a notification with android at an interval 通知栏上的“操作”按钮不适用于Android - Action button from notification bar not working Android Android从应用程序A向应用程序B发送通知 - Android sending notification from application A to application B 推送通知未显示在Android的通知栏中 - Push Notification is not displaying in Notification Bar Android 如何在Android应用程序中向同一应用程序的注册用户发送通知 - How to send notification to registered users of same application in android application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM