我在使用Firebase推送通知时遇到问题,
问题:
应用程序图标在Android 6.0及以上的系统中会变成白色,因此我创建了白色和透明的图标集,现在推送通知的图标看起来符合我要求,但只有当应用程序在前台时才能看到。当用户收到通知并关闭应用程序时,图标仍然是白色。
我的清单文件:
我的清单文件:
<application
android:name="com.xxxx"
android:allowTaskReparenting="true"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_xxxx"
android:label="@string/app_name"
android:largeHeap="true"
android:theme="@style/AppTheme">
通知代码:当我收到推送通知时
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder;
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.xxxxxx)
.setColor(getResources().getColor(R.color.accent))
.setContentTitle(messageTitle)
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(contentIntent);
} else {
notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(messageTitle)
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(contentIntent);
}
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(count, notificationBuilder.build());
收到消息时的代码
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
//Displaying data in log
//It is optional
Log.d(TAG, "Notification Message TITLE: " + remoteMessage.getNotification().getTitle());
Log.d(TAG, "Notification Message BODY: " + remoteMessage.getNotification().getBody());
Log.d(TAG, "Notification Message DATA: " + remoteMessage.getData().toString());
//Calling method to generate notification
//remoteMessage.getNotification().getBody()
sendNotification(remoteMessage.getNotification().getTitle(),
remoteMessage.getNotification().getBody(), remoteMessage.getData());
}
onMessageReceived
代码吗? - Bhuvanesh BS