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

Commit e914173

Browse files
authored
Merge pull request #1511 from Adapptor/icon-empty-strings
Support empty strings as default push notification icons
2 parents faf2440 + ec05c04 commit e914173

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,9 @@ PushNotification.localNotification({
303303
ticker: "My Notification Ticker", // (optional)
304304
showWhen: true, // (optional) default: true
305305
autoCancel: true, // (optional) default: true
306-
largeIcon: "ic_launcher", // (optional) default: "ic_launcher"
306+
largeIcon: "ic_launcher", // (optional) default: "ic_launcher". Use "" for no large icon.
307307
largeIconUrl: "https://www.example.tld/picture.jpg", // (optional) default: undefined
308-
smallIcon: "ic_notification", // (optional) default: "ic_notification" with fallback for "ic_launcher"
308+
smallIcon: "ic_notification", // (optional) default: "ic_notification" with fallback for "ic_launcher". Use "" for default small icon.
309309
bigText: "My big text that will be shown when notification is expanded", // (optional) default: "message" prop
310310
subText: "This is a subText", // (optional) default: none
311311
bigPictureUrl: "https://www.example.tld/picture.jpg", // (optional) default: undefined

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,13 @@ public void sendToNotificationCentreWithPicture(Bundle bundle, Bitmap largeIconB
348348
}
349349

350350
// Small icon
351-
int smallIconResId;
351+
int smallIconResId = 0;
352352

353353
String smallIcon = bundle.getString("smallIcon");
354354

355355
if (smallIcon != null) {
356356
smallIconResId = res.getIdentifier(smallIcon, "mipmap", packageName);
357-
} else {
357+
} else if (!smallIcon.isEmpty()) {
358358
smallIconResId = res.getIdentifier("ic_notification", "mipmap", packageName);
359359
}
360360

@@ -370,13 +370,13 @@ public void sendToNotificationCentreWithPicture(Bundle bundle, Bitmap largeIconB
370370

371371
// Large icon
372372
if(largeIconBitmap == null) {
373-
int largeIconResId;
373+
int largeIconResId = 0;
374374

375375
String largeIcon = bundle.getString("largeIcon");
376376

377377
if (largeIcon != null) {
378378
largeIconResId = res.getIdentifier(largeIcon, "mipmap", packageName);
379-
} else {
379+
} else if (!largeIcon.isEmpty()) {
380380
largeIconResId = res.getIdentifier("ic_launcher", "mipmap", packageName);
381381
}
382382

0 commit comments

Comments
 (0)