iOS 版 Flutter App 上出现 FlutterObservatoryPublisher 错误

Jay*_*n45 5 ios firebase-realtime-database flutter

我从 flutter 调试控制台收到此错误“[VERBOSE-2:FlutterObservatoryPublisher.mm(143)] 无法注册为 FlutterObservatoryPublisher 的服务器。请检查您的网络设置并重新启动应用程序。”

我正在构建一个匹配应用程序,如果应用程序最小化或屏幕关闭,我希望能够在找到匹配项时通过本地推送通知通知用户。我的问题是我无法让 iOS 版本的应用程序在后台运行以继续侦听数据库中的更改。我的数据库是 Firebase 实时数据库,我需要该应用在搜索匹配项时保持清醒。我正在使用 flutter_background_service 包来保持匹配搜索过程在后台运行。我已经能够让后台服务在 Android 上运行,但不能在 iOS 上运行。在调试模式下,iOS 版本在后台运行良好,但在配置文件或发布模式下则无法运行。

谁能指出我如何解决这个问题的正确方向?

Kau*_*dru 0

请检查以下内容

  1. 启用后台获取和后台处理

  2. 将这些添加到 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>
<!-- Background Processing -->
<key>UIBackgroundModes</key>
<array>
    <string>processing</string>
</array>

<!-- Task Schedulling -->
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
   <string>workmanager.background.task</string>
</array>

<!-- Background Fetching -->
<key>UIBackgroundModes</key>
<array>
    <string>fetch</string>
</array>
</dict>
Run Code Online (Sandbox Code Playgroud)
  1. 在 appdelegate.swift 中
import UIKit
import Flutter

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
    UIApplication.shared.setMinimumBackgroundFetchInterval(TimeInterval(/* Your Desired Interval for Background Tasks */)) 
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}
Run Code Online (Sandbox Code Playgroud)