In some case, you might want to check your app is running in background or foreground, such as you want to show push notification message only when the app is in background. The following method will be very easy to know app running state.
...
Now, Google Inc removed
GCM and start using FCM to push notification.
We 'll instruction to
you How to intergrate Firebase to your backend, so that you can send messages
from your server.
...