Skip to content

[iOS] Futures dont execute when onDestroy is called #392

Description

@ygor-coelho

When i swipe up my app, to kill my background service on ios, the onDestroyed is called, but, async methods not be executed

this is the simple snippet to reproduced.

Only synchronous methods will be executed, but I need asynchronous methods to be executed as well.

  @override
  Future<void> onDestroy(DateTime timestamp, bool isTimeout) async {
    print("[$_LOG] onDestroy: START - timestamp=$timestamp, isTimeout=$isTimeout");
    await Future.delayed(Duration(seconds: 1));
    print("[$_LOG] onDestroy: after delay 1");
    await Future.delayed(Duration(seconds: 1));
    print("[$_LOG] onDestroy: after delay 2");
    await Future.delayed(Duration(seconds: 1));
    print("[$_LOG] onDestroy: after delay 3");
    await Future.delayed(Duration(seconds: 1));
    print("[$_LOG] onDestroy: after delay 4");
    await Future.delayed(Duration(seconds: 1));
    print("[$_LOG] onDestroy: after delay 5");
    await Future.delayed(Duration(seconds: 1));
    print("[$_LOG] onDestroy: after delay 6");
    await Future.delayed(Duration(seconds: 1));
    print("[$_LOG] onDestroy: after delay 7");
    await Future.delayed(Duration(seconds: 1));
    print("[$_LOG] onDestroy: after delay 8");
  }

Log when app is killed

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions