2017-07-17 6 views
0

アンドロイドのプッシュ通知メッセージの隣にアイコンが表示されます。コードナビアプリがあり、iOSプッシュメッセージのアイコンが表示されますが、Androidではプッシュメッセージの横に白い丸が表示されます。プッシュ通知メッセージのアイコンを表示する方法

私は私のconfig.xmlファイルにあなたの助けを

<platform name="android"> 

     <icon src="splash/icon/android/icon-96-xhdpi.png" /> 
     <icon density="ldpi" src="splash/icon/android/icon-36-ldpi.png" /> 
     <icon density="mdpi" src="splash/icon/android/icon-48-mdpi.png" /> 
     <icon density="hdpi" src="splash/icon/android/icon-72-hdpi.png" /> 
     <icon density="xhdpi" src="splash/icon/android/icon-96-xhdpi.png" /> 
     <icon density="xxhdpi" src="splash/icon/android/icon-144-xxhdpi.png" /> 
     <icon density="xxxhdpi" src="splash/icon/android/icon-192-xxxhdpi.png" /> 

    </platform> 

おかげで、このセットアップを持って

答えて

6

こんにちは、あなたはちょうどあなたが通知アイコンを取得することができます MyFirebaseMessagingServiceにonMessageReceived()からこのメソッドを呼び出します 白いアイコンの代わりに。これがあなたを助けてくれることを願っています。これはアンドロイド向けです。 - Icon not displaying in notification: white square shown instead

private void sendNotification(String message, String mAction) { 
     int id = (int) System.currentTimeMillis(); 
     PendingIntent pendingIntent = null; 
     Intent intent = new Intent(this, SplashActivity.class); 
     intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | 
     Intent.FLAG_ACTIVITY_SINGLE_TOP); 
     pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); 

     Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); 
     NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) 
       .setSmallIcon(R.mipmap.ic_launcher) 
       .setContentTitle(getString(R.string.app_name)) 
       .setContentText(message) 
       .setAutoCancel(true) 
       .setSound(defaultSoundUri) 
       .setContentIntent(pendingIntent); 
     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 
      notificationBuilder.setSmallIcon(R.mipmap.ic_launcher); 
     } else { 
      notificationBuilder.setSmallIcon(R.mipmap.ic_launcher); 
     } 
     NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
     notificationManager.notify(id, notificationBuilder.build()); 
    } 
関連する問題