Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit a509e8a

Browse files
committed
Allow HTML tags in bigText field
1 parent 894d424 commit a509e8a

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
import android.os.Build;
2323
import android.os.Bundle;
2424
import android.service.notification.StatusBarNotification;
25+
import android.text.Spanned;
2526
import android.util.Log;
2627
import androidx.core.app.RemoteInput;
2728

2829
import androidx.annotation.RequiresApi;
2930
import androidx.core.app.NotificationCompat;
31+
import androidx.core.text.HtmlCompat;
3032

3133
import com.facebook.react.bridge.Arguments;
3234
import com.facebook.react.bridge.ReadableArray;
@@ -369,12 +371,6 @@ public void sendToNotificationCentreWithPicture(Bundle bundle, Bitmap largeIconB
369371
if (subText != null) {
370372
notification.setSubText(subText);
371373
}
372-
373-
String bigText = bundle.getString("bigText");
374-
375-
if (bigText == null) {
376-
bigText = message;
377-
}
378374

379375
NotificationCompat.Style style;
380376

@@ -401,7 +397,14 @@ public void sendToNotificationCentreWithPicture(Bundle bundle, Bitmap largeIconB
401397
.bigLargeIcon(bigLargeIconBitmap);
402398
}
403399
else {
404-
style = new NotificationCompat.BigTextStyle().bigText(bigText);
400+
String bigText = bundle.getString("bigText");
401+
402+
if (bigText == null) {
403+
style = new NotificationCompat.BigTextStyle().bigText(message);
404+
} else {
405+
Spanned styledText = HtmlCompat.fromHtml(bigText, HtmlCompat.FROM_HTML_MODE_LEGACY);
406+
style = new NotificationCompat.BigTextStyle().bigText(styledText);
407+
}
405408
}
406409

407410
notification.setStyle(style);

0 commit comments

Comments
 (0)