wix / react-native-notifications

React Native Notifications
MIT License
3.25k stars 764 forks source link

Notification from background does not have an icon #859

Closed codeheart09 closed 2 years ago

codeheart09 commented 2 years ago

I have version 4.2.4 installed in Android 11.

I properly configured the notification icon as described in the docs.

When I trigger a local notification with the app in the foreground (only way to trigger it, see this issue), the icon is displayed correctly in the notification.

Notifications.events().registerNotificationReceivedForeground(
  (notification) => {
    Notifications.postLocalNotification({
      body: notification.payload['gcm.notification.body'],
      title: notification.payload['gcm.notification.title'],
      silent: false,
      fireDate: new Date(),
    });
  },
);

But when I trigger a notification from the background (with completion or force a local notification, same result) the icon is displayed as a solid square.

Notifications.events().registerNotificationReceivedBackground(
  (notification, completion) => {
    console.log('Notification received in background', notification.payload);

    // Calling completion on iOS with `alert: true` will present the native iOS inApp notification.
    completion({ alert: true, sound: true, badge: true });
  },
);

Also, in both cases (foreground & background), the notification popup does not show up.

DanielEliraz commented 2 years ago

About the notification popup, check the app notification settings in the OS. About the icon, did you follow this guide: https://wix.github.io/react-native-notifications/docs/installation-android/#step-6-customize-the-appearance?

codeheart09 commented 2 years ago

Hi Daniel, thanks for your reply.

Yes, as I stated in the first message, I did follow the documentation. Our links seem to point to the same place.

It seems the foreground local notification gets the configured icon correctly, while the background notification gets the app icon, which is a solid square (no transparent pixels).

Upon further tests I found that the meta-data tags in AndroidManifest.xml must be under application in order to the background notification display the icon properly (I had placed them under manifest tag). What misled me about that is that the foreground local notification was displaying the icon properly while only the background one wasn't.

Maybe this could be clearer in the documentation?

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] commented 2 years ago

The issue has been closed for inactivity.