diff --git a/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java b/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java index b22cf7b8..fe4c350a 100644 --- a/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java +++ b/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java @@ -236,6 +236,41 @@ public class RNFirebaseNotificationManager { Double badgeIconType = android.getDouble("badgeIconType"); nb = nb.setBadgeIconType(badgeIconType.intValue()); } + if (android.containsKey("bigPicture")) { + Bundle bigPicture = android.getBundle("bigPicture"); + + NotificationCompat.BigPictureStyle bp = new NotificationCompat.BigPictureStyle(); + Bitmap picture = getBitmap(bigPicture.getString("picture")); + if (picture != null) { + bp = bp.bigPicture(picture); + } + if (bigPicture.containsKey("largeIcon")) { + Bitmap largeIcon = getBitmap(bigPicture.getString("largeIcon")); + if (largeIcon != null) { + bp = bp.bigLargeIcon(largeIcon); + } + } + if (bigPicture.containsKey("contentTitle")) { + bp = bp.setBigContentTitle(bigPicture.getString("contentTitle")); + } + if (bigPicture.containsKey("summaryText")) { + bp = bp.setSummaryText(bigPicture.getString("summaryText")); + } + nb = nb.setStyle(bp); + } + if (android.containsKey("bigText")) { + Bundle bigText = android.getBundle("bigText"); + + NotificationCompat.BigTextStyle bt = new NotificationCompat.BigTextStyle(); + bt.bigText(bigText.getString("text")); + if (bigText.containsKey("contentTitle")) { + bt = bt.setBigContentTitle(bigText.getString("contentTitle")); + } + if (bigText.containsKey("summaryText")) { + bt = bt.setSummaryText(bigText.getString("summaryText")); + } + nb = nb.setStyle(bt); + } if (android.containsKey("category")) { nb = nb.setCategory(android.getString("category")); } diff --git a/lib/modules/notifications/AndroidNotification.js b/lib/modules/notifications/AndroidNotification.js index f67b3d3f..915b112b 100644 --- a/lib/modules/notifications/AndroidNotification.js +++ b/lib/modules/notifications/AndroidNotification.js @@ -7,6 +7,8 @@ import { BadgeIconType, Category, GroupAlert, Priority } from './types'; import type Notification from './Notification'; import type { BadgeIconTypeType, + BigPicture, + BigText, CategoryType, DefaultsType, GroupAlertType, @@ -22,6 +24,8 @@ export default class AndroidNotification { _actions: AndroidAction[]; _autoCancel: boolean | void; _badgeIconType: BadgeIconTypeType | void; + _bigPicture: BigPicture | void; + _bigText: BigText | void; _category: CategoryType | void; _channelId: string; _clickAction: string | void; @@ -75,6 +79,8 @@ export default class AndroidNotification { : []; this._autoCancel = data.autoCancel; this._badgeIconType = data.badgeIconType; + this._bigPicture = data.bigPicture; + this._bigText = data.bigText; this._category = data.category; this._channelId = data.channelId; this._clickAction = data.clickAction; @@ -128,6 +134,14 @@ export default class AndroidNotification { return this._badgeIconType; } + get bigPicture(): ?BigPicture { + return this._bigPicture; + } + + get bigText(): ?BigText { + return this._bigText; + } + get category(): ?CategoryType { return this._category; } @@ -298,6 +312,34 @@ export default class AndroidNotification { return this._notification; } + setBigPicture( + picture: string, + largeIcon?: string, + contentTitle?: string, + summaryText?: string + ): Notification { + this._bigPicture = { + contentTitle, + largeIcon, + picture, + summaryText, + }; + return this._notification; + } + + setBigText( + text: string, + contentTitle?: string, + summaryText?: string + ): Notification { + this._bigText = { + contentTitle, + summaryText, + text, + }; + return this._notification; + } + /** * * @param category @@ -639,6 +681,8 @@ export default class AndroidNotification { actions: this._actions.map(action => action.build()), autoCancel: this._autoCancel, badgeIconType: this._badgeIconType, + bigPicture: this._bigPicture, + bigText: this._bigText, category: this._category, channelId: this._channelId, clickAction: this._clickAction, diff --git a/lib/modules/notifications/types.js b/lib/modules/notifications/types.js index 1441d8e3..780eabab 100644 --- a/lib/modules/notifications/types.js +++ b/lib/modules/notifications/types.js @@ -85,6 +85,19 @@ export type PriorityType = $Values; export type SemanticActionType = $Values; export type VisibilityType = $Values; +export type BigPicture = {| + contentTitle?: string, + largeIcon?: string, + picture: string, + summaryText?: string, +|}; + +export type BigText = {| + contentTitle?: string, + summaryText?: string, + text: string, +|}; + export type Lights = {| argb: number, onMs: number, @@ -129,6 +142,8 @@ export type NativeAndroidNotification = {| actions?: NativeAndroidAction[], autoCancel?: boolean, badgeIconType?: BadgeIconTypeType, + bigPicture?: BigPicture, + bigText?: BigText, category?: CategoryType, channelId: string, clickAction?: string,