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

时间:2017-02-12 00:29:45

标签: android push-notification notifications android-notifications

我正在实施 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());

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

1 个答案:

答案 0 :(得分:0)

根据Firebase 9.4 release notes

  

消息现在支持扩展手势,允许Android UI在通知正文超过一行时显示多行。

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

相关问题