アプリがフォアグラウンドとバックグラウンドの両方にある場合、firebaseを使用して通知を送信したいと思います。私はこれを達成することができますが、問題はデフォルトのfirebase通知アイコン(白い四角の円)の代わりに表示されます。ランチャーアイコンが表示されます。私は次のコードを実装しましたが、まだ表示されていません。私はここで何が問題なのか分かりません。ここでは、コードFirebaseMessagingServiceがFirebase通知がアイコンを表示していない
public class MyFirebaseMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Intent intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
notificationBuilder.setContentTitle("Dream 11 Prediction Guru");
notificationBuilder.setContentText(remoteMessage.getNotification().getBody());
notificationBuilder.setAutoCancel(true);
notificationBuilder.setSmallIcon(R.mipmap.ic_launcher_round);
//notificationBuilder.setLargeIcon(R.mipmap.ic_launcher);
notificationBuilder.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0,notificationBuilder.build());
}
}
あるFirebaseInstanceIdServiceコード
public class MyFirebaseInstanceIdService extends FirebaseInstanceIdService {
private static final String REG_TOKEN = "REG_TOKEN";
@Override
public void onTokenRefresh() {
String recent_token = FirebaseInstanceId.getInstance().getToken();
Log.d(REG_TOKEN,recent_token);
}
}
Firebaseコンソールを使用してプッシュ通知や実装されたサーバー側を送信していますか? –
メッセージを送信するためにfirebaseコンソールを使用 –