ryanheise / audio_service

Flutter plugin to play audio in the background while the screen is off.
797 stars 477 forks source link

App stops at splash screen after entering via firebase notification #1004

Open Szymon-Gesicki opened 1 year ago

Szymon-Gesicki commented 1 year ago

Documented behaviour

The application should work properly after implementing the plugin. It should turn on correctly from a notification or from the home screen.

Actual behaviour

The application stop on splash screen when accessed from a firebase notification. Nothing can be done. When you open the app without notification everything works fine.

Minimal reproduction project

https://github.com/Szymon-Gesicki/AudioServiceExample

Reproduction steps

  1. compile the applications and copy your fcm token
  2. turn off the application, stop, so that it not be in the background, terminanted
  3. send "push notification" to your phone. To do this, use the command below. Replace the fcm token with yours in "to" variable
curl --location --request POST 'https://fcm.googleapis.com/fcm/send' \
--header 'Authorization: key=AAAAddPFzt8:APA91bFdGwc83baoL7NG5Jje7tnoU4ALub0_V159cupx--bPqVra29WKmG_4Sq83r5zo5S8mlrcDOj4T72y9vWQorsyVDNP7rlgvn8hcECaV6HL4pyn_hyhRaHrUEtIg2Vsn7idJL_dv' \
--header 'Content-Type: application/json' \
--data-raw '{
 "to" : "YOUR_TOKEN",
 "data": {
     "custom": "test"
 }
}'
  1. click on the notification, the app will stop in a splash screen

    Output of flutter doctor

    [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
    [✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    [✓] Chrome - develop for the web
    [✓] Android Studio
    [✓] Android Studio (version 2021.1)
    [✓] Android Studio (version 2021.2)
    [✓] VS Code (version 1.76.0)
    [✓] Connected device (5 available)
    [✓] HTTP Host Availability

    Devices exhibiting the bug

    Android 12 Pixel 3a, on ios everything works fine

ryanheise commented 1 year ago

Documented behaviour

The application should work

Actual behaviour

The application does not work properly after entering the notification. It stops and nothing can be done.

Would you mind putting some more effort into your answers to these questions? The instructions for "Documented behaviour" were quite specific.

You also have a formatting issue with the formatting of the flutter doctor output. The 3 back-tics at the end need to go on a separate line to close the code block.

Szymon-Gesicki commented 1 year ago

I corrected, I think everything is quite accurate with a good example.

mickbad commented 1 year ago

Hello,

I have same issue with same context : freeze on splash android screen when received firebase notification and apps terminated

But I have this message in Logcat android studio 2023-03-27 14:57:40.929 202-202 Layer surfaceflinger E [Surface(name=AppWindowToken{3cd6ecc token=Token{aa5a0ff ActivityRecord{4e1401e u0 io.sample.apps/com.ryanheise.audioservice.AudioServiceActivity t42}}})/@0xc66b700 - animation-leash#0] No local sync point found

If it can help solve the bug :)

thanks for your work

andrearubeis commented 1 year ago

Hi everyone,

I have the exact same problem with my app. However, I can add that it started happening the moment I implemented background push notification handling. Before that, it didn't occur.

The background push notification handling initiates an isolate that somehow keeps the app alive in the background. If I open the app by tapping on the notification or by launching it from the icon, the behavior is a black screen.

dfdgsdfg commented 3 months ago

875 ?

djsjr commented 1 month ago

duplicate of #875 - suggest closing