-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[Android] Headless task to set image on notification when in background is not being executed #3285
Comments
what's unfiltered logcat look like? You should see the headless task starting. I noticed in my implementation that it had to be registered before AppContainer was created and loaded |
Another issue led me here. I did sth like this 6 months ago using First, if your purpose is displaying large image without customize the UI, android notification has already supported that without any background service. Second, If you still need to use |
@luatnd thanks for pointing this out! I found the working solution eventually in here https://stackoverflow.com/a/58334833/1683304 which pointed me to the @mikehardy perhaps it makes sense to add this information to the documentation. Either way, you guys might update the documentation to reflect the registration of the headless task has to come before! the registration of the Main component. Currently it's the other way around. |
One of the downsides to maintenance is you lose track of the initial steps because you don't do them all the time, so people that have just gone through something are actually much more equipped to make these sorts of changes - for that reason there is an edit button at the top of every document page and making doc PRs on github is an incredibly quick process (they handle all the fork/branch/make-PR stuff in just a couple clicks all on the web) |
Thanks so much and apologies. I wasn't aware the community is allowed to edit them. Did it right away: invertase/react-native-firebase-docs#251 Thanks Mike! |
Issue
I am trying to display images in push notifications on Android when the app is in background. When running in foreground, I see the image in the notification but as soon as the app is in background or even not running, the headless task is not being executed. I can see the notification with text and title but since the headless task is not being executed, the image is not being downloaded and displayed.
I followed the documentation of rnfirebase-(Optional)(Android-only)-Listen-for-FCM-messages-in-the-background) and https://medium.com/@sumedh.tare/react-native-firebase-custom-notification-with-image-d9c2264c7fab
My goal is to see the image when the app is not in foreground too.
We added the following code:
index.android.js
after registering the Main component.
notifications/bgNotifications.js
MainApplication.java
Added this in the
onCreate()
functionUnfortunately the headless task is never executed and I never get into the JS part to debug further. That's why I think this may a bug. Any hints are very appreciated on how to fix this.
Project Files
Javascript
Click To Expand
package.json
:iOS
Click To Expand
ios/Podfile
:# N/A
AppDelegate.m
:// N/A
Android
Click To Expand
Have you converted to AndroidX?
android/gradle.settings
jetifier=true
for Android compatibility?jetifier
for react-native compatibility?android/build.gradle
:android/app/build.gradle
:// N/A
android/settings.gradle
:// N/A
MainApplication.java
:// N/A
AndroidManifest.xml
:Environment
Click To Expand
react-native info
output:react-native-firebase
version you're using that has this issue:e.g. 5.4.3
Firebase
module(s) you're using that has the issue:e.g. Instance ID
TypeScript
?Y/N
&VERSION
Think
react-native-firebase
is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]React Native Firebase
andInvertase
on Twitter for updates on the library.The text was updated successfully, but these errors were encountered: