android通知默认展开,android – Firebase展开式通知当应用程序在后台时显示图像

我正在

Android中实施FCM通知,但根据应用状态(背景与前景)通知有何不同?

我正在使用FCM API与邮递员发送通知,这是通知结构:

{ "notification": {

"title": "Notification title","body": "Notification message","sound": "default","color": "#53c4bc","click_action": "MY_BOOK","icon": "ic_launcher"

},"data": {

"main_picture": "URL_OF_THE_IMAGE"

},"to" : "USER_FCM_TOKEN"

}

要渲染的图像取自data.main_picture.

我已经实现了我自己的FirebaseMessagingService,它使通知在前台状态下完美显示.通知代码是下一个:

NotificationCompat.BigPictureStyle notiStyle = new NotificationCompat.BigPictureStyle();

notiStyle.setSummaryText(messageBody);

notiStyle.bigPicture(picture);

Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

NotificationCompat.Builder notificationBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)

.setSmallIcon(R.drawable.ic_launcher)

.setLargeIcon(bigIcon)

.setContentTitle(title)

.setContentText(messageBody)

.setAutoCancel(true)

.setSound(defaultSoundUri)

.setContentIntent(pendingIntent)

.setStyle(notiStyle); code here

NotificationManager notificationManager =

(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

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

但是,在后台,服务甚至不执行.在AndroidManifest.xml中,Firebase服务的声明如下:

android:name=".MyFirebaseMessagingService">

android:name=".MyFirebaseInstanceIDService">

我的问题不是LargeIcon或SmallIcon,而是显示大图.

感谢您的支持.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值