2

奇妙な問題があります。Android アプリで通知を送信する方法は 2 つあります。1 つは Android サービスから、もう 1 つは FCM 経由です。

シナリオは次のとおりです。

  1. アプリの起動、停止に関わらず、Android サービスから送信される通知のアイコンは正しく表示されます。
  2. アプリの実行中に、FCM 経由で通知を送信すると、通知アイコンが正しく表示されます。
  3. しかし、アプリが実行されておらず、FCM 経由で通知を送信すると、通知アイコンの代わりに白い四角が表示されます。

FCMService の私のコード:

Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.drawable.notification_icon)
                .setContentTitle("Android App")
                .setContentText(messageBody)
                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setContentIntent(pendingIntent);

        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(0, notificationBuilder.build());
4

2 に答える 2

-1

これは、github fcm ページに詳述されている FMC バグです。

https://github.com/firebase/quickstart-android/issues/4

于 2016-06-06T08:27:46.690 に答える