Not able to get GCM token in MI 5 with 5.0 Android and LG G6 with android 7?

51 views Asked by At

In my android app when user call login api I am sending the gcm token for push notification. It's working fine in all the devices except Mi 5 with 5.0 android and LG G6 with android 7. Mean I am not able to get the GCM token in these devices.

Right now I don't have particular device (Mi 5 and LG G6) to check the proper exception.

This is my code to get GCM token -

       AsyncTask<Void, Void, String> asyncTask = new AsyncTask< Void, Void, String > ( ) {
            @Override
            protected String doInBackground (Void... params) {
                try {
                    InstanceID instanceID = InstanceID.getInstance(context);
                    return instanceID.getToken(BuildConfig.GCM_SENDER_ID, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
                } catch ( Exception e ) {
                    //Crashlytics.logException(e);
                    return "";
                }
            }

            @Override
            protected void onPostExecute (String deviceId) {
                super.onPostExecute ( deviceId );
                if(null != deviceIdResponseable){
                    SavedPreferences.getSavedPreferenceInstance(context).setData(Constants.PREF_DEVICE_ID, deviceId);
                    deviceIdResponseable.deviceId ( deviceId );
                }
            }
        };

I also tried with Crashlytics.logException(e); in catch block but I didn't get any logs in crashlytics.

I don't know what can be the problem and need help :-)

Happy coding (++)

0

There are 0 answers