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

Commit 469c167

Browse files
author
Boris Tacyniak
authored
Merge pull request #1787 from hojason117/androidDrawableIcon
Support using drawable as Android small icon
2 parents 2e5fa1c + 3e87b12 commit 469c167

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ In your `android/app/src/main/AndroidManifest.xml`
8989
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
9090

9191
<application ....>
92-
<!-- Change the value to true to enable pop-up for in foreground (remote-only, for local use ignoreInForeground) -->
92+
<!-- 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) -->
9393
<meta-data android:name="com.dieam.reactnativepushnotification.notification_foreground"
9494
android:value="false"/>
9595
<!-- Change the resource name to your App's accent color - or any other color you want -->
@@ -324,7 +324,7 @@ PushNotification.localNotification({
324324
ongoing: false, // (optional) set whether this is an "ongoing" notification
325325
priority: "high", // (optional) set notification priority, default: high
326326
visibility: "private", // (optional) set notification visibility, default: private
327-
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)
327+
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
328328
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
329329
onlyAlertOnce: false, // (optional) alert will open only once with sound and notify, default: false
330330

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

+10-4
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,12 @@ public void sendToNotificationCentreWithPicture(Bundle bundle, Bitmap largeIconB
325325
String smallIcon = bundle.getString("smallIcon");
326326

327327
if (smallIcon != null && !smallIcon.isEmpty()) {
328-
smallIconResId = res.getIdentifier(smallIcon, "mipmap", packageName);
328+
smallIconResId = res.getIdentifier(smallIcon, "drawable", packageName);
329+
if (smallIconResId == 0) {
330+
smallIconResId = res.getIdentifier(smallIcon, "mipmap", packageName);
331+
}
329332
} else if(smallIcon == null) {
330-
smallIconResId = res.getIdentifier("ic_notification", "mipmap", packageName);
333+
smallIconResId = res.getIdentifier("ic_notification", "mipmap", packageName);
331334
}
332335

333336
if (smallIconResId == 0) {
@@ -347,9 +350,12 @@ public void sendToNotificationCentreWithPicture(Bundle bundle, Bitmap largeIconB
347350
String largeIcon = bundle.getString("largeIcon");
348351

349352
if (largeIcon != null && !largeIcon.isEmpty()) {
350-
largeIconResId = res.getIdentifier(largeIcon, "mipmap", packageName);
353+
largeIconResId = res.getIdentifier(largeIcon, "drawable", packageName);
354+
if (largeIconResId == 0) {
355+
largeIconResId = res.getIdentifier(largeIcon, "mipmap", packageName);
356+
}
351357
} else if(largeIcon == null) {
352-
largeIconResId = res.getIdentifier("ic_launcher", "mipmap", packageName);
358+
largeIconResId = res.getIdentifier("ic_launcher", "mipmap", packageName);
353359
}
354360

355361
// Before Lolipop there was no large icon for notifications.

0 commit comments

Comments
 (0)