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

Support using drawable as Android small icon #1787

Merged
merged 4 commits into from
Dec 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ In your `android/app/src/main/AndroidManifest.xml`
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

<application ....>
<!-- Change the value to true to enable pop-up for in foreground (remote-only, for local use ignoreInForeground) -->
<!-- Change the value to true to enable pop-up for in foreground on receiving remote notifications (for prevent duplicating while showing local notifications set this to false) -->
<meta-data android:name="com.dieam.reactnativepushnotification.notification_foreground"
android:value="false"/>
<!-- Change the resource name to your App's accent color - or any other color you want -->
Expand Down Expand Up @@ -322,7 +322,7 @@ PushNotification.localNotification({
ongoing: false, // (optional) set whether this is an "ongoing" notification
priority: "high", // (optional) set notification priority, default: high
visibility: "private", // (optional) set notification visibility, default: private
ignoreInForeground: false, // (optional) if true, the notification will not be visible when the app is in the foreground (useful for parity with how iOS notifications appear)
ignoreInForeground: false, // (optional) if true, the notification will not be visible when the app is in the foreground (useful for parity with how iOS notifications appear). should be used in combine with `com.dieam.reactnativepushnotification.notification_foreground` setting
shortcutId: "shortcut-id", // (optional) If this notification is duplicative of a Launcher shortcut, sets the id of the shortcut, in case the Launcher wants to hide the shortcut, default undefined
onlyAlertOnce: false, // (optional) alert will open only once with sound and notify, default: false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,12 @@ public void sendToNotificationCentreWithPicture(Bundle bundle, Bitmap largeIconB
String smallIcon = bundle.getString("smallIcon");

if (smallIcon != null && !smallIcon.isEmpty()) {
smallIconResId = res.getIdentifier(smallIcon, "mipmap", packageName);
smallIconResId = res.getIdentifier(smallIcon, "drawable", packageName);
if (smallIconResId == 0) {
smallIconResId = res.getIdentifier(smallIcon, "mipmap", packageName);
}
} else if(smallIcon == null) {
smallIconResId = res.getIdentifier("ic_notification", "mipmap", packageName);
smallIconResId = res.getIdentifier("ic_notification", "mipmap", packageName);
}

if (smallIconResId == 0) {
Expand All @@ -341,9 +344,12 @@ public void sendToNotificationCentreWithPicture(Bundle bundle, Bitmap largeIconB
String largeIcon = bundle.getString("largeIcon");

if (largeIcon != null && !largeIcon.isEmpty()) {
largeIconResId = res.getIdentifier(largeIcon, "mipmap", packageName);
largeIconResId = res.getIdentifier(largeIcon, "drawable", packageName);
if (largeIconResId == 0) {
largeIconResId = res.getIdentifier(largeIcon, "mipmap", packageName);
}
} else if(largeIcon == null) {
largeIconResId = res.getIdentifier("ic_launcher", "mipmap", packageName);
largeIconResId = res.getIdentifier("ic_launcher", "mipmap", packageName);
}

// Before Lolipop there was no large icon for notifications.
Expand Down