使用GCM推送通知 [英] Push Notification with GCM

查看:67
本文介绍了使用GCM推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我想在我的应用中实现推送通知。我跟进了这个链接:

http://fryerblog.com/发布/ 30057483199 / implementation-push-notifications-with-gcm [ ^ ]

  private   void  RegisterWithGCM()
{
GCMRegistrar.checkDevice( this );
GCMRegistrar.checkManifest( this );
final String regId = GCMRegistrar.getRegistrationId( this );
if (regId.equals( )){
GCMRegistrar.register( this ,SENDER_ID); // 注意:从配置中获取发件人ID。
} else {

Log.v( 注册 已经注册,注册: + regId);
}
}





有了这个,我得到了注册ID(APA91bGAJrOxxxxxxxxxx)。我在这一点上达成了意思,通过这个注册ID,我如何向我的Android模拟器发送通知。



请有人建议/指导我这个..



谢谢大家。

解决方案

 检查在Android SDK安装中找到的示例gcm代码。 `gcm-demo-server`代码将指导 这个。 

您有 从移动代码关键字>和 使用`MessageBuilder`沿 消息构建消息< span class =code-keyword>和发​​送。

帮助检查以下链接: -

http://developer.android.com/google/gcm/demo.html

&&

http://developer.android.com/reference/com/google/android/gcm/server/Message.Builder.html

全部最好。 : - )


Hi All,

I want to implement push notification in my app. i followed up this link:
http://fryerblog.com/post/30057483199/implementing-push-notifications-with-gcm[^]

private void RegisterWithGCM()
{
    GCMRegistrar.checkDevice(this);
    GCMRegistrar.checkManifest(this);
    final String regId = GCMRegistrar.getRegistrationId(this);
    if (regId.equals("")) {
      GCMRegistrar.register(this, SENDER_ID); // Note: get the sender id from configuration.
    } else {

      Log.v("Registration", "Already registered, regId: " + regId);
    }
}



With this i got the Registration ID(APA91bGAJrOxxxxxxxxxx). I struck up at this point meaning that with this Registration ID, how do i send notification to my android emulator.

Please can anyone suggest/guide me on this..

Thank you all.

解决方案

Check the sample gcm code found inside Android SDK installation. `gcm-demo-server` code will guide you on this.

You have to get the regID from your mobile and using `MessageBuilder` along with you message build the message and send.

For anymore help check the below link:-

http://developer.android.com/google/gcm/demo.html

&&

http://developer.android.com/reference/com/google/android/gcm/server/Message.Builder.html

All the best. :-)


这篇关于使用GCM推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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