Commit 6f0f32c3 authored by yunussaha's avatar yunussaha

added big picture style to android notification

by just adding a key called picture to  the notification payload, we can
display image on android notification.
parent 3064ba25
...@@ -133,6 +133,28 @@ public class FIRLocalMessagingHelper { ...@@ -133,6 +133,28 @@ public class FIRLocalMessagingHelper {
notification.setStyle(new NotificationCompat.BigTextStyle().bigText(bigText)); notification.setStyle(new NotificationCompat.BigTextStyle().bigText(bigText));
} }
//picture
String picture = bundle.getString("picture");
if(picture!=null){
NotificationCompat.BigPictureStyle bigPicture = new NotificationCompat.BigPictureStyle();
if (picture.startsWith("http://") || picture.startsWith("https://")) {
Bitmap bitmap = getBitmapFromURL(picture);
bigPicture.bigPicture(bitmap);
} else {
int pictureResId = res.getIdentifier(picture, "mipmap", packageName);
Bitmap pictureResIdBitmap = BitmapFactory.decodeResource(res, pictureResId);
if (pictureResId != 0) {
bigPicture.bigPicture(pictureResIdBitmap);
}
}
bigPicture.setBigContentTitle(title);
bigPicture.setSummaryText(bundle.getString("body"));
notification.setStyle(bigPicture);
}
//sound //sound
String soundName = bundle.getString("sound", "default"); String soundName = bundle.getString("sound", "default");
if (!soundName.equalsIgnoreCase("default")) { if (!soundName.equalsIgnoreCase("default")) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment