2017-08-07 11 views
0

アプリがフォアグラウンドとバックグラウンドの両方にある場合、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); 
    } 

} 

enter image description here

enter image description here

+0

Firebaseコンソールを使用してプッシュ通知や実装されたサーバー側を送信していますか? –

+0

メッセージを送信するためにfirebaseコンソールを使用 –

答えて

0

は、マニフェストファイルでこれを追加してみてください。

<meta-data 
      android:name="com.google.firebase.messaging.default_notification_icon" 
      android:resource="@mipmap/ic_launcher" /> 
+0

はこれを試しましたが、まだ動作していません –

+0

あなたの質問に問題のイメージを追加できますか、本当に感謝しています。 @NikeshPatel –

+0

ちょっと待って –

関連する問題