App is not receiving any remote notifications when app is in foreground state. Background remote notifications are working correctly.
I've also set this to true in manifest file:
<!-- Change the value to true to enable pop-up for in foreground (remote-only, for local use ignoreInForeground) -->
<meta-data android:name="com.dieam.reactnativepushnotification.notification_foreground"
android:value="true"/>
react-native info output:
System:
OS: Windows 10 10.0.18363
CPU: (4) x64 Intel(R) Core(TM) i5-3570 CPU @ 3.40GHz
Memory: 1.22 GB / 7.88 GB
Binaries:
Node: 12.9.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.10.2 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels: 28, 29
Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.0
System Images: android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: Not Found
Languages:
Java: 1.8.0_221 - C:\Program Files\Java\jdk1.8.0_221\bin\javac.EXE
Python: 2.7.16 - C:\Python27\python.EXE
npmPackages:
@react-native-community/cli: Not Found
react: 16.11.0 => 16.11.0
react-native: 0.62.2 => 0.62.2
npmGlobalPackages:
*react-native*: Not Found
Library version: 3.5.2
Describe what you expected to happen:
Ps. I'm using the example app for now, so the configs are same
Hi @iarmankhan
I just test this, and this is working well, maybe a cache problem with gradle ?
I am observing exactly the same issue but with Android emulator.
My steps:
onNotification is not triggered while the app is in foreground.Hello @Dallas62
Well if it was a cache issue it should be solved by now, because after posting this issue here I built app multiple times and tested but it's still same.
I also tried it with released app (made using --variant=release) and it's same in that too.
EDIT : I'm talking about remote notifications (sent from firebase or server) for local notification it's working correctly (I did not use local notification in my app but it was working on example app)
Hi @iarmankhan @apalchys
I would be pleased to help you, but I did the exact same test as @apalchys, and all is working as expected...
If appstate == foreground && com.dieam.reactnativepushnotification.notification_foreground == true
onNotification is triggered.If appstate == foreground && com.dieam.reactnativepushnotification.notification_foreground == false
onNotification is triggered.Maybe I don't understand the issue, do you have more information like the content of the payload or the full step to reproduce with example project ?
I do all tests for issues on example project.
I have the exact same issue, here is my manifest
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission tools:node="remove" android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application>
<activity
android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:fitsSystemWindows="true"
android:label="@string/app_name"
android:windowSoftInputMode="adjustPan"
android:screenOrientation="portrait">
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<meta-data android:name="com.dieam.reactnativepushnotification.notification_foreground"
android:value="true"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name"
android:value="Example-Channel"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_description"
android:value="Super channel description"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_color"
android:resource="@android:color/white"/>
</application>
Hi @theasc
"Having the same issue" is not helping to resolve this.
Can you provide a reproducible example ? Or a complete description on what is working and what is not working.
As I said previously, I tried to reproduce this and all work as expected.
Hi @Dallas62, It works now I was just missing the following part:
<service
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
Hello @theasc
Thank you for pointing that out, somehow I missed that. Sorry @Dallas62 for taking your time on this.
Thanks for your great work!
Most helpful comment
Hello @theasc
Thank you for pointing that out, somehow I missed that. Sorry @Dallas62 for taking your time on this.
Thanks for your great work!