flutter_workmanager
flutter_workmanager copied to clipboard
Flutter workmanager not working in ios background
- [x] I have read the README
- [x] I have done the setup for iOS
- [x] I have ran the sample app and it does not work there
Version
Technology | Version |
---|---|
Workmanager version | latest |
Xcode version | 13.4 |
Swift version | |
iOS deployment target |
Describe the error
I have downloaded workmanager repository on Github. then I add some code in the callback dispatcher. I have included the code below. Then I debug using Xcode.
After pressing the Background Fetch button (in Xcode), the app went minimize & starts warkmanager by showing a local notification. but when I close my app (terminate, remove from recent), not running in the background.
when the app is minimized, the app is working fine. but not working in the background.
I have tested with the release build.
what should I do right now?
This code I added inside the callback dispatcher
for (int i = 0; i < 1000; i++) {
await Future.delayed(const Duration(seconds: 5));
AwesomeNotifications().createNotification(
content: NotificationContent(
id: 10,
channelKey: 'basic_channel',
title: i.toString(),
body: 'Workmanager '));
print("background $i");
}
await Future.delayed(const Duration(minutes: 15));
I have initialized the notification package before this code. & WidgetFlutterBinding.ensureInitialized()
Output of flutter doctor -v
[✓] Flutter (Channel stable, 3.0.1, on macOS 12.3.1 21E258 darwin-arm, locale
en-BD)
• Flutter version 3.0.1 at /Users/shakil/Desktop/Remon/flutter_latest
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision fb57da5f94 (3 weeks ago), 2022-05-19 15:50:29 -0700
• Engine revision caaafc5604
• Dart version 2.17.1
• DevTools version 2.12.2
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/shakil/Library/Android/sdk
• Platform android-31, build-tools 31.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-7249189)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] 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-7249189)
[✓] VS Code (version 1.67.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.42.0
[✓] Connected device (3 available)
• AGL iPhone (mobile) • ba6ebe86b805f74de860ebd222cac1e70c3ac21c • ios
• iOS 15.5 19F77
• macOS (desktop) • macos •
darwin-arm64 • macOS 12.3.1 21E258 darwin-arm
• Chrome (web) • chrome •
web-javascript • Google Chrome 102.0.5005.61
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
its same for me I just register a simple one off task but nothing happens
Me neither, Please help. I'm using flutter 3.0.5, xcode 13.4.1, workmanager 0.5.0
How to fix this ? The task never run even after 20 minutes
Same issue here with Flutter 3.0.5 and iOS 15.5 on real device. Work correctly on Android.
Same issue here, in debug it works only with first run, no any others runs, on android (all fine)
Same issue, I have tested with example app with real iPhone device but noting happens.
If you kill the App (swipe it away in the task switcher), iOS considers the App killed and will not perform background task.
Background Fetch can be triggered using Xcode (simulate background fetch) and typically runs once a day.
If you need fine-grained control, follow the setup guide for BGAppRefreshTasks.
My brother implemented it and it works it. he researches out of the box. which means your documentation is not enough to work fine.
Contributions are always welcome :)
My brother implemented it and it works it. he researches out of the box. which means your documentation is not enough to work fine.
Would be helpful if you share how he achieved that
My brother implemented it and it works it. he researches out of the box. which means your documentation is not enough to work fine.
@blackshadowsoftwareltd It would be nice if you could share your solution, I have the same problem like your issue