depuis aujourd'hui j'ai rencontré le problème suivant avec GCM "abonnez-vous aux sujets". Nexus 6, Android 6.0.1, Services Google Play 9.0.83 Utilisation de google-play-services: 8.3.0 dans l'applicationAbonnez-vous aux sujets jette soudainement "java.io.IOException: InternalServerError"
Étape 1
Je suivre la documentation de Google pour obtenir le jeton par l'ID d'instance. Après avoir obtenu le jeton, je suis abonné à la rubrique "topics/global" et je stocke le token dans les préférences partagées.
protected void register() {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
try {
// [START register_for_gcm]
// Initially this call goes out to the network to retrieve the token, subsequent calls
// are local.
// R.string.gcm_defaultSenderId (the Sender ID) is typically derived from google-services.json.
// See https://developers.google.com/cloud-messaging/android/start for details on this file.
// [START get_token]
InstanceID instanceID = InstanceID.getInstance(this);
String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
// [END get_token]
Log.i(TAG, "GCM Registration Token: " + token);
// TODO: Implement this method to send any registration to your app's servers.
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
sharedPreferences.edit().putString("token", token).apply();
// You should store a boolean that indicates whether the generated token has been
// sent to your server. If the boolean is false, send the token to your server,
// otherwise your server should have already received the token.
sharedPreferences.edit().putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, true).apply();
// [END register_for_gcm]
} catch (Exception e) {
Log.d(TAG, "Failed to complete token refresh", e);
// If an exception happens while fetching the new token or updating our registration data
// on a third-party server, this ensures that we'll attempt the update at a later time.
sharedPreferences.edit().putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false).apply();
}
// Notify UI that registration has completed, so the progress indicator can be hidden.
Intent registrationComplete = new Intent(QuickstartPreferences.REGISTRATION_COMPLETE);
LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
}
Étape 2
Après un certain temps/interaction de l'utilisateur Je veux souscrire à des sujets supplémentaires. Je récupère le jeton des préférences partagées et essaie de m'abonner comme avant, mais cette fois-ci il échoue avec le "java.io.IOException: InternalServerError". L'exception est attrapé bien sûr, mais je ne sais pas comment procéder maintenant.
private void subscribeTopics() throws IOException {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
String token = sharedPreferences.getString("token", null);
if(token == null) {
Log.e(TAG, "No token");
return;
}
GcmPubSub pubSub = GcmPubSub.getInstance(this);
for (String topic : TOPICS) {
pubSub.subscribe(token, "/topics/" + topic, null); // <--- FAILS HERE
}
Log.d(TAG, "Subscribed to topics.");
}
Ce processus a fonctionné pendant les 5 derniers mois sans problème. Soudain, depuis ce matin, l'abonnement à des sujets supplémentaires (étape 2) échoue. Une idée si le passage à Firebase Cloud Messaging (FCM) a apporté des modifications de rupture?
Actuellement, toutes les applications de mes clients ne sont pas utilisables. Une aide rapide est vraiment appréciée.
J'ai vu le même problème à partir d'aujourd'hui matin. Je ne sais pas ce qui est mal c'est dire la signature com.google.android.gms pas valide Trouvé. et nous avons un long SHA –