https://kotlinlang.org logo
Title
m

Mohamed Ibrahim

10/24/2019, 7:40 AM
does anyone know how to debug a FCM notification while app is closed
m

mertceyhan

10/24/2019, 8:01 AM
App isn’t closed when coming notification, FCM service is running on background. You can select your app in “choose process” screen on android studio.
m

Mohamed Ibrahim

10/24/2019, 8:03 AM
how you will do that
g

gildor

10/24/2019, 8:04 AM
Just log incoming message to Logcat
👍 1
if you want to wait for debugger, and cold start of the app (so app is not started yet) just use
android.os.Debug.waitForDebugger()
m

mertceyhan

10/24/2019, 8:07 AM
Send notification to yourself while app is closed and FCM Service start to running on background in this moment. You can select your app in “choose process” screen
g

gildor

10/24/2019, 8:08 AM
True, but it may be tricky to catch particular moment between app start and moment when you attach it to debugger, waitForDebugger() may help debug such cases
👍 1
m

mertceyhan

10/24/2019, 8:10 AM
In my case, App will stop at breakpoint while you click to notification.
g

gildor

10/24/2019, 8:11 AM
yes, but it only if you debug some code that runs after click
you may also want to debug code that parses GCM message or register InstanceId token etc, really depends on case
m

mertceyhan

10/24/2019, 8:18 AM
Right. Two case can work for you, @Mohamed Ibrahim should try these.
m

Mohamed Ibrahim

10/24/2019, 10:13 AM
thank you guys I'll try that