简体   繁体   English

用gcm推送通知Android

[英]push notification android with gcm

I want to develop an android application having push up notification. 我想开发一个具有上推通知的android应用程序。 the notification will be shown when admin upload new in the website or announce message in the admin account in mobile application. 当管理员在网站上上传新内容或在移动应用程序中的admin帐户中宣布消息时,将显示通知。 Generally speaking, I want the push up notification done by website and mobile application. 一般来说,我希望通过网站和移动应用程序完成推送通知。 I have searched almost for 3 days but it is difficult to do it successfully. 我已经搜索了将近3天,但是很难成功完成搜索。 I know GCM can do this. 我知道GCM可以做到这一点。 But I do not know how to use it properly. 但是我不知道如何正确使用它。 I have watched many tutorial video but it does not work. 我已经看了很多教程视频,但是它不起作用。 Is there anybody has experience doing push up notification in android using GCM. 有没有人有使用GCM在Android中进行俯卧撑通知的经验。 Can you teach me? 你能教我吗?

I suggest you do the following: 我建议您执行以下操作:

1) find out your device's GCM token 2) send a push notification to that device using a software like POSTMAN or a CURL command (push notifications are actually REST requests) 3) set up your backend to actually do step #2 4) Enjoy 1)找出您设备的GCM令牌2)使用POSTMAN或CURL命令之类的软件向该设备发送推送通知(推送通知实际上是REST请求)3)设置您的后端以实际执行第2步4)享受

You can follow this tutorial to learn how to use Push Notification using GCM in Android Studio. 您可以按照本教程学习如何在Android Studio中使用GCM使用推送通知。

You can learn here the step by step procedure on how to setup your project with push notification. 您可以在此处了解有关如何使用推送通知设置项目的分步过程。

  • creating a project on Google Developer Console 在Google Developer Console上创建项目
  • enable the Google Cloud messaging API 启用Google Cloud消息传递API
  • generate the server key and project number for further use 生成服务器密钥和项目号以备将来使用
  • register the app from android using the project number 使用项目编号从android注册应用
  • Google will return a registration ID send this ID to your server Google将返回注册ID,并将此ID发送到您的服务器
  • send message from your server to GCM to corresponding registration ID 从您的服务器向GCM发送消息到相应的注册ID
  • GCM will send you push message through BroadCast Receiver and show it as a notification GCM将通过BroadCast接收器向您发送推送消息,并将其显示为通知

This tutorial also includes some picture for the developers to learned easily in setting up the project. 本教程还包括一些图片,供开发人员在设置项目时轻松学习。

Note that this service is only available for small messages to the client applications: 4096 Bytes is the limit, so only lightweight information can be sent. 请注意,此服务仅适用于发送给客户端应用程序的小消息:限制为4096字节,因此只能发送轻量级信息。

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

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