简体   繁体   English

获取注册ID时出现GCM AUTHENTICATION_FAILED错误

[英]GCM AUTHENTICATION_FAILED error while getting registration id

I,m developing GCM app and recieve "error:AUTHENTICATION_FAILED". 我正在开发GCM应用,并收到“错误:AUTHENTICATION_FAILED”。 I,m using my samsung tab device.My code is below: 我正在使用我的三星标签设备。我的代码如下:

  private void registerInBackground() {
            new AsyncTask<Void, Void, String>() {
                @Override
                protected String doInBackground(Void... params) {
                    String msg = "";
                    try {

                        Log.i(TAG, "11111");
                        if (gcm == null) {
                            gcm = GoogleCloudMessaging.getInstance(context);
                            Log.i(TAG, "11dfsfsd111");

                        }
                        Log.i(TAG, "11dfsfsd111fsdfsdf");
                        regid = gcm.register(SENDER_ID);
                        Log.i(TAG, "id = :"+regid);
                         Log.i(TAG, "2222");
                        msg = "Device registered, registration ID=" + regid;

                        // You should send the registration ID to your server over HTTP, so it
                        // can use GCM/HTTP or CCS to send messages to your app.
                     //   sendRegistrationIdToBackend();

                        // For this demo: we don't need to send it because the device will send
                        // upstream messages to a server that echo back the message using the
                        // 'from' address in the message.

                        // Persist the regID - no need to register again.
                     //   storeRegistrationId(context, regid);
                    } catch (IOException ex) {
                        msg = "Error :" + ex.getMessage();
                        // If there is an error, don't just keep trying to register.
                        // Require the user to click a button again, or perform
                        // exponential back-off.
                    }
                    return msg;
                }

                @Override
                protected void onPostExecute(String msg) {
                     Log.i(TAG, "sdfdsfs:" + msg);
                    mDisplay.append(msg + "\n");
                }
            }.execute(null, null, null);
        }

i Get this msg when the control comes in postExecute function and print the "msg" variable. 当控件进入postExecute函数时,获取此msg并打印“ msg”变量。 I searched for the error and found that this error come due to wrong password of gmail sync acount, But i checked it and my password is correct. 我搜索了错误,发现此错误是由于gmail sync acount密码错误引起的,但是我检查了一下,密码正确。 Kindly help 请帮助

public void registerClient() {

        try {
            // Check that the device supports GCM (should be in a try / catch)
            GCMRegistrar.checkDevice(viewLogin);

            // Check the manifest to be sure this app has all the required
            // permissions.
            GCMRegistrar.checkManifest(viewLogin);

            // Get the existing registration id, if it exists.
            regId = GCMRegistrar.getRegistrationId(viewLogin);

            if (regId.equals("")) {

                registrationStatus = "Registering...";

                // register this device for this project
                GCMRegistrar.register(viewLogin, GCMIntentService.PROJECT_ID);
                regId = GCMRegistrar.getRegistrationId(viewLogin);

                registrationStatus = "Registration Acquired";

                // This is actually a dummy function. At this point, one
                // would send the registration id, and other identifying
                // information to your server, which should save the id
                // for use when broadcasting messages.

            } else {

                registrationStatus = "Already registered";

            }
            Log.d(TAG, regId);
            sendRegistrationToServer();
        } catch (Exception e) {

            e.printStackTrace();
            registrationStatus = e.getMessage();

        }

        Log.d(TAG, registrationStatus);

        // This is part of our CHEAT. For this demo, you'll need to
        // capture this registration id so it can be used in our demo web
        // service.

    }

please use this..its working in my project. 请使用this..it在我的项目中工作。 add in your manifestfile: 在清单文件中添加:

<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

I think you are using old GCM implementation. 我认为您正在使用旧的GCM实现。 New GCM implementation code is available on developer site( http://developer.android.com/google/gcm/client.html ). 可在开发者网站( http://developer.android.com/google/gcm/client.html )上获得新的GCM实施代码。 Account authentication and other type of authentication is properly handled here 帐户身份验证和其他类型的身份验证在此处正确处理

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM