eclipse中将支持通过GCM推送通知 [英] Will push notifications through GCM be supported in eclipse

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

问题描述

我正在使用eclipse IDE进行开发。我遵循了很多教程,并在我的项目中实现了推送通知,但我没有得到GCM注册ID,所以我的问题是: eclipse 是否支持推送通知?

I am using eclipse IDE for development. I followed lots of tutorials and implemented push notifications in my project but I'm not getting the GCM Registration id, So my questions is: will eclipse support the push notifications or not?

下面是代码片段;如果你需要更清晰的话请在下面评论。

Below is the code snippet; if you need more clarity please comment below.

        registerReceiver(mHandleMessageReceiver, new IntentFilter(DISPLAY_MESSAGE_ACTION));

    Log.v("testing", "testing");
    // Get GCM registration id
    final String regId = GCMRegistrar.getRegistrationId(this);

    Log.v("regId", regId);
    // Check if regid already presents
    if (regId.equals("")) {
        // Registration is not present, register now with GCM
        Log.v("registerd","am here");

        GCMRegistrar.register(this, SENDER_ID);

    } else {
        // Device is already registered on GCM
        if (GCMRegistrar.isRegisteredOnServer(this)) {
            // Skips registration.              
            Toast.makeText(getApplicationContext(), "Already registered with GCM", Toast.LENGTH_LONG).show();
        } else {
            // Try to register again, but not in the UI thread.
            // It's also necessary to cancel the thread onDestroy(),
            // hence the use of AsyncTask instead of a raw thread.
            final Context context = this;
            Log.v("hello","am here");

            mRegisterTask = new AsyncTask<Void, Void, Void>() {
                @Override
                protected Void doInBackground(Void... params) {
                    // Register on our server
                    // On server creates a new user
                    ServerUtilities.register(context, name, email, regId);
                    return null;
                }

                @Override
                protected void onPostExecute(Void result) {
                    mRegisterTask = null;
                }

            };
            mRegisterTask.execute(null, null, null);
        }


推荐答案

以下教程.. 链接

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

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