quickstart-android icon indicating copy to clipboard operation
quickstart-android copied to clipboard

App (killed) starts automagically after receiving notification

Open hare989 opened this issue 8 years ago • 1 comments

Step 2: Describe your environment

  • Android device: Emulators, Huawei P9 Lite, Samsung Galaxy Tab 3
  • Android OS version: 4.4.4, 5.1, 6.0, 7.0
  • Google Play Services version: com.google.gms:google-services:4.1.0 (Also found in play-services-basement-15.0.1.aar in values.xml: 12451000)
  • Firebase/Play Services SDK version:
    • com.google.android.gms:play-services-ads:15.0.1
    • com.google.android.gms:play-services-analytics:16.0.3
    • com.google.firebase:firebase-core:16.0.3
    • com.google.firebase:firebase-messaging:17.3.0

Step 3: Describe the problem:

After I figured out how to receive notification when my app is killed I faced with other thing: now when I receive notification when app is killed, notification is showed in status bar but immediately after that application starts automagically without launcher activity ever created and without intent data from notification data payload. It starts Application subclass where I create login activity. Also, if I swipe app from recent apps, notification will stay in status bar and and after clearing all notifications app starts automagically again. This happens no matter if notification is sent via console or with cURL.

Steps to reproduce:

  1. App killed
  2. Send notification to single device with or without data payload from Firebase console or using cURL

Observed Results:

App starts automagically with Application singleton subclass onCreate method; Launcher activity defined in AndroidManifest.xml was never created. Cannot obtain intent with data from notification.

Expected Results:

Push notification icon is showed in status bar. App doesn't start without user interaction.

Relevant Code:

AndroidManifest.xml

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

<meta-data
          android:name="com.google.android.gms.version"
          android:value="@integer/google_play_services_version" />

onMessageReceived in MyFirebaseMessagingService.java is never called because app is killed.

hare989 avatar Aug 29 '18 10:08 hare989

It starts Application subclass where I create login activity

This sounds like the issue to me. No part of your app can run without the Application being initialized. If your Application class is launching an activity, that will happen at some pretty random times!

I suggest removing that logic from your Application class, this doesn't sound like a bug with FCM.

samtstern avatar Sep 13 '18 21:09 samtstern