Fixing white square icon and annotation error (#379)

* 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

* 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

* Updating documentation for the Icon

* Fixing image name and updating documentation

* Update installation.md

Forgot one more place to update the file name
This commit is contained in:
Carlos Alcazar
2019-09-22 05:57:23 -04:00
committed by Yogev Ben David
parent f421c5127e
commit a1510bae1b
3 changed files with 19 additions and 3 deletions

View File

@@ -151,11 +151,18 @@ public class PushNotification implements IPushNotification {
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("notification_icon", "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,

View File

@@ -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 {

View File

@@ -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.
**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 notification_icon.png and add it to your drawable folders. Once that is done add the following line to your AndroidManifest.xml
```diff
+<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable notification_icon" />
```