簡體   English   中英

當應用程序處於后台時,我的FCM通知不會擴展

[英]My FCM notification does not expand when the app is in background

我正在實施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發行說明

現在,消息支持擴展手勢,允許Android UI在通知正文超過一行時顯示多行。

確保使用Firebase 9.4或更高版本作為依賴項。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM