react-native-foreground-service icon indicating copy to clipboard operation
react-native-foreground-service copied to clipboard

Notification is not displaying the correct title, text and icon

Open beige229 opened this issue 5 years ago • 6 comments

I am using the code from your example application, but the notification is not showing anything from notificationConfig. The title is testApp is running, message is Tap for more information or to stop the app and there is no icon at all.

Code snippet:

	startForegroundService = async () => {
		if (Platform.OS !== 'android') {
			console.log("Foreground service is available only on Android!");
			return;
		}

		if (Platform.Version >= 26) {
			const channelConfig = {
				id: 'ForegroundServiceChannel',
				name: 'Notification Channel',
				description: 'Notification Channel for Foreground Service',
				enableVibration: true,
				importance: 2
			};

			try {
				await VIForegroundService.createNotificationChannel(channelConfig);
			} catch (e) {
				console.log('HomePage', e);
			}
		}

		const notificationConfig = {
			channelId: 'ForegroundServiceChannel',
			id: 3456,
			title: 'MyTestApplication',
			text: 'Notification test text',
			icon: 'ic_notification',
			priority: 1
		};

		if (Platform.Version >= 26) {
			notificationConfig.channelId = 'ForegroundServiceChannel';
		}

		await VIForegroundService.startService(notificationConfig);
	}

beige229 avatar Jun 05 '19 16:06 beige229

Add an icon with name ic_notification in resource of android.

ipa127001 avatar Jun 13 '19 11:06 ipa127001

Thanks @ipa127001! To provide a bit more detail, I added my icon as an ic_notification.png file to the following directories which fixed all of the issues mentioned in this ticket:

/android/app/src/main/res/mipmap-hdpi /android/app/src/main/res/mipmap-mdpi /android/app/src/main/res/mipmap-xhdpi /android/app/src/main/res/mipmap-xxhdpi /android/app/src/main/res/mipmap-xxxhdpi

dkoo761 avatar Jul 17 '19 02:07 dkoo761

did you fix the problem by adding a image file i also same issue please help

cristoferraobluestream avatar Jun 12 '20 10:06 cristoferraobluestream

Yes, the ic_notification.png file should be a PNG image file.

dkoo761 avatar Jun 12 '20 22:06 dkoo761

What about title and text? Can it be changed?

Rendfold avatar Nov 09 '20 09:11 Rendfold

Oh sorry, I answered my own question. It's seems that without icon text and intent doesn't change. Seems a little bit crazy, but it works. Sorry once more.

Rendfold avatar Nov 09 '20 12:11 Rendfold