谷歌云消息 - 示例服务器 [英] Google Cloud messaging - Sample Server
问题描述
我需要谷歌云消息示例应用程序。与样本服务器来测试我的应用程序。任何一个可以帮助我在这?
我需要一个样本服务器来测试我的$ C $词已经写好了code,但我不知道wheather将工作或没有。我不知道服务器端的编码,以便任何人都可以帮助我在此。这里是我的code
意图服务
包com.example.pushnotificationsample;
进口android.content.Context;
公共类GCMIntentService扩展GCMBaseIntentService {
保护GCMIntentService(字符串senderId){
超(senderId);
// TODO自动生成构造函数存根
}
@覆盖
保护无效的onError(背景为arg0,串ARG1){
// TODO自动生成方法存根
}
@覆盖
保护无效的onMessage(背景为arg0,意图msgIntent){
// TODO自动生成方法存根
Log.d(GCM,收到了一条消息);
//弦乐味精= msgIntent.getStringExtra(信息);
Log.d(GCM,msgIntent.toString());
//从意图获取数据并发送至notificaion吧
}
@覆盖
保护无效onRegistered(背景为arg0,串ARG1){
// TODO自动生成方法存根
}
@覆盖
保护无效onUnregistered(背景为arg0,串ARG1){
// TODO自动生成方法存根
}
}
我的主要活动
包com.example.pushnotificationsample;
进口android.app.Activity;
进口com.google.android.gcm.GCMRegistrar;
进口android.os.Bundle;
进口android.util.Log;
公共类MainActivity延伸活动{
@覆盖
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.activity_main);
GCMRegistrar.checkDevice(本);
// GCMRegistrar.checkManifest(本);
最后弦乐REGID = GCMRegistrar.getRegistrationId(本);
如果(regId.equals()){
GCMRegistrar.register(这一点,555817657362);
Log.v(消息,注册);
} 其他 {
Log.v(消息,已登记);
}
}
}
您需要通过Android SDK中下载。转到窗口 - > Android的SDK管理器。向下滚动到额外的检查谷歌云消息传递并安装。
完成后,你可以检查在: Android的SDK /演员/谷歌/ GCM /样本
或者你可以试试这个(我已经上传自己): GCM
有关服务器端,检查这样的回答: http://stackoverflow.com/a/11253231/554740
I need a sample application for Google Cloud messaging. with a sample server to test my app. can any one help me on this?
I need a sample server to test my code i already written the code but i dont know wheather it will work or not. i dont know server side coding so anyone could help me on this. here is my code
intent service
package com.example.pushnotificationsample;
import android.content.Context;
public class GCMIntentService extends GCMBaseIntentService {
protected GCMIntentService(String senderId) {
super(senderId);
// TODO Auto-generated constructor stub
}
@Override
protected void onError(Context arg0, String arg1) {
// TODO Auto-generated method stub
}
@Override
protected void onMessage(Context arg0, Intent msgIntent) {
// TODO Auto-generated method stub
Log.d("GCM", "RECIEVED A MESSAGE");
// String msg=msgIntent.getStringExtra("Message");
Log.d("GCM", msgIntent.toString());
// Get the data from intent and send to notificaion bar
}
@Override
protected void onRegistered(Context arg0, String arg1) {
// TODO Auto-generated method stub
}
@Override
protected void onUnregistered(Context arg0, String arg1) {
// TODO Auto-generated method stub
}
}
my main activity
package com.example.pushnotificationsample;
import android.app.Activity;
import com.google.android.gcm.GCMRegistrar;
import android.os.Bundle;
import android.util.Log;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GCMRegistrar.checkDevice(this);
// GCMRegistrar.checkManifest(this);
final String regId = GCMRegistrar.getRegistrationId(this);
if (regId.equals("")) {
GCMRegistrar.register(this, "555817657362");
Log.v("Msg", "registered");
} else {
Log.v("Msg", "Already registered");
}
}
}
You need to download via Android SDK. go to Window->Android SDK Manager. scroll down to extra and check "Google Cloud Messaging" and install.
after completed, you may check at : android-sdk/extras/google/gcm/samples
or you could try this (I've uploaded myself) : gcm
for server side, check on this answer : http://stackoverflow.com/a/11253231/554740
这篇关于谷歌云消息 - 示例服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!