title: Android Notification with FCM - Who started the FirebaseMessagingService?
body: <p>According to the set up guide <a href="https://firebase.google.com/docs/cloud-messaging/android/client" rel="noreferrer">here</a>, in a sample app, A) I created a class that <code>extends</code> firebase services class.  B) I put these classes in the <code>AndroidManifest.xml</code></p>
  
  <p>A) Java Class</p>
  
  <pre><code>public class MyFirebaseMessagingService extends FirebaseMessagingService {
  
      @Override
      public void onMessageReceived(RemoteMessage remoteMessage) {
          //a) What's the life cycle of the service? How can I ensure this method is getting called?
          //b) If the service is killed at some point, will system restart it on receiving new messages?
          Log.d(TAG, "From: " + remoteMessage.getFrom());
      }
  }
  </code></pre>
  
  <p>B) AndroidManifest.xml</p>
  
  <pre><code>&lt;service
      android:name=".MyFirebaseMessagingService"&gt;
      &lt;intent-filter&gt;
          &lt;action android:name="com.google.firebase.MESSAGING_EVENT"/&gt;
      &lt;/intent-filter&gt;
  &lt;/service&gt;
  </code></pre>
  
  <p>Then, the app can receive notifications from FCM!</p>
  
  <p>Here is my question: </p>
  
  <ol>
  <li><p>Who started the FirebaseMessagingService notification service?
  There must be some place calling startService(), isn't it? </p></li>
  <li><p>My understanding is that, the downstream notification will deliver to my mobile device's google play service, regardless of the state of my app. 
  Then, to what extent can I ensure that my <code>onMessageReceive()</code> is called when the <code>app</code> or <code>service</code> is <code>swipe closed/killed/force stop</code>? Is the relevant behavior documented anywhere?</p></li>
  </ol>
  
  <p>EDIT: </p>
  
  <ol start="3">
  <li>I am more concerned about the following case. Let's talk about the <code>data message</code>. (compared to the <code>notification message</code>.)
  My client app received the FCM message and shows the default notification, because google play service is running and send it to the system tray. But my <code>onMessageReceive()</code> is not called, because <code>MyFirebaseMessagingService</code> is killed by system and not restarted. Is it possible? </li>
  </ol>