Android通知图标问题 [英] Android notification icon issue

查看:161
本文介绍了Android通知图标问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题.我有两种在Android应用中发送通知的方法;一个来自Android服务,另一个来自FCM.

I have a strange issue. I have two way to send notifications in my Android app; one from the Android service and the other through FCM.

方案如下:

  1. 无论应用程序是否正在运行,从Android服务发送的通知图标均正确显示.
  2. 应用运行时,如果我通过FCM发送通知,通知图标仍会正确显示.
  3. 但是如果该应用未运行,并且我通过FCM发送通知,则会显示一个白色正方形而不是通知图标.

我在FCMService中的代码:

My code in 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());

推荐答案

这是FMC错误,在github fcm页面中有详细说明.

This is a FMC bug detailed in github fcm page.

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

这篇关于Android通知图标问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆