I have ran the sample app and it does not work there
Version
Technology
Version
Workmanager version
0.5.2
Xcode version
15.0
Swift version
5.9
iOS deployment target
17.0.2
Describe the error
I've setup the example app by copying an pasting the example app code into lib/main.dart and setup the pubspec.yaml with the proper dependencies:
added the background capacities:
updated AppDelegate.swift:
import UIKit
import Flutter
import workmanager
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
GeneratedPluginRegistrant.register(with: self)
UNUserNotificationCenter.current().delegate = self
WorkmanagerPlugin.setPluginRegistrantCallback { registry in
// Registry in this case is the FlutterEngine that is created in Workmanager's
// performFetchWithCompletionHandler or BGAppRefreshTask.
// This will make other plugins available during a background operation.
GeneratedPluginRegistrant.register(with: registry)
}
WorkmanagerPlugin.registerTask(withIdentifier: "be.tramckrijte.workmanagerExample.taskId")
WorkmanagerPlugin.registerTask(withIdentifier: "be.tramckrijte.workmanagerExample.simpleTask")
WorkmanagerPlugin.registerTask(withIdentifier: "be.tramckrijte.workmanagerExample.rescheduledTask")
WorkmanagerPlugin.registerTask(withIdentifier: "be.tramckrijte.workmanagerExample.failedTask")
WorkmanagerPlugin.registerTask(withIdentifier: "be.tramckrijte.workmanagerExample.simpleDelayedTask")
WorkmanagerPlugin.registerTask(withIdentifier: "be.tramckrijte.workmanagerExample.simplePeriodicTask")
WorkmanagerPlugin.registerTask(withIdentifier: "be.tramckrijte.workmanagerExample.simplePeriodic1HourTask")
UIApplication.shared.setMinimumBackgroundFetchInterval(TimeInterval(60*15))
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func userNotificationCenter(
_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler(.alert) // shows banner even if app is in foreground
}
}
and updated my info.plist:
The code builds and installs on my iphone 15 physical device, yet when I run Debug > Simulate Background Fetch, all that happens is the foreground app closes. I'm expecting at least a print to console as per the example code. Here are some snippets of the example code:
But I get nothing. I'm quite stumped. Am I missing some settings? or might this be an issue with ios 17?
Output of flutter doctor -v
[✓] Flutter (Channel stable, 3.13.6, on macOS 14.0 23A344 darwin-arm64, locale en-CA)
• Flutter version 3.13.6 on channel stable at /Users/user/Development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ead455963c (4 weeks ago), 2023-09-26 18:28:17 -0700
• Engine revision a794cf2681
• Dart version 3.1.3
• DevTools version 2.25.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at /Users/jboldsenryan/Library/Android/sdk
• Platform android-33, build-tools 33.0.1
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15A240d
• CocoaPods version 1.13.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
Version
Describe the error
I've setup the example app by copying an pasting the example app code into lib/main.dart and setup the pubspec.yaml with the proper dependencies:
added the background capacities:
updated AppDelegate.swift:
and updated my info.plist:
The code builds and installs on my iphone 15 physical device, yet when I run Debug > Simulate Background Fetch, all that happens is the foreground app closes. I'm expecting at least a print to console as per the example code. Here are some snippets of the example code:
But I get nothing. I'm quite stumped. Am I missing some settings? or might this be an issue with ios 17?
Output of
flutter doctor -v
[✓] Flutter (Channel stable, 3.13.6, on macOS 14.0 23A344 darwin-arm64, locale en-CA) • Flutter version 3.13.6 on channel stable at /Users/user/Development/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision ead455963c (4 weeks ago), 2023-09-26 18:28:17 -0700 • Engine revision a794cf2681 • Dart version 3.1.3 • DevTools version 2.25.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1) • Android SDK at /Users/jboldsenryan/Library/Android/sdk • Platform android-33, build-tools 33.0.1 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) • All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.0) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15A240d • CocoaPods version 1.13.0
[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.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.13+0-b1751.21-8125866)
[✓] VS Code (version 1.83.0) • VS Code at /Applications/VS Code.app/Contents • Flutter extension version 3.72.0
[✓] Connected device (3 available) • iPhone (mobile) • ios • iOS 17.0.3 21A360 • macOS (desktop) • macos • darwin-arm64 • macOS 14.0 23A344 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 118.0.5993.96
[✓] Network resources • All expected network resources are available.
• No issues found!