Will push notifications through GCM be supported in eclipse

烂漫一生 提交于 2019-12-12 03:46:31

问题


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);
        }

回答1:


Push notifications will work no matter what IDE you're using, but I have two pieces of advice for you:

  1. You need to migrate your project to Android Studio for better support.
  2. Your GCM registration library GCMRegistrar is too old. You need to get the latest version, checkout here.

Hope this helped :)




回答2:


Finally got the answer by using following tutorial.. link



来源:https://stackoverflow.com/questions/37117761/will-push-notifications-through-gcm-be-supported-in-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!