My code is ditto same as provided by fcm docs I am recieving notification when app is closed without using intent extras or any php code.
when app is in foreground onMessageRecieved() method gets invoked so i get default sound but when app is in background or closed i dont get sound.
i am using one phone and firebase console to send message thats it no php scripts or http requests
my phone setting has max volume for notification
From your firebase console (Notifications), go to Advanced options > Sound > Enable - before sending every message. Thus you'll get sound even if your app is in background. Here's a screenshot