fluttercommunity / flutter_downloader

Flutter Downloader - A plugin for creating and managing download tasks.
https://pub.dev/packages/flutter_downloader
BSD 3-Clause "New" or "Revised" License
911 stars 511 forks source link

iOS "Lost connection to device" Error #415

Closed ufukhawk closed 3 years ago

ufukhawk commented 3 years ago

Hello,

Although I have made all the settings "await FlutterDownloader.initialize (debug: true);" As soon as this code runs, I get a "Lost connection to device" error on the simulator device and there is no other information other than this message.

my AppDelegate.swift

 `import UIKit
  import Flutter
  import Firebase
  import flutter_downloader

      @UIApplicationMain
      @objc class AppDelegate: FlutterAppDelegate {
        override func application(
          _ application: UIApplication,
          didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
        ) -> Bool {
          GeneratedPluginRegistrant.register(with: self)
          return super.application(application, didFinishLaunchingWithOptions: launchOptions)
           FirebaseApp.configure()
              if #available(iOS 10.0, *) {
                UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
              }
              FlutterDownloaderPlugin.setPluginRegistrantCallback(registerPlugins)
              return super.application(application, didFinishLaunchingWithOptions: launchOptions)
        }
          let MY_BACKGROUND_SCREEN_TAG = 1001
          override func  applicationDidEnterBackground(_ application: UIApplication) {
              // Visual effect view for blur
              let blurEffect = UIBlurEffect(style: .dark)
              let blurView = UIVisualEffectView(effect: blurEffect)
              blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
              blurView.frame = window.frame
              blurView.tag = MY_BACKGROUND_SCREEN_TAG

              window.addSubview(blurView)
          }

          override func applicationWillEnterForeground(_ application: UIApplication) {
              // remove blur view if present
              let view = window.viewWithTag(MY_BACKGROUND_SCREEN_TAG)
              if let view = view {    
                  UIView.animate(withDuration: 0.2, animations: {
                      view.alpha = 0

                  }) { finished in
                      view.removeFromSuperview()
                  }
              }
          }
      }

      private func registerPlugins(registry: FlutterPluginRegistry) {
          if (!registry.hasPlugin("FlutterDownloaderPlugin")) {
             FlutterDownloaderPlugin.register(with: registry.registrar(forPlugin: "FlutterDownloaderPlugin")!)
          }
      }

`

my info.plist

      `<?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
      <plist version="1.0">
      <dict>
          <key>CFBundleDevelopmentRegion</key>
          <string>$(DEVELOPMENT_LANGUAGE)</string>
          <key>CFBundleDisplayName</key>
          <string>xxx</string>
          <key>CFBundleExecutable</key>
          <string>$(EXECUTABLE_NAME)</string>
          <key>CFBundleIdentifier</key>
          <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
          <key>CFBundleInfoDictionaryVersion</key>
          <string>6.0</string>
          <key>CFBundleName</key>
          <string>xxxxxx</string>
          <key>CFBundlePackageType</key>
          <string>APPL</string>
          <key>CFBundleShortVersionString</key>
          <string>$(MARKETING_VERSION)</string>
          <key>CFBundleSignature</key>
          <string>????</string>
          <key>CFBundleVersion</key>
          <string>$(CURRENT_PROJECT_VERSION)</string>
          <key>FDAllFilesDownloadedMessage</key>
          <string>All files have been downloaded</string>
          <key>FDMaximumConcurrentTasks</key>
          <integer>5</integer>
          <key>LSRequiresIPhoneOS</key>
          <true/>
          <key>NSFaceIDUsageDescription</key>
          <string>We need your face ID for automatic login.</string>
          <key>UIBackgroundModes</key>
          <array>
              <string>fetch</string>
              <string>processing</string>
              <string>remote-notification</string>
          </array>
          <key>UILaunchStoryboardName</key>
          <string>LaunchScreen</string>
          <key>UIMainStoryboardFile</key>
          <string>Main</string>
          <key>UISupportedInterfaceOrientations</key>
          <array>
              <string>UIInterfaceOrientationPortrait</string>
          </array>
          <key>UISupportedInterfaceOrientations~ipad</key>
          <array>
              <string>UIInterfaceOrientationPortrait</string>
              <string>UIInterfaceOrientationPortraitUpsideDown</string>
              <string>UIInterfaceOrientationLandscapeLeft</string>
              <string>UIInterfaceOrientationLandscapeRight</string>
          </array>
          <key>UIViewControllerBasedStatusBarAppearance</key>
          <false/>
      </dict>
      </plist>

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 1.22.6, on macOS 11.2.1 20D74 darwin-x64, locale en-TR) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) [✓] Xcode - develop for iOS and macOS (Xcode 12.4) [✓] Android Studio (version 4.1) [✓] Connected device (3 available)

      • No issues found!

`

ufukhawk commented 3 years ago

If I use an AppDelegate like in the document, it works. but i need to use Firebase?

      import UIKit
      import Flutter
      import flutter_downloader

      @UIApplicationMain
      @objc class AppDelegate: FlutterAppDelegate {
        override func application(
          _ application: UIApplication,
          didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
        ) -> Bool {
          GeneratedPluginRegistrant.register(with: self)
          FlutterDownloaderPlugin.setPluginRegistrantCallback(registerPlugins)
          return super.application(application, didFinishLaunchingWithOptions: launchOptions)
        }
      }

      private func registerPlugins(registry: FlutterPluginRegistry) { 
          if (!registry.hasPlugin("FlutterDownloaderPlugin")) {
             FlutterDownloaderPlugin.register(with: registry.registrar(forPlugin: "FlutterDownloaderPlugin")!)
          }
      }
dubey2k commented 3 years ago

If I use an AppDelegate like in the document, it works. but i need to use Firebase?

      import UIKit
      import Flutter
      import flutter_downloader

      @UIApplicationMain
      @objc class AppDelegate: FlutterAppDelegate {
        override func application(
          _ application: UIApplication,
          didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
        ) -> Bool {
          GeneratedPluginRegistrant.register(with: self)
          FlutterDownloaderPlugin.setPluginRegistrantCallback(registerPlugins)
          return super.application(application, didFinishLaunchingWithOptions: launchOptions)
        }
      }

      private func registerPlugins(registry: FlutterPluginRegistry) { 
          if (!registry.hasPlugin("FlutterDownloaderPlugin")) {
             FlutterDownloaderPlugin.register(with: registry.registrar(forPlugin: "FlutterDownloaderPlugin")!)
          }
      }

can you please give me the solution if you have, I am getting same error.

erperejildo commented 3 years ago

same error also