android - Get Data From Notification via Intent When App Not Running

Clash Royale CLAN TAG#URR8PPPandroid - Get Data From Notification via Intent When App Not Running
I have an app using Firebase Notification and when the notification coming i want to open the application and get data from it. Now i'm using getLaunchIntent() to open app but it's only open when app is in backstack/running in background. If
the app is not running, it doesn't open the app.
The problem listed here:
I want to open app and get data from intent despite the app is in foreground/background/not running. The method getLaunchIntent() didn't pass any data if i want to open current app, it only pass data when i open other application. Any help is appreciated, thanks for help!
1 Answer
1
If you want to get the payload, you should use data {"string":"val"} and define a click_action to get the data in your activity.
data {"string":"val"}
click_action
Then you should only use data{} block not notification{}, using only data block will make onMessageReceived() called in all situations, when the function is called you can do any operation you want.
– H. Ekici
9 mins ago
Yes, i'm only using data block in my payload. The problem here is the getLaunchIntent didn't pass any data if i open current application. But when i use getLaunchIntent to open other application, the data is there and not null :/
– Kapocs Zoltan
5 mins ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
I suppose click_action is used if you want to open specific activity when user clicked on notification but my case is different. I'm looking for method to open the app automatically when notification is received. Sorry the question isn't clear enough, i have edited it.
– Kapocs Zoltan
44 mins ago