-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐞iOS: registerOneOffTask never registers with callbackDispatcher #450
Comments
same issue on iOS 16 |
This happens to me as well. Don't paste code because it happens also with plugin's example. If I run example on android, it works perfectly. |
Hi, I inspected the behavior. The issue at the moment seems the isolated SharedPrefs on iOS . I consider to write the data's to an extra file without storing in SharedPrefs. Be aware iOS is arbitrary and BGRefresh doesn't start like an Android BGTask. Sometimes on iOS the task is called after few minutes, sometimes after two hours. Please tell me what you want to do. Perhaps I can add a helpful sample code snippet. |
@xunreal75 thx for the kind help. The need is to have task running for at least 20-30sec even if user moves app to background |
Hi I think your idea is the wrong approach. You could use notifications to wake up the app in background. This will happen a lot of battery duscharge. |
Yea, noticed that. We will do incremental daily backup. Data will be <30MB which can be uploaded in <20sec over wifi. Silent notifications from server are killed by ios in many occasion, we use Once to run a background task 2 times a day from foreground state |
Hi there, |
Hi. I'm recoding at the moment the OnOffTask and looking for other issues. Further the SharedPrefs reading in isolated doesn't update - updates are only visible after restart app. I'll solve that by writing log to local filesystem. There are some (strange) restrictions in iOS. At the moment the Task starts as AppRefreshTask - means the task starts at any time when iOS like to start.
|
Facing same issue on Ios, Any updates on this ? |
@xunreal75 were you able to finalize your solution, if yes could you share the outcome
If you mean on the dart side then you can use |
Many good points in this thread. Will close this ticket in favor of that one. |
Version
Describe the error
Have followed all the directions in the iOS setup and guides but am unable to get the plugin to work correctly. No errors are thrown - the callback dispatcher is just never called. The code works without fault on Android. The test environment is a physical device (iPhone XS running iOS 16.1.2) and is being debugged from XCode. The Info.plist has been configured with the correct task indentifier and backgroundFetch seems to work as expected and triggers the callbackDispatcher, but registering a one off task doesn't.
callbackDispatcher as top level function:
my AppDelegate.swift:
I'm calling registerOneOffTask from a Popupmenuitem:
When calling the onTap function this is the debug output:
I noticed that the callback will fire at a very random time (not associated with any input or background fetch) and the task will be in the queue but missing the input data.
I was expecting behaviour similar to what I am seeing in Android where the callback function is triggered nearly immediately upon registering the task. Am I missunderstanding the functionality of this package or have I missused it?
**[✓] Flutter (Channel stable, 3.0.3, on macOS 13.0.1 22A400 darwin-x64, locale en-AU)
• Flutter version 3.0.3 at /Users/ChrisBrislin/Developer/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 676cefaaff (6 months ago), 2022-06-22 11:34:49 -0700
• Engine revision ffe7b86a1e
• Dart version 2.17.5
• DevTools version 2.12.2
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/ChrisBrislin/Library/Android/sdk
• Platform android-33, build-tools 33.0.0
• Java binary at: /Applications/Android
Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
[✓] IntelliJ IDEA Community Edition (version 2021.3.2)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
[✓] VS Code (version 1.74.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.54.0
[✓] Connected device (4 available)
• Chris iphone (mobile) • 00008020-001870340E92002E • ios
• iOS 16.1.2 20B110
• iPhone 14 (mobile) • 91A06788-785D-40B3-AEA8-77AED473ECCF • ios
• com.apple.CoreSimulator.SimRuntime.iOS-16-1 (simulator)
• macOS (desktop) • macos • darwin-x64
• macOS 13.0.1 22A400 darwin-x64
• Chrome (web) • chrome • web-javascript
• Google Chrome 108.0.5359.98
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!**
The text was updated successfully, but these errors were encountered: