xinthink / flt_worker

Schedule & run Dart code in the background on both Android & iOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does the example works?

vicenterusso opened this issue · comments

I cloned the repo and started the example on ios simulator. Apparently nothing happened when I click the buttons, no error, no exceptions, no value being changed.

[✓] Flutter (Channel master, 1.22.0-10.0.pre.380, on Mac OS X 10.15.6 19G2021 x86_64, locale en-BR)
    • Flutter version 1.22.0-10.0.pre.380 at /Users/vicente/fvm/versions/master
    • Framework revision ec40df9576 (11 hours ago), 2020-09-25 21:27:22 -0700
    • Engine revision 3a73d073c8
    • Dart version 2.11.0 (build 2.11.0-161.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/vicente/Library/Android/sdk
    • Platform android-29, build-tools 29.0.2
    • ANDROID_SDK_ROOT = /Users/vicente/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.0, Build version 12A7209
    • CocoaPods version 1.9.3

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 41.1.2
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.49.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.14.1


[✓] Connected device (1 available)
    • iPhone SE (2nd generation) (mobile) • 20FE9D1E-FFAB-4B29-807E-BDDB6794DE71 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-0 (simulator)

• No issues found!

I think the problem is from iOS, because the background process doesn't work the same way as android's WorkManager. The iOS still decides when to call your task :( and will not trigger immediately after all conditions are met as with the WorkManager.

There are example commands in the repo which you can use to force trigger the background event on iOS
https://github.com/xinthink/flt_worker/blob/master/example/lib/main.dart

Here is the documentation from apple : https://developer.apple.com/documentation/backgroundtasks/starting_and_terminating_tasks_during_development

I have tested it as registered an event , then kill the app and run it again from XCode with break point in the application class(after plugin registration). While the code is stopped on the break point, put in the console one of the commands from the main.dart and resume the app.
My callback writes many logs, basically after each row so I can see what has been done.

I think that this approach works on real devices only though.

However, another drawback is that you still have a limited time and if you are uploading 20 images may still not be enough to finish.