0

내 앱의 푸시 알림을 위해 Firebase 알림을 사용하고 있습니다. 정상적으로 작동하지만 앱이 실행되고 있지 않을 때 알림 아이콘이 모두 흰색 원으로 표시됩니다. SDK 버전 23을 타겟팅하고 있으며 Roman Nurik의 알림 아이콘 생성기를 사용하여 흰색 투명 아이콘을 생성하고 있습니다.Android 알림 앱이 실행 중이 아닌 경우 흰색 동그라미

앱이 포 그라운드에서 실행 중일 때 알림 아이콘이 올바르게 표시됩니다. img

그러나 앱이 백그라운드이거나 죽으면 아이콘이 일반 흰색 원으로 바뀝니다.

private void sendNotification(String messageTitle, String messageBody) { 

    Intent intent = new Intent(this, MainActivity.class); 
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 
      PendingIntent.FLAG_ONE_SHOT); 

    NotificationCompat.Builder notification = new NotificationCompat.Builder(this) 
      .setSmallIcon(R.drawable.ic_stat_notification_icon) 
      .setContentTitle(messageTitle) 
      .setContentText(messageBody) 
      .setStyle(new NotificationCompat.BigTextStyle().bigText(messageBody)) 
      .setAutoCancel(true) 
      .setPriority(Notification.PRIORITY_DEFAULT) 
      .setDefaults(Notification.DEFAULT_ALL) 
      .setContentIntent(pendingIntent); 

    NotificationManager notificationManager = 
      (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 

    notificationManager.notify(0, notification.build()); 

} 

답변

1

이미 유사한 문제에 대한 답을 발견했습니다 : Notification Icon with the new Firebase Cloud Messaging system

불행하게도이 SDK 9.0.0에서 중포 기지 알림의 제한 사항입니다 img

여기 내 알림 빌더 방법입니다 . 앱이 배경에있을 때 실행 프로그램 아이콘은 콘솔에서 으로 보낸 메시지에 대한 매니페스트 (필수 Android 트 틴팅 포함)에서 사용됩니다.

앱에서 (또는 데이터 메시지가 전송) 당신이 사용자 지정하는 것이 자신의 논리를 사용할 수 있어야하고, HTTP에서 메시지를 보내는 경우 아이콘을 사용자 정의에 당신이 할 수 있어야한다 전경에있는 경우/XMPP API. 지금 콘솔에서 보낸 메시지가 있으면 동작을 보게됩니다.

이 중포 기지 알림 버그를 방지하는 가장 좋은 방법은 19build.gradletargetSdkVersion을 변경하는 것 같다. 알림 아이콘이 표시됩니다. Firebase가 잠시 후에이 문제를 해결할 것입니다.

+0

답장을 보내 주셔서 감사합니다. 즉, Firebase 콘솔에서 테스트 알림을 보낼 때만 문제가 발생했음을 의미합니까? 실제 백엔드 서버에서 실제 알림을 보내는 경우 다음과 같은 문제가 발생하지 않습니다. –

+0

네, 바로 그것이 의미하는 바입니다. 위의 게시물에서 위의 다른 솔루션도 확인하십시오. 태그 중 'AndroidManifest.xml'에있는 ... 태그를 확인하십시오.하지만 Firebase 콘솔 버그라고 확신합니다. – piotrek1543

0

이 코드를 시도 도움이 될 것입니다 희망 :

Intent intent = new Intent(this, TabActivity.class); 
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
    PendingIntent 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(getNotificationIcon()) 
      .setContentTitle("IDS DMS Support") 
      .setContentText(messageBody) 
      .setAutoCancel(true) 
      .setSound(defaultSoundUri) 
      .setContentIntent(pendingIntent); 


    NotificationManager notificationManager = 
      (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); 
0

나는 장치가 안드로이드 롤리팝를 실행중인 경우 앱에 실루엣 아이콘을 추가하고 사용할 필요가 있다고 생각합니다.

알림을위한 작은 아이콘을 얻으려면 아래 코드를 사용하십시오.

protected int getNotificationIcon() { 
     boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP); 
     return useWhiteIcon ? R.drawable.ic_silhouette : R.drawable.ic_launcher; 
    } 

전체 솔루션 Here을 볼 수 있습니다.

나는 똑같은 일을하고 잘 작동한다.

관련 문제