JulianAssmann / flutter_background

A flutter plugin to keep apps running in the background via foreground services. Android only.
https://pub.dev/packages/flutter_background
MIT License
86 stars 46 forks source link

[BUG] The notification closes when closing the application #28

Closed miguelflores1993 closed 3 years ago

miguelflores1993 commented 3 years ago

Describe the bug

I bought an s10 plus phone. I just tested flutter_background and when I close the app the notification closes as well. I have seen in some applications that when the application is completely closed, a notification always remains on the screen.

To Reproduce close the application the notification closes

Expected behavior The notification should not be closed.

Screenshots none

Smartphone: Samsumg s10 + android 11

JulianAssmann commented 3 years ago

This is expected behaviour, see #10 Is there a specific reason you want the notification to live on after the app is closed?

miguelflores1993 commented 3 years ago

Este es el comportamiento esperado, consulte el n . ° 10. ¿Hay alguna razón específica por la que desea que la notificación siga activa después de que se cierre la aplicación?

@JulianAssmann Yes, because I am applying the Offline First Mobile architecture, and I need that when the application is closed it still sends the local SQLITE data to the Amazon cloud.

Similar to WhatsApp when it is synchronizing your data and when you close it, a current notification appears.

JulianAssmann commented 3 years ago

I'm not sure this plugin is the best choice for this kind of task. This plugin keeps the Flutter app running in the background, but the Flutter runtime is terminated when the user explicitly closes the app (e.g. by swiping up in the task view). So there is no use in still holding on to the Wake Lock, as nothing would happen anyway. I don't know the specifics of your use case, but maybe something like the Android JobScheduler or the workmanager plugin might be more suitable to it. However, background execution on Android is a mess in general (see here and dontkillmyapp for more).

miguelflores1993 commented 3 years ago

No estoy seguro de que este complemento sea la mejor opción para este tipo de tarea. Este complemento mantiene la aplicación Flutter ejecutándose en segundo plano, pero el tiempo de ejecución de Flutter finaliza cuando el usuario cierra explícitamente la aplicación (por ejemplo, deslizando hacia arriba en la vista de tareas). Por lo tanto, no tiene sentido seguir aferrándose al Wake Lock, ya que de todos modos no pasaría nada. No conozco los detalles de su caso de uso, pero tal vez algo como Android JobScheduler o el complemento workmanager podría ser más adecuado para él. Sin embargo, la ejecución en segundo plano en Android es un desastre en general (consulte aquí y dontkillmyapp para obtener más información). @JulianAssmann How will facebook or whatssap be able to do it? will they have their own sdk?

thanks for your clarification

JulianAssmann commented 3 years ago

You're welcome :)