From f01332cc444ed7723b9f2933fe8f8831a02126c7 Mon Sep 17 00:00:00 2001 From: Carlos Alcazar Date: Thu, 19 Sep 2019 15:32:20 -0400 Subject: [PATCH 1/5] Fixing issue with notification showing as a white square for application icons that do not follow the notification icon Standard. Should be a non breaking change as the fall back should pull the application icon if it's not defined --- .../core/notification/PushNotification.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java b/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java index 5e4e3d2ba..1c3aab7a1 100644 --- a/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java +++ b/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java @@ -151,11 +151,18 @@ protected Notification.Builder getNotificationBuilder(PendingIntent intent) { final Notification.Builder notification = new Notification.Builder(mContext) .setContentTitle(mNotificationProps.getTitle()) .setContentText(mNotificationProps.getBody()) - .setSmallIcon(mContext.getApplicationInfo().icon) .setContentIntent(intent) .setDefaults(Notification.DEFAULT_ALL) .setAutoCancel(true); + + int resourceID = mContext.getResources().getIdentifier("notificationIcon", "drawable", mContext.getPackageName()); + if (resourceID != 0) { + notification.setSmallIcon(resourceID); + } else { + notification.setSmallIcon(mContext.getApplicationInfo().icon); + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, From d5631a8fa0681e51d68de8489c2cbd599dcb5d29 Mon Sep 17 00:00:00 2001 From: Carlos Alcazar Date: Thu, 19 Sep 2019 15:33:23 -0400 Subject: [PATCH 2/5] Not sure how long this error has been here but we are importing the wrong thing. We should be importing NonNull as importing Nullable causes a build error. The RN 60 flavor of the file is importing the NonNull --- .../NotificationManagerCompatFacade.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java b/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java index f527a5d5a..f9c858b06 100644 --- a/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java +++ b/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java @@ -2,7 +2,7 @@ package com.wix.reactnativenotifications; import android.content.Context; -import android.support.annotation.Nullable; +import android.support.annotation.NonNull; import android.support.v4.app.NotificationManagerCompat; public abstract class NotificationManagerCompatFacade { From 28415c809c713a3c81e632f1e23c256e9ff04236 Mon Sep 17 00:00:00 2001 From: Carlos Alcazar Date: Thu, 19 Sep 2019 15:34:05 -0400 Subject: [PATCH 3/5] Updating documentation for the Icon --- docs/installation.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/installation.md b/docs/installation.md index 56f1aba29..b1bb74750 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -183,4 +183,13 @@ To do so edit `android/build.gradle` and add: +} ``` -**Note**: As more build variants come available in the future, you will need to adjust the list (`names.contains("reactNative59")`). This is why we recommend the first solution. \ No newline at end of file +**Note**: As more build variants come available in the future, you will need to adjust the list (`names.contains("reactNative59")`). This is why we recommend the first solution. + +#### Step #6: Set your notification Icon. + +By default, the package will use your native application icon. If your icon is not notification friendly, you may have to set and use a different icon. To do this, create a notificationIcon.png and add it to your drawable folders. Once that is done add the following line to your AndroidManifest.xml + +```diff ++ +``` + From cfc7c5167b41612700bb3bfed9162d6b5f630424 Mon Sep 17 00:00:00 2001 From: Carlos Alcazar Date: Thu, 19 Sep 2019 16:13:24 -0400 Subject: [PATCH 4/5] Fixing image name and updating documentation --- .../core/notification/PushNotification.java | 2 +- docs/installation.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java b/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java index 1c3aab7a1..524ff0772 100644 --- a/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java +++ b/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java @@ -156,7 +156,7 @@ protected Notification.Builder getNotificationBuilder(PendingIntent intent) { .setAutoCancel(true); - int resourceID = mContext.getResources().getIdentifier("notificationIcon", "drawable", mContext.getPackageName()); + int resourceID = mContext.getResources().getIdentifier("notification_icon", "drawable", mContext.getPackageName()); if (resourceID != 0) { notification.setSmallIcon(resourceID); } else { diff --git a/docs/installation.md b/docs/installation.md index b1bb74750..da1de6eb2 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -190,6 +190,6 @@ To do so edit `android/build.gradle` and add: By default, the package will use your native application icon. If your icon is not notification friendly, you may have to set and use a different icon. To do this, create a notificationIcon.png and add it to your drawable folders. Once that is done add the following line to your AndroidManifest.xml ```diff -+ ++ ``` From 5adb484857cae6386e9d87bbb1caae3bc3d05e18 Mon Sep 17 00:00:00 2001 From: Carlos Alcazar Date: Thu, 19 Sep 2019 16:41:27 -0400 Subject: [PATCH 5/5] Update installation.md Forgot one more place to update the file name --- docs/installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/installation.md b/docs/installation.md index da1de6eb2..968ac9788 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -187,7 +187,7 @@ To do so edit `android/build.gradle` and add: #### Step #6: Set your notification Icon. -By default, the package will use your native application icon. If your icon is not notification friendly, you may have to set and use a different icon. To do this, create a notificationIcon.png and add it to your drawable folders. Once that is done add the following line to your AndroidManifest.xml +By default, the package will use your native application icon. If your icon is not notification friendly, you may have to set and use a different icon. To do this, create a notification_icon.png and add it to your drawable folders. Once that is done add the following line to your AndroidManifest.xml ```diff +