Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(expo): enhances notification config retrieval #8663

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

Open
huextrat wants to merge 3 commits into invertase:main
base: main
Choose a base branch
Loading
from huextrat:feat/expo-notifications
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(expo): enhances notification config retrieval
Improves notification configuration by first checking
`expo-notifications` plugin for icon and color.
Falls back to deprecated `config.notification` settings.
Warns about missing notification icon for Android.
  • Loading branch information
huextrat committed Sep 23, 2025
commit c6a741821e4b761e70e6fcaa2e27af9c633f82dc
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,51 @@ export const withExpoPluginFirebaseNotification: ConfigPlugin = config => {
});
};

// Helper function to get notification icon and color from either config.notification or expo-notifications plugin
const getNotificationConfig = (config: ExpoConfig) => {
// Check expo-notifications plugin
if (config.plugins) {
const expoNotificationsPlugin = config.plugins.find(plugin =>
Array.isArray(plugin) && plugin[0] === 'expo-notifications'
);

if (expoNotificationsPlugin && Array.isArray(expoNotificationsPlugin)) {
const pluginConfig = expoNotificationsPlugin[1];
if (pluginConfig && typeof pluginConfig === 'object') {
return {
icon: pluginConfig.icon,
color: pluginConfig.color,
};
}
}
}

/**
* @deprecated
* Get notification config from config.notification
* Will be removed in the future as `expo-notifications` plugin is the recommended way to configure notifications.
*/
if (config.notification) {
return {
icon: config.notification.icon,
color: config.notification.color,
};
}

return { icon: undefined, color: undefined };
};

export function setFireBaseMessagingAndroidManifest(
config: ExpoConfig,
application: ManifestApplication,
) {
// If the notification object is not defined, print a friendly warning
if (!config.notification) {
const { icon, color } = getNotificationConfig(config);
if (!icon) {
// This warning is important because the notification icon can only use pure white on Android. By default, the system uses the app icon as the notification icon, but the app icon is usually not pure white, so you need to set the notification icon
// eslint-disable-next-line no-console
console.warn(
'For Android 8.0 and above, it is necessary to set the notification icon to ensure correct display. Otherwise, the notification will not show the correct icon. For more information, visit https://docs.expo.dev/versions/latest/config/app/#notification',
);
return config;
}

// Defensive code
Expand All @@ -46,7 +79,7 @@ export function setFireBaseMessagingAndroidManifest(
const metaData = application['meta-data'];

if (
config.notification.icon &&
icon &&
!hasMetaData(application, 'com.google.firebase.messaging.default_notification_icon')
) {
// Expo will automatically create '@drawable/notification_icon' resource if you specify config.notification.icon.
Expand All @@ -59,7 +92,7 @@ export function setFireBaseMessagingAndroidManifest(
}

if (
config.notification.color &&
color &&
!hasMetaData(application, 'com.google.firebase.messaging.default_notification_color')
) {
metaData.push({
Expand Down

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /