Simulate background fetch closes app rather than expected behaviour from example app for ios 17.0.2
justin-boldsen opened this issue · comments
- I have read the README
- I have done the setup for iOS
- 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:
![Screenshot 2023-10-22 at 8 07 34 PM](https://user-images.githubusercontent.com/4400621/277220678-f257748f-7ebc-4d38-8b4b-7aede5cf008d.png)
added the background capacities:
![Screenshot 2023-10-22 at 8 01 33 PM](https://user-images.githubusercontent.com/4400621/277219888-507b430c-8b86-4858-beb3-2fd4bd895540.png)
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:
![Screenshot 2023-10-22 at 8 05 09 PM](https://user-images.githubusercontent.com/4400621/277220313-45b53094-6e47-463b-bc38-e83cc86a58c0.png)
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:
![Screenshot 2023-10-22 at 8 12 05 PM](https://user-images.githubusercontent.com/4400621/277221209-91e64511-e9cb-4925-accd-6f55a17e0996.png)
![Screenshot 2023-10-22 at 8 13 39 PM](https://user-images.githubusercontent.com/4400621/277221412-21b5cb95-e370-43f3-9384-aea1ba7b5df3.png)
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!
Same for me on real device
Same for me as well.
Also have this exact issue