How Firebase notifications are managed by the operating system?


Hi everyone,
i’m reading these repo:

First simple question:
My app has to be always in foreground or background to get a notification? Only the second link talks about a closed mode.
Second question:
Le’t say that my app is closed (not in background), i don’t understand how the device operating system knows that if the device receives a notification from Firebase then it is related to my app.

Thank you :slightly_smiling_face: