简体   繁体   English

Flutter_beacon 插件在 IOS 的后台不工作

[英]Flutter_beacon plugin is not working in Background for IOS

Is there any workaround here to keep MainActivity/App alive in the background in the IOS.这里有什么解决方法可以让 MainActivity/App 在 IOS 的后台保持活跃。

As I am using 2 different plugins to scan and broadcast at the same time.因为我使用 2 个不同的插件同时扫描和广播。

here's my scanning code: I am using FLUTTER_BEACON plugin这是我的扫描代码:我正在使用FLUTTER_BEACON插件

_streamRanging =
        flutterBeacon.ranging(regions).listen((RangingResult result) {
      print(result);
      if (result != null && mounted) {
        setState(() {
          _regionBeacons[result.region] = result.beacons;
          _beacons.clear();
          _regionBeacons.values.forEach((list) {
            _beacons.addAll(list);
          });
          _beacons.sort(_compareParameters);
        });
      }
    });

While this question is specifically about Flutter, iOS enforces certain rules on an app's background uses regardless of how an app is built:虽然这个问题专门针对 Flutter,但 iOS 对应用程序的后台使用强制执行某些规则,而不管应用程序是如何构建的:

  1. When an iOS app is not visible on the screen, it is considered in the background.当 iOS 应用程序在屏幕上不可见时,它被视为在后台。
  2. When in the background, an app's beacon ranging is blocked unless:在后台时,应用程序的信标测距被阻止,除非:

    a.一个。 The app sets up a background process (which will enable ONLY 30 seconds of ranging on iOS 13+ each time the app is put to the background) Read more here该应用程序设置了一个后台进程(每次将应用程序置于后台时,它只会在 iOS 13+ 上启用 30 秒的测距) 在这里阅读更多

    b.湾。 The sets up a background process, declares "location" background mode, and requests periodic location updates.设置后台进程,声明“位置”后台模式,并请求定期位置更新。 This will unlock unlimited background ranging, but it may make it impossible to get approved for the app store unless you can justify an obvious user-facing background location benefit.这将解锁无限的背景范围,但它可能无法获得应用商店的批准,除非你能证明一个明显的面向用户的背景位置优势是合理的。

    c. c。 As an alternative to (b) if the app does beacon monitoring, if a beacon monitoring region entry or exit can be triggered periodically, it will unlock an extra 30 seconds of background ranging as described in (a).作为 (b) 的替代方案,如果应用程序进行信标监控,如果可以定期触发信标监控区域进入或退出,它将解锁额外 30 秒的背景测距,如 (a) 中所述。 This is possible to do if you can deploy an alternating beacon in the location where the app is used.如果您可以在使用应用程序的位置部署交替信标,则可以做到这一点。

The workarounds described in (2) are the same whether you use Flutter or not.无论您是否使用 Flutter,(2)中描述的解决方法都是相同的。 The specifics of how you implement a background task is certainly different with Flutter. Flutter 实现后台任务的具体方式当然不同。

Edit 4/11/2020: Apple announced plans for a new beacon advertisement that will work in the background.编辑 2020 年 4 月 11 日: Apple 宣布了将在后台运行的新信标广告的计划。 See here for more info.请参阅此处了解更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM