Skip to content
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

Simulate background fetch closes app rather than expected behaviour from example app for ios 17.0.2 #515

Open
justin-boldsen opened this issue Oct 23, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@justin-boldsen
Copy link

justin-boldsen commented Oct 23, 2023

  • 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

added the background capacities:

Screenshot 2023-10-22 at 8 01 33 PM

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

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 Screenshot 2023-10-22 at 8 13 39 PM

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!

@justin-boldsen justin-boldsen added the bug Something isn't working label Oct 23, 2023
@justin-boldsen justin-boldsen changed the title Simulate background fetch closes app rather than expected behaviour from example app for ios 17.0.3 Simulate background fetch closes app rather than expected behaviour from example app for ios 17.0.2 Oct 23, 2023
@vishweshsoni
Copy link

vishweshsoni commented Oct 24, 2023

Same for me on real device

@ScottAtRedHawk
Copy link

Same for me as well.

@AtomicRaven
Copy link

Also have this exact issue

@naamapps
Copy link

Same here! any update?

@OmerTrainer
Copy link

same for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants