Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the FireBaseCloud start the services registered in the manifest?

I'm new to android. And during my period of developing an App for android that has FireBaseCloud integrated with it. If we go through documentation for setting up a client app for FireBaseMessaging service it tells you to register two services in the manifest as follows.

<service
android:name=".MyFirebaseMessagingService">
<intent-filter>
    <action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>

  <service
android:name=".MyFirebaseInstanceIDService">
<intent-filter>
    <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>

These are the two services that are registered in the manifest. My question is how does android system start these services? I know that both these services have intent filters with action specified but what if there are multiple application with these two services registered and implemented. How does the Firebase send the Notification from cloud and Android system receives it and gives to My Application specifically? (where i get the message in the "MyFirebaseMessagingService" service and send a notification out of it). Please shed some light upon this, to help me gain an understanding of it.

like image 746
Shoaib Anwar Avatar asked Oct 30 '22 23:10

Shoaib Anwar


1 Answers

The services that you have added to your manifest are started by Google Play services which is started at device startup. These services are also defined under your application's package name so another app will not be able to listen for notifications intended for your application.

like image 100
Arthur Thompson Avatar answered Nov 15 '22 05:11

Arthur Thompson