如何在React Native Android上显示多行通知?

时间:2019-05-23 05:04:15

标签: android react-native react-native-android react-native-firebase

我已经创建了这样的通知:

const notification = new firebase.notifications.Notification()
    .setNotificationId('1')
    .setTitle('Reminder')
    .setBody('Looooooooooooooooooooooonggggggg messageeeeeeeeeeeeeeeeeeeeee longggggggggggggg messsssssagggeeeeeeeeee')
    .setData({
      key: true,
      data: {},
    })
    .android.setChannelId('test-channel')
    .android.setAutoCancel(true)
    .android.setPriority(firebase.notifications.Android.Priority.Max);

我想在通知中显示所有正文消息。但它只显示一行消息。

1 个答案:

答案 0 :(得分:1)

android对象中有一个bigText道具。您可以在https://rnfirebase.io/docs/v5.x.x/notifications/reference/AndroidNotification#setBigText此处查看文档,但为了总结一下这种做法

const notification = new firebase.notifications.Notification()
    .setNotificationId('1')
    .setTitle('Reminder')
    .setBody('Looooooooooooooooooooooonggggggg messageeeeeeeeeeeeeeeeeeeeee longggggggggggggg messsssssagggeeeeeeeeee')
    .setData({
      key: true,
      data: {},
    })
    .android.setChannelId('test-channel')
    .android.setAutoCancel(true)
    .android.setBigText('Looooooooooooooooooooooonggggggg messageeeeeeeeeeeeeeeeeeeeee longggggggggggggg messsssssagggeeeeeeeeee')
    .android.setPriority(firebase.notifications.Android.Priority.Max);