简体   繁体   English

Google Cloud Messaging测试应用程序

[英]Google Cloud Messaging test application

I'm a PHP developer and I have this assignment where I have to send GCM messages to an android application. 我是一名PHP开发人员,因此我必须将GCM消息发送到android应用程序。

I have zero experience on developing android applications so I would like to know if there's a sandbox or a test application where I can test if my server is working properly. 我在开发android应用程序方面经验为零,所以我想知道是否有一个沙箱或测试应用程序,可以在其中测试服务器是否正常运行。

I'm creating the server with these instructions: GCM with PHP (Google Cloud Messaging) 我正在按照以下说明创建服务器: 具有PHP的GCM(Google云消息传递)

It seems that I need a server api key (which I know how to create in the google developer console) but how can I create a blank application? 似乎我需要一个服务器api密钥(我知道该如何在Google Developer Console中创建),但是如何创建空白应用程序? I need exact tutorial since I know nothing about it. 我需要确切的教程,因为我对此一无所知。

I found this answer earlier: https://stackoverflow.com/a/12437549/1278155 but I have no idea what to do with the .zip file provided. 我早些时候找到了这个答案: https : //stackoverflow.com/a/12437549/1278155,但是我不知道该如何处理提供的.zip文件。

1 1

You need to register the App on Google Console. 您需要在Google控制台上注册该应用。 For this you need following information about the application to which you wish to send notifications: 为此,您需要有关要向其发送通知的应用程序的以下信息:

  1. SHA Certificate : This is a key that uniquely identifies the Machine on which the app is being created and the app itself. SHA证书 :这是唯一标识在其上创建应用程序的计算机以及应用程序本身的密钥。 There is a Command Prompt command to get this key directly. 有一个命令提示符命令可直接获取此密钥。

  2. Package name : Each application has a unique Package Name as you have a URL for PHP projects. 包名称 :每个应用程序都有一个唯一的包名称,因为您有一个PHP项目的URL。

The app developer can provide with these details. 应用程序开发人员可以提供这些详细信息。 Then on successful app registration you will get ProjectCode and a Key. 然后,在成功注册应用程序后,您将获得ProjectCode和一个密钥。 These will be needed in further process 这些将在后续流程中使用

2 2

Next to go a bit deeper and explain why all this information is required by GCM, you see on device side, the app needs to register the user with GCM and in return it gets a GCM-ID at run time. 接下来,我们将更深入地解释GCM为何需要所有这些信息,您会在设备端看到,应用程序需要向GCM注册用户,然后作为回报,它会在运行时获取GCM-ID。 Then This GCM-ID received is passed on to the server side(You). 然后,收到的此GCM-ID会传递到服务器端(您)。 The developer will need ProjectID and Key that was generated in #1. 开发人员将需要在#1中生成的ProjectID和Key。

3 3

Now when you trigger your code to fire a GCM, you mention the GCM-IDs to send the notification to specific devices or else you can mention the ProjectID that you receive at the time of app registration with Google Console. 现在,当您触发代码触发GCM时,您将提及GCM-ID以将通知发送到特定设备,否则,您将提及在Google控制台注册应用程序时收到的ProjectID。 These parameters are handed over to Google's Side of things. 这些参数将移交给Google的物联网。

4 4

Now if you pass ProjectID, Google can fetch all corresponding GCM-IDs to this project-ID or else you have specifically passed some GCM-IDs. 现在,如果您传递ProjectID,则Google可以将所有相应的GCM-ID提取到该Project-ID,否则您已经专门传递了一些GCM-ID。 Then the Google will push a message to all devices corresponding to the GCM-IDs. 然后,Google会将消息推送到与GCM-ID对应的所有设备。

5

Still not over, The message reached the target device, but not the target Application on the device. 消息尚未到达目标设备,但未到达目标应用程序。 So for this purpose we need the package name at the time of registeration o Google console. 因此,为此,我们需要在Google控制台注册时使用软件包名称。

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

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