私は自分の電話機トレイに個人的な通知を表示しようとしますが、私は金持ちではありません。アンドロイドfirebase reg idは受信されましたが通知は電話機に表示されません
FireBase Cloud Messagingでデバイスからトークンを取得し、Google Firebase通知コンソールで通知テストを送信する際に問題が発生しましたが、通知は記録されずアンドロイド仮想デバイスにプッシュされません。 FCMのドキュメントは、私が以下にあるコードとほぼ同じです。また、firebaseで動作するプッシュ通知を取得するために他に何が必要なのでしょうか。私はすべてのセットアップ情報(build.gradleの追加、Google Playサービスのインストールなど)をドキュメントに記載されている通りに行ったが、まだメッセージを生成していない。私がログキャットやデバイスにプッシュ通知を受け取っていないというコードで何が問題になっていますか?私が助けてくれる情報があれば教えてください。ありがとう。
mRegistrationBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Config.REGISTRATION_COMPLETE)) {
FirebaseMessaging.getInstance().subscribeToTopic(Config.TOPIC_GLOBAL);
displayFirebaseRegId();
} else if (intent.getAction().equals(Config.PUSH_NOTIFICATION))
{
String message = intent.getStringExtra("message");
Toast.makeText(getApplicationContext(), "Push notification: " + message, Toast.LENGTH_LONG).show();
txtMessage.setText(message);
}
}
};
displayFirebaseRegId();
}
private void displayFirebaseRegId() {
SharedPreferences pref = getApplicationContext().getSharedPreferences(Config.SHARED_PREF, 0);
String regId = pref.getString("regId", null);
Log.e(TAG, "Firebase reg id: " + regId);
if (!TextUtils.isEmpty(regId))
txtRegId.setText("Firebase Reg Id: " + regId);
else
txtRegId.setText("Firebase Reg Id is not received yet!");
}
@Override
protected void onResume() {
super.onResume();
LocalBroadcastManager.getInstance(this).registerReceiver(mRegistrationBroadcastReceiver,
new IntentFilter(Config.REGISTRATION_COMPLETE));
LocalBroadcastManager.getInstance(this).registerReceiver(mRegistrationBroadcastReceiver,
new IntentFilter(Config.PUSH_NOTIFICATION));
NotificationUtils.clearNotifications(getApplicationContext());
}
@Override
protected void onPause() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(mRegistrationBroadcastReceiver);
super.onPause();
}
そして、私は火災ベースのメッセージングのlibが追加されますが、次のとおりです。
compile 'com.google.firebase:firebase-messaging:11.0.4'