gpt4 book ai didi

iOS:BLE 设备(不是 iBeacon)能否唤醒我的应用程序?

转载 作者:可可西里 更新时间:2023-11-01 17:05:36 26 4
gpt4 key购买 nike

是否可以将普通蓝牙低功耗设备(不是 iBeacon!)与我的 iPhone 应用相关联,这样当设备发送数据时,即使 iPhone 已锁定且应用已终止,我的应用也会被 iPhone 唤醒(甚至不在后台)?

最佳答案

只要您的应用程序指定了蓝牙中央后台模式,那么它就会被唤醒

  • 您的应用与设备建立了当前连接并发送数据(即设备在范围内并通知或指示特征)
  • 您的应用与设备的连接处于挂起状态并且它进入范围(即设备超出范围,但您已调用 connect 以在设备进入范围时自动重新连接)
  • 您的应用正在扫描特定服务类型,并且宣传其中一种服务类型的设备进入范围

应用终止的情况略有不同。为了使这些方案在这种情况下起作用,您的应用程序必须实现 state preservation and restoration

Core Bluetooth supports state preservation and restoration for apps that implement the central role, peripheral role, or both.

When your app implements the central role and adds support for state preservation and restoration, the system saves the state of your central manager object when the system is about to terminate your app to free up memory (if your app has multiple central managers, you can choose which ones you want the system to keep track of). In particular, for a given CBCentralManager object, the system keeps track of:

  • The services the central manager was scanning for (and any scan options specified when the scan started)
  • The peripherals the central manager was trying to connect to or had already connected to
  • The characteristics the central manager was subscribed to

Apple 指南中谈到了您的 App 由于内存压力而终止的情况。它没有指定如果应用程序被用户在应用程序切换器中“向上滑动”终止时会发生什么——在许多情况下,iOS 将此视为用户根本不希望应用程序运行并且不会运行的指示在这种情况下恢复它。

关于iOS:BLE 设备(不是 iBeacon)能否唤醒我的应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31905852/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com