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.

Android 10 & 11 local notifications doesn't show

See original GitHub issue

On emulators and physical devices with Android10+ the local notifications triggered with PushNotification.localNotification() don’t show on the top of the screen, just go to the system tray. I also checked on emulator with Android 8 and it works fine. Any ideas? 😃


package.json

“react-native”: “^0.63.4”, “react-native-push-notification”: “^7.2.2”,

AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <permission android:name="${applicationId}.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> <uses-permission android:name="android.permission.WAKE_LOCK" /><meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name" android:value="YOUR NOTIFICATION CHANNEL NAME"/> <meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_description" android:value="YOUR NOTIFICATION CHANNEL DESCRIPTION"/> <meta-data android:name="com.dieam.reactnativepushnotification.notification_color" android:resource="@android:color/white"/> <!-- < Only if you're using GCM or localNotificationSchedule() > --> <receiver android:name="com.google.android.gms.gcm.GcmReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="${applicationId}" /> </intent-filter> </receiver> <!-- < Only if you're using GCM or localNotificationSchedule() > --> <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" /> <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/> <!-- < Only if you're using GCM or localNotificationSchedule() > --> <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerServiceGcm" android:exported="false" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> </intent-filter> </service> <!-- </ Only if you're using GCM or localNotificationSchedule() > --> <meta-data android:name="com.dieam.reactnativepushnotification.notification_foreground" android:value="true" /> <meta-data android:name="com.dieam.reactnativepushnotification.channel_create_default" android:value="true" /> <meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="push-notifications-channel" /> <receiver android:name="com.google.android.gms.gcm.GcmReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="............" /> </intent-filter> </receiver> <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService" /> <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerServiceGcm" android:exported="false" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> </intent-filter> </service> <service android:name=".java.MyFirebaseMessagingService" android:exported="false"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service>

settings.gradle

… include ‘:react-native-push-notification’ project(‘:react-native-push-notification’).projectDir = file(‘…/node_modules/react-native-push-notification/android’) include ‘:app’

Configuration

import PushNotification from ‘react-native-push-notification’; import {registerToPushNotifications} from ‘…’;

export const configureNotifications = () => { PushNotification.configure({ onNotification: notification => { console.log(‘onNotification:’, notification); }, onAction: notification => { console.log(‘onAction:’, notification); }, permissions: { alert: true, badge: true, sound: true, }, senderID: ‘bla-bla-bla’, popInitialNotification: true, requestPermissions: true, });

PushNotification.createChannel({ channelId: ‘push-notifications-channel’, channelName: ‘Push notifications channel’, channelDescription: ‘Push notifications channel’, playSound: true, soundName: ‘default’, importance: 4, vibrate: true, }); };

Trigger

const triggerNotification = () => { PushNotification.localNotification({ channelId: ‘push-notifications-channel’, channelName: ‘Push notifications channel’, foreground: true, ignoreInForeground: false, invokeApp: true, visibility: ‘private’, priority: ‘high’, vibrate: true, vibration: 500, playSound: true, soundName: ‘default’, autoCancel: true, title: ‘Title’, message: ‘Message’, bigText: ‘Big text’, subText: ‘Sub text’, }); };

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
tgrecocommented, Apr 19, 2021

I am very confused on the channel usage too. Can someone provide more information on mocanSergiu666’s question?

1reaction
Dallas62commented, Mar 18, 2021

Hi @mocanSergiu666 Please refer to the Channel Management, in the README. https://github.com/zo0r/react-native-push-notification#channel-management-android NOTE: Without channel, notifications don’t work Regards

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android Notifications Not Showing Up? 10 Fixes You Can Try
Not seeing notifications show up on your Android phone? Try these fixes to get Android notifications working again.
Read more >
How to Fix 'Android 11 Notifications Not Working' Issue in 2022
Whether Android notifications are lagging or not showing at all, here are the top 10 fixes to fix missing notifications on Android, so...
Read more >
Top 6 Ways to Fix Android 11 Notifications Not Working
Top 6 Ways to Fix Android 11 Notifications Not Working · 1. Clear App Cache · 2. Update App · 3. Check Notification...
Read more >
Local notification occurs but doesn't appear on the screen
I tried but it didn't work. Afterwards, I noticed that when a certain notification accumulates at the top, the notifications begin to not...
Read more >
How to fix Android notifications not working - Carlcare Service
Open your phone Settings app. Click Apps & notifications. Now select 'Special app Access'; Tap 'Notification Access' from the list. It will show ......
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