mirror of
https://github.com/zhigang1992/react-native-notifications.git
synced 2026-04-29 04:45:02 +08:00
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:
committed by
Yogev Ben David
parent
f421c5127e
commit
a1510bae1b
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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" />
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user