question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why LargeIcon not display on android in background and closed app state?

See original GitHub issue

I am not getting large icon if receiving notification in background or closed app state.

screenshot-2021 05 13-14_08_56

Here Top notification I am getting when app in foreground and second one when app is background. Please suggest how to show large icon in background and closed app state too.

This is a configuration I have inside project::

PushNotification.configure({
			// (required) Called when a remote or local notification is opened or received
			onNotification: this.clickOnOpenAppNotification,
			// IOS ONLY (optional): default: all - Permissions to register.
			permissions: { alert: true, badge: true, sound: true },
			// Should the initial notification be popped automatically
  			// default: true
			popInitialNotification: true,
			/**
			* (optional) default: true
			* - Specified if permissions (ios) and token (android and ios) will requested or not,
			* - if not, you must call PushNotificationsHandler.requestPermissions() later
			* - if you are not using remote notification or do not have Firebase installed, use this:
			*     requestPermissions: Platform.OS === 'ios'
			*/
			requestPermissions: true,
			largeIcon: 'ic_launcher',
			smallIcon: '@mipmap/notification_state',
		});

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

1reaction
ArchanaSharma95commented, May 13, 2021

@Dallas62 I have checked my manifest file everything is set correctly. Also icons are added inside res folder.

 <meta-data  android:name="com.dieam.reactnativepushnotification.notification_foreground" android:value="false"/>
		 <!-- Change the resource name to your App's accent color - or any other color you want -->
		 <meta-data  android:name="com.dieam.reactnativepushnotification.notification_color" android:resource="@color/white"/>
		 <meta-data  android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@mipmap/notification_state" />

And now inside onMessage handler I am setting local notification like this. When I am getting remote notification then this returns a notification value and here I have added localNotification config like this:

this.notificationListener = messaging().onMessage(notification => {
	console.log("onMessage", notification)
	if (notification) {
		if (isIOS) {
			PushNotification.localNotification({
				title: notification && notification.notification && notification.notification.title || '',
				message: notification && notification.notification && notification.notification.body || '',
				userInfo: notification.data,
			});
		}
		else {
			PushNotification.localNotification({
				channelId: "my-channel",
				title: notification && notification.notification && notification.notification.title || '',
				message: notification && notification.notification && notification.notification.body || '',
				userInfo: notification.data,
				showWhen: true,
				// when: null,
				playSound: true,
				soundName: 'default',
				largeIcon: "@mipmap/ic_launcher",
				smallIcon: "@mipmap/notification_state",
			});
		}
	}
});

I am still not able to show large icon in background and closed app state. Please help I have already invested a day to add this icon.

0reactions
Awesomer9561commented, Sep 1, 2022

Hi @ArchanaSharma95 did you find a work around for this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - Not getting Large Icon when app is not in background
It's because you've to set the large icon first and small icon second to that, also you shouldn' ...
Read more >
Notifications Overview | Android Developers
A notification is a message that Android displays outside your app's UI to provide the user with reminders, communication from other people, or...
Read more >
Firebase Notifications in Background & Foreground in Android
When the app is closed, your notifications are processed by the Google Service process, which take care of displaying your notifications as ...
Read more >
Android notifications - Material Design
Foreground services are app processes that run in the background while the user is ... By default, a timestamp does not appear, but...
Read more >
How to implement Flutter local notifications to boost user ...
Running your application should display the initial state of your app. ... on a notification when the app is no longer in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found