新的云通讯使用PHP的Andr​​oid [英] New cloud messaging with php android

查看:208
本文介绍了新的云通讯使用PHP的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新与谷歌的云消息,所以我一直在寻找这个教程,但我只是发现了古老的教程。我知道GCM改了一下,所以任何人都可以使用PHP来发送推送消息或类似的东西给我推荐一个新的教程。

I'm new with google cloud messaging, so I was looking for tutorials about this but I just found out old tutorials. I know GCM changed a bit, so Can anyone can recommend me a new tutorial using php to send push messages or something like that.

我发现这个问题,但我没有在控制台开发商找到registerId
GCM用PHP(谷歌云通讯)

I found this question but I didnt find registerId in console developer GCM with PHP (Google Cloud Messaging)

推荐答案

是的,GCM改变其控制台和文档了。这里是链接,使用PHP服务器最新的GCM教程。
http://www.programming-techniques.com/2014/01/google-cloud-messaging-gcm-in-android.html

Yes, the GCM has changed its console and documentation too. Here is the link for latest GCM tutorial using PHP server. http://www.programming-techniques.com/2014/01/google-cloud-messaging-gcm-in-android.html

您无法找到在控制台注册​​ID。有一个在控制台只有发件人ID(项目编号)。后来在节目中,当您使用发件人ID在GCM注册您的应用程序,只有这样,你获得注册ID。

You cannot find registration Id in the console. There is only sender id (project number) in the console. Later in the program, when you register your application in GCM using your sender ID, only then you get registration Id.

有很多谁搜索注册ID的开发者控制台初学者。让我澄清一下这个
当您注册到控制台,创建一个项目后,您将提供项目数量

There are lot of beginners who search the registration Id in the developer console. Let me clarify this When you register into the console, after creating a project, you will be provided with the project number

您将在程序中使用这个作为发件人ID来获得注册ID。这里是伪code这一点。

You will use this as a SENDER ID in the program to get the registration ID. Here is the pseudo code for this.

registration_id = gcm.register(sender_id)

从Android应用程序通过这个registration_id到应用服务器(如PHP)。

From the android application pass this registration_id to the application server (e.g. PHP).

URI url = null;
        try {
            url = new URI("http://YOUR_SERVER_URL/register.php?regId=" + registration_id);
        } catch (URISyntaxException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } 
        HttpClient httpclient = new DefaultHttpClient();
        HttpGet request = new HttpGet();
        request.setURI(url);
        try {
            httpclient.execute(request);
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

在register.php文件,获取注册ID

In register.php file, retrieve the registration ID

regId = $_GET['regId'];

,并将其保存到数据库中。
当你想将消息发送到Android应用程序,你可以简单地用这个注册ID并发送邮件。

and save it into the database. When you want to send the message to the android application, you can simply use this registration id and send your message.

这篇关于新的云通讯使用PHP的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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