gpt4 book ai didi

android - 当应用程序处于后台时,我的 FCM 通知不会展开

转载 作者:太空狗 更新时间:2023-10-29 14:44:29 25 4
gpt4 key购买 nike

我正在实现FCM来推送通知,但是当通知内容很大时,我试图扩展通知。
应用处于后台时无法执行

这是我的代码

PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_stat_new_logo).setTicker(title).setWhen(0)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_stat_new_logo))
.setContentTitle("SuezApp")
.setContentText(remoteMessage.getNotification().getBody())
.setAutoCancel(true)
.setStyle(new NotificationCompat.BigTextStyle().bigText(title))
.setStyle(new NotificationCompat.BigTextStyle().bigText(remoteMessage.getNotification().getBody()))
.setPriority(Notification.PRIORITY_MAX)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
final NotificationCompat.BigTextStyle style = new NotificationCompat.BigTextStyle(notificationBuilder);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());

如何在应用程序处于后台时展开它?

最佳答案

根据 Firebase 9.4 release notes :

Expanded gestures are now supported for messages, allowing the Android UI to display multiple lines when the body of a notification exceeds a single line.

确保您使用的是 Firebase 9.4 或更高版本作为依赖项。

关于android - 当应用程序处于后台时,我的 FCM 通知不会展开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42182896/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com