-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Push Notification Icon not working on Android #24844
Comments
please check your applicationId and google-play-service.json have the same and device is register before push remote if you are using Expo Go is not possible please use prebuild |
@chanphiromsok If any of those weren't the case I wouldn't be receiving notifications at all, but I am. |
Ahh sorry I didn't read issue clearly. How about other android device ?
|
Yes I set up the app icon and the notification icon using the My team has done some testing on their phones, so far a notification icon is visible for all iPhones and some androids. BUT even when an icon is showing on android phones, the "app icon" image is being displayed in the notification rather than the Here are the results from the testing:
|
@jkstrawn we're running into the same situation as you are. were you able to make any further progress here? we've also tried configuring the icon via the [
'expo-notifications',
{
icon: './assets/android-icon-transparent.png',
color: '#FF0000',
},
], |
@jkstrawn did you manage to work this out? I'm also facing the same issue only on Pixel phones with Android 13 |
Yeah we're seeing this issue on Pixels, Motorola phones, Samsung phones and the Android Emulator. We've also confirmed that the PNG is being successfully copied into the APK when building with EAS. |
No sorry, I haven't had time to figure it out yet. My plan was to try editing the manifest file using a custom config plugin to change the notification icon settings manually. https://forums.expo.dev/t/how-to-edit-android-manifest-was-build/65663 https://github.com/expo/expo/tree/master/packages/expo-notifications#configure-for-android |
interesting - thanks for the details @jkstrawn. when I analyze our built APK I can see the following values from our app config seemingly successfully being applied to the <meta-data
android:name="expo.modules.notifications.default_notification_color"
android:resource="@ref/0x7f060135" />
<meta-data
android:name="expo.modules.notifications.default_notification_icon"
android:resource="@ref/0x7f080134" />
// ...
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@ref/0x7f060179" /> however I note there isn't a |
facing the same issue |
cc @cruzach @sjchmiela can see you've both done some work on android notification icons - wondering if either of you would have a hunch as to why this is occurring? 🙏 |
cc @jkstrawn To address this problem, you should convert your drawable to the appropriate format and size. Ensure that you have a 24dp version of the drawable available for different screen resolutions. This should help resolve the compatibility issues on devices like Pixel. to generate icon for your notifications. |
We're having the same issue and assumed that Expo would deal with all app icons automatically including notifications? We just supply a 1024x1024 PNG as the Happy to generate a custom icon just for Android notifications if anyone has specifics on what format is going to work across all Android versions/devices. |
@SidZadaun02 I used that tool when debugging the same issue on my project, and still saw the white circle as illustrated in this issue when using icons generated from it. @robcaldecott details are in the expo docs here. you can also observe how @jkstrawn has configured this in the reproducible example. |
@josh- i was facing the same issue. I tried png and svg both put didn't work. But after i make icon from android studio it work smoothly. Step to make notification Icon :
src="https://github.com/expo/expo/assets/119805008/964e8c3e-c420-4491-962b-252744e7b4c3" |
@SidZadaun02 just tried your approach and I still see an empty icon. I generated this icon from the Android Studio Resource manager (note that it's an all-white icon with transparency):
and then used this config in my expo app config: notification: {
icon: './assets/notification-icon.png',
color: '#faa200',
},
// ...
plugins: [
[
'expo-notifications',
{
icon: './assets/notification-icon.png',
color: '#faa200',
},
],
], and this is the result after sending a message via Firebase Cloud Messaging:
I've now tried many different permutations of icon files and none have worked so I'm fairly certain the issue is not related to the icon file itself, but must be another issue. |
@SidZadaun02 did you see the icon that I linked? it does have a transparent background. here is a screenshot of it being rendered in VS Code: ![]() |
Tried the icon tool linked above today and still get the generic circle icon. I'm out of ideas now. |
@SidZadaun02 that looks like native android code. this issue is specifically related to android notification icons when using expo and react native. |
OK, I have made this work (we use a custom development build via EAS build) and using the app.config.js
|
thanks for the datapoint @robcaldecott - I've just tried only setting the icon in the root |
just following up here - we were able to get this working in our app by using the new plugins: [
'@react-native-firebase/app',
+ '@react-native-firebase/messaging',
], this plugin reads the value from |
@robcaldecott could you share what version of I've tried using the |
|
@robcaldecott are you only relying on locally scheduled notifications? For us, it seems locally scheduled notifications show the icon but when we send them remotely via expo push notification tool it doesn't work. I'm curious if you're seeing the same. |
Thank you for filing this issue! |
@christopherwalter and @douglowder are working on this. sorry for the huge delay here, and thank you to everyone who managed to figure out great workarounds with config plugins for sharing those! |
Same issue here. Icon is white and data object is empty, addNotificationResponseReceivedListener, and getLastNotificationResponseAsync not working |
OMG THANK YOU! I have been beating my head against the keyboard on this one! |
I was so hopeful, but alas, this did not fix the issue. Icon still not showing :( |
I have been banging my head against the keyboard with this one. Is there any workaround? The one above doesn't work for me. Is there any estimate of a fix? I'm on Expo 51.0.1 and it still doesn't work. |
hey @krazykriskomar and others in this thread - @douglowder and @christopherwalter are currently investigating this. we're sorry that it took a long time to get to this. if the above fix isn't working for you, another option that is always available is to run |
Thank you guys, we faced the same issue.
My project is still using the legacy method and it doesn't make any difference. Expo adds
Yes, thank you for sharing your config plugin! With the addition of
|
Thanks @swey for confirming that the config plugin solution is working for you. We're going to put a fix together to properly use |
The plugin solution failing development build with error |
I'm testing a fix where I don't use a separate plugin, but instead patch the existing diff --git a/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/service/delegates/ExpoNotificationLifecycleListener.java b/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/service/delegates/ExpoNotificationLifecycleListener.java
index 3ae6481..a03e70d 100644
--- a/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/service/delegates/ExpoNotificationLifecycleListener.java
+++ b/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/service/delegates/ExpoNotificationLifecycleListener.java
@@ -11,6 +11,8 @@ import android.util.Log;
import androidx.core.app.NotificationCompat;
+import java.util.Objects;
+
import expo.modules.core.interfaces.ReactActivityLifecycleListener;
import expo.modules.notifications.notifications.NotificationManager;
import expo.modules.notifications.notifications.model.Notification;
@@ -70,7 +72,10 @@ public class ExpoNotificationLifecycleListener implements ReactActivityLifecycle
Log.d("ExpoNotificationLifecycleListener", method + " : keys count = " + extra.keySet().size());
for (String key : extra.keySet()) {
- Log.d("ExpoNotificationLifecycleListener", method + " : key = " + key + " = " + extra.get(key).toString());
+ Log.d(
+ "ExpoNotificationLifecycleListener",
+ method + " : key = " + key + " = " + Objects.requireNonNull(extra.get(key)).toString()
+ );
}
}
}
diff --git a/node_modules/expo-notifications/plugin/build/withNotificationsAndroid.js b/node_modules/expo-notifications/plugin/build/withNotificationsAndroid.js
index 9ca09dc..45bc261 100644
--- a/node_modules/expo-notifications/plugin/build/withNotificationsAndroid.js
+++ b/node_modules/expo-notifications/plugin/build/withNotificationsAndroid.js
@@ -17,8 +17,8 @@ exports.dpiValues = {
const { addMetaDataItemToMainApplication, getMainApplicationOrThrow, removeMetaDataItemFromMainApplication, } = config_plugins_1.AndroidConfig.Manifest;
const BASELINE_PIXEL_SIZE = 24;
const ERROR_MSG_PREFIX = 'An error occurred while configuring Android notifications. ';
-exports.META_DATA_NOTIFICATION_ICON = 'expo.modules.notifications.default_notification_icon';
-exports.META_DATA_NOTIFICATION_ICON_COLOR = 'expo.modules.notifications.default_notification_color';
+exports.META_DATA_NOTIFICATION_ICON = 'com.google.firebase.messaging.default_notification_icon';
+exports.META_DATA_NOTIFICATION_ICON_COLOR = 'com.google.firebase.messaging.default_notification_color';
exports.NOTIFICATION_ICON = 'notification_icon';
exports.NOTIFICATION_ICON_RESOURCE = `@drawable/${exports.NOTIFICATION_ICON}`;
exports.NOTIFICATION_ICON_COLOR = 'notification_icon_color';
diff --git a/node_modules/expo-notifications/plugin/src/withNotificationsAndroid.ts b/node_modules/expo-notifications/plugin/src/withNotificationsAndroid.ts
index 94d2bd0..581e165 100644
--- a/node_modules/expo-notifications/plugin/src/withNotificationsAndroid.ts
+++ b/node_modules/expo-notifications/plugin/src/withNotificationsAndroid.ts
@@ -32,9 +32,10 @@ const {
} = AndroidConfig.Manifest;
const BASELINE_PIXEL_SIZE = 24;
const ERROR_MSG_PREFIX = 'An error occurred while configuring Android notifications. ';
-export const META_DATA_NOTIFICATION_ICON = 'expo.modules.notifications.default_notification_icon';
+export const META_DATA_NOTIFICATION_ICON =
+ 'com.google.firebase.messaging.default_notification_icon';
export const META_DATA_NOTIFICATION_ICON_COLOR =
- 'expo.modules.notifications.default_notification_color';
+ 'com.google.firebase.messaging.default_notification_color';
export const NOTIFICATION_ICON = 'notification_icon';
export const NOTIFICATION_ICON_RESOURCE = `@drawable/${NOTIFICATION_ICON}`;
export const NOTIFICATION_ICON_COLOR = 'notification_icon_color'; |
# Why - Fixes #24844 - Corrects an NPE that can happen if a deep link in the app is opened # How - Change constants in the `expo-notifications` plugin to the correct ones expected for FCMv1 - Add the recommended code to guard against NPE when logging Android lifecycle events # Test Plan - CI should pass - Test app should show the correct icon and color in notification banners # Checklist <!-- Please check the appropriate items below if they apply to your diff. This is required for changes to Expo modules. --> - [ ] Documentation is up to date to reflect these changes (eg: https://docs.expo.dev and README.md). - [ ] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md) - [ ] This diff will work correctly for `npx expo prebuild` & EAS Build (eg: updated a module plugin).
- Fixes #24844 - Corrects an NPE that can happen if a deep link in the app is opened - Change constants in the `expo-notifications` plugin to the correct ones expected for FCMv1 - Add the recommended code to guard against NPE when logging Android lifecycle events - CI should pass - Test app should show the correct icon and color in notification banners <!-- Please check the appropriate items below if they apply to your diff. This is required for changes to Expo modules. --> - [ ] Documentation is up to date to reflect these changes (eg: https://docs.expo.dev and README.md). - [ ] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md) - [ ] This diff will work correctly for `npx expo prebuild` & EAS Build (eg: updated a module plugin).
- Fixes #24844 - Corrects an NPE that can happen if a deep link in the app is opened - Change constants in the `expo-notifications` plugin to the correct ones expected for FCMv1 - Add the recommended code to guard against NPE when logging Android lifecycle events - CI should pass - Test app should show the correct icon and color in notification banners <!-- Please check the appropriate items below if they apply to your diff. This is required for changes to Expo modules. --> - [ ] Documentation is up to date to reflect these changes (eg: https://docs.expo.dev and README.md). - [ ] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md) - [ ] This diff will work correctly for `npx expo prebuild` & EAS Build (eg: updated a module plugin).
expo ~51.0.14 none of above methods work |
For me the meta-data tag in a Manifest did the job:
|
So for expo.notifications.icon in app.config.js to work I have to install expo-notifications? If that's the case I think that should be noted in the docs? |
I have also not figured it out. "expo": "~51.0.17", |
i'm locking this because it is resolved in sdk 51 in the latest version of expo-notifications, using fcm v1. if you are still experiencing this on the latest version, please create a new issue with a minimal reproducible example. |
Minimal reproducible example
https://github.com/jkstrawn/notify-genie
Summary
The push notification icon for my expo app shows up as a white circle on my Pixel 7 Android 13 phone. I've made a test project "Notify Genie" for demonstrating the issue.
Here is what the notification icon file looks like:
I'm sending the push notification through the FCM "Notification" type message. I understand this doesn't make use of the expo-notifications library, but I'm still using the library for setting channels and granting permission.
I'm setting the app icon in the
app.config.ts
file like this:The request I'm sending to FCM looks like this:
I'm testing by creating a build, downloading the app onto my phone, and sending the push notification request through FCM.
I haven't seen anyone getting this particular icon issue, so I don't know if there's something funky about my particular app setup or what. The icon for the app itself works fine, it's only the notification icon that isn't working, and only on some of the phones that it's been tested on. I'm still working on compiling a list of working/not-working phones from my team, but at least for my particular phone the icon doesn't work.
Please let me know if there's any other information I should provide. Thank you
Environment
expo-env-info 1.0.5 environment info:
System:
OS: Windows 10 10.0.22621
Binaries:
Node: 18.0.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
npm: 8.6.0 - C:\Program Files\nodejs\npm.CMD
npmPackages:
@expo/webpack-config: ^19.0.0 => 19.0.0
expo: 49.0.8 => 49.0.8
react: 18.2.0 => 18.2.0
react-dom: 18.2.0 => 18.2.0
react-native: 0.72.5 => 0.72.5
react-native-web: ~0.19.0 => 0.19.9
Expo Workflow: managed
The text was updated successfully, but these errors were encountered: