-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
FCM when app in background #20
Comments
Hi hablema, thanks for giving FCM a try. You mentioned a couple of things:
So if I understand your issues, there are a couple of things to note:
|
Hi @kroikie I have a follow up question. |
Hi @kroikie I am looking for the same solution as mentioned by @wassupnari. Can we achieve that or it is not possible with FCM. As using FCM on iOS we have background mode do Android also have same background mode using FCM or not. |
@avirepo @wassupnari these customizations are possible through FCM but not yet through the console UI, you have to use the HTTP API. You can see more discussion on #4, I am going to close this issue as we are tracking this feature request elsewhere. We know this is important to everyone so the team is working hard on it. |
@kroikie : Thanks for info. I got it working as you have mentioned from the intent of the activity. The documentation should have been more clear in that aspect with a full sample manifest. Its good now, also i had a problem in which the FCM messages from console only started delivering after i tried from the HTTP API. Don't know why but after that its working directly from the console. Thanks again. |
Hi Team, Works just fine except this issue. when the app is in background , and during cold launch from notification, the app is getting opened but how to access the notification data, and do some activities with that. Unlike the PushNotificationIOS's popInitialNotification, I dont think we have any function that will get the data. Can someone help me if you have made it work. @hablema |
Hi @rimzici, on Android when your application is in the background and a notification message is sent the accompanying data payload (if included) is available via the launched intent resulting from the developer tapping on the notification. By default that would be your MainActivity, you can find an example of this in the messaging sample in this repo. For more on handling data accompanying a notification message see the docs. |
@kroikie , |
So does it mean that data-message only are not received anymore when the application is in background?? The doc is really fuzzy on it. If yes, that's a very new behavior and it's what I'm facing in my application for few days because I built and published an application on 07/08/16 (FCM 9.2.0) which perfectly receives data-message sent by API while it's in background, on a Samsung GT-9295 5.0.1 and on a Nexus 7 6.0.1 and it's what I do for a long time in GCM then in FCM. But starting from the working project built one week ago, I realize that now I rebuild it, the generated app is no more able to receive anything in background. I tried to upgrade to FCM 9.2.1, same. So there is something new in my environment, sdk, studio, java, I don't know, which causes this very important feature to not work anymore. Why? |
After a deep search, I have found what is going on: There are two types of messages in FCM:
Firebase team have not developed a UI to send data-messages to your devices. To achieve this, you have to do a And the following headers:
Body:
To get your server key, you can find it in the firebase console: Your project -> settings -> Project settings -> Cloud messaging -> Server Key Hope this helps! Ref: How to handle notification when app in background in firebase |
@pratikbutani That's sure, but according to lot of tests I did, applications built with Studio 2.1.2 can't work. |
Anybody please let me know is it not possible to show custom notification instead of default when app is in background or is not running while using FCM. |
@anujjpandey11 Yes it's possible by sending a data message which will be received by |
I already tried it but it is only work when app is in foreground. Note: I'm sending message from firebase console. |
AFAIK, firebase console is not able to send data only messages, unles it has been updated very recently. To do that, I use Google Advanced REST Client And configure it like here |
Thanks @2ndGAB |
Hi Team, and in my mainfest file, i have with the same manifest I tried DATA ONLY push like { that time notification not even received in the tray. gets data when app in open. So I assume without "notification" key device wont receive push in tray. So after all I come to conclusion that only way is what you have said already to handle it somehow like if (getIntent().getExtras() != null) { someone help me how to pass this data from MainApplication.java to our javascript file. |
Hi. |
@rimzici I don't think that, messages from the Firebase console (notification messages) are supported by React Native. I would suggest that you use data messages (sent from the REST API) and generate your own notifications. |
Hi, it all works perfectly. |
If I send User segment push notification All user don't get push notification Why all did not get? From console.firebase.google.com I found monthly active user 4100 but when i send notification It shows 2100 send. That mean 50% user found. then what would be be others. |
With SDK 9.8.0 however, you can override the default! In your AndroidManifest.xml you can set the following fields to customise the icon and color: |
FCM background notifications works on all the android versions except Android 7.. When the app is in the background I get the notification and once I tap the notification I can open the activity and read the intents, is there something that I'm missing for Android 7? |
Ya esta solucionado el poder darle manejo a los mensajes que llegan mientras la aplicación esta totalmente cerrada ? |
Hi All The issue still remains - if sent push with notification and data when app on bakground - notification arrives but no extras on launching activity. In all other scenarios when app killed /open data arrives to extras of activity/onMessageReceived. Please help Example of postman body: { |
I don't know about notification + data, I use data message only and I create the notification by myself in onMessageReceive. That now works from AS 2.2.2 and also 2.2.3. EDIT |
Thank you notification/ data only also works. I need to take care of this exact scenario: notification with data & app on background |
My issue was when activity arrive to onStart - he still have old intent. So I override onNewIntent func and set the new Intent to be the one of activity. In such case onStart it rceives Intent with data from push |
Same problem on my side. Here is my code chip for that.
It works well when app is in foreground, but just open the app(Launcher activity) when app is in background. |
@SelfnessAid in case you want to start the app by tapping the notification, this code is not concerned. Here is the code you need: In your
Then I'm not sure about your flag
After, you have to add code in your Add somewhere in
Then also add the following method. (@aaalive yes, that point is the key!):
And so you
I hope it will help you. |
Hi, @2ndGAB |
Hi @SelfnessAid |
Thanks, @Siddharth-Dev |
Hey guys, Is FCM what i need to fetch data in background from FirebaseDataBase? |
@samkerm yes you can use FCM to fetch data from the Firebase Realtime Database. Note that if you open a listener in the background and leave it open it may affect battery life. |
I can receive notification even if app is killed but when app is killed i sent 3 message from server i could receive only one message(which sent lastly) when i tap the notification and move into app |
Don't worry. i'm fine
나의 SOL에서 보냄
2017. 2. 23. 오후 2:08에 christianraj <[email protected]>님이 작성:I can receive notification even if app is killed but when app is killed i sent 3 message from server i could receive only one message(which sent lastly) when i tap the notification and move into app
Any help to get all message which i sent to be received when i get back to my app
—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or mute the thread.
|
When app is in killed notification is not visible neither is data. it's been whole day I am trying to get a notification when app is killed. I have tried sending only notification and only data from Postman but nothing works when app is killed. FCM does not launch any notification. it only works when app is in background or foreground. Has anyone actually found a solution? |
@achavhan Do you use a recent Android Studio version? |
@2ndGAB In my leeco 1s auto start was turned off by default. Giving permission of auto start solved the issue. Now I am looking for the reason why it didn't work in emulator. |
my personal advise is use phonegap-push-plugin
…---- On Thu, 09 Mar 2017 22:11:10 +0530 AMOL CHAVHAN <[email protected]> wrote ----
When app is in killed notification is not visible neither is data. it's been whole day I am trying to get a notification when app is killed. I have tried sending only notification and only data from Postman but nothing works when app is killed. FCM does not launch any notification. it only works when app is in background or foreground. Has anyone actually found a solution?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
i got a solution for that.
when app is in background or killed,FCM will not call onmessagerecieved method,but it will send data to system tray to display notification.so datapayload(sent from fcm console) will not be handled by onmessagerecieved method.when user click on notification,it will launch default activity of app and datapayload will be passed by intent .so making change in oncreate method of launcher activity(as above)we can get datapayload even when app is in background or killed.(ex key is sent by fcm console).when app is in foreground datapayload and will be handled by onmessagerecieved method of fcm service. |
thank you
…---- On Wed, 22 Mar 2017 10:38:51 +0530 tushar2812 <[email protected]> wrote ----
i got a solution for that.
just put below code in oncreate method of launcher activity.
if (bundle != null) { String value = bundle.getString("key"); if (value != null) { startActivity(new Intent(MainActivity.this, secActivity.class)); } }
when app is in background or killed,FCM will not call onmessagerecieved method,but it will send data to system tray to display notification.so datapayload(sent from fcm console) will not be handled by onmessagerecieved method.when user click on notification,it will launch default activity of app and datapayload will be passed by intent .so making change in oncreate method of launcher activity(as above)we can get datapayload even when app is in background or killed.(ex key is sent by fcm console).when app is in foreground datapayload and will be handled by onmessagerecieved method of fcm service.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
If app is in Foreground you can receive the "Notification" as well as "Data" in "onMessageReceived" But if the app is running in background the "Notification" is delivered to SystemTray but the "Data" is delivered to "Intent Extra" if you deliver Notification and Data both at same time. So instead in you "onMessageRecieved" method, what you need to do is. In you Activity where you are redirecting users to when they click notification. Just create : String data_message = getIntent().getStringExtra("data-key"); Replace "data-key" with the key of data. Say for example :
If you want detailed explaination, you can checkout : |
how about my solution |
Hi Guys , the only issue i am facing is with ionic 3 cordova fcm plugin , the push notification shows up silently in the systems tray whereas i want the the notification to pop out and display like chat notifications do on whats app or instagram.. what can be done about this.? |
Is this possible to send a notification from FCM for background app. |
In Meizu M1 Note data-only push comes if app is foreground/background? but if app is killed onMessageRecieved is not call. |
|
everything is working fine , |
I'm get message in both param data and notification , When my app in background onMessageReceived not triggered |
Hi,
The FCM works fine when the app is in foreground and a push comes, but when the app is in background and the system tray notification is clicked , it just opens up the app without passing any intent extras. I have added the
click_action
in Notification Payload from Advanced option of Firebase Console to open an activity but it dosen't work. I have also added the intent-filter ( handle backgound app section) as in documentation.How can i open a specific activity using FCM service along with the data i pass when the app is in background or exit state.
The text was updated successfully, but these errors were encountered: