今日、GCMで「トピックに登録」という次の問題が発生しています。 Nexus 6、Android 6.0.1、Google Playサービス9.0.83 google-play-servicesの使用:アプリ内で8.3.0トピックを購読すると、突然 "java.io.IOException:InternalServerError"が返される
ステップ1
私は、インスタンスIDを通じてトークンを取得するためのGoogleからのドキュメントに従ってください。 トークンを取得した後、「topics/global」トピックを正常に購読し、トークンを共有設定に保存します。
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);
}
ステップ2
しばらくする/ユーザーとの対話に私は、追加のトピックにサブスクライブしたいと思います。 共有環境設定からトークンを取得し、以前と同様に購読しようとしますが、今回は "java.io.IOException:InternalServerError"で失敗します。 例外はもちろんキャッチされていますが、今はどのように進めるかわかりません。
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.");
}
このプロセスは、問題なしで過去5ヶ月間有効でした。突然、今朝以降、追加のトピック(ステップ2)の購読は失敗します。 Firebase Cloud Messaging(FCM)への切り替えが急激な変化をもたらしたかどうか考えてください。
現在のところ、すべてのクライアントアプリケーションは使用できません。 速いヘルプは本当に感謝しています。
私は今日の朝から同じ問題を見てきました。 com.google.android.gmsの署名が無効であることが間違っているかどうかわかりません。長いSHAを持っている –