菜鸟教程小白 发表于 2022-12-12 14:49:35

iOS/信标 - 打开蓝牙时如何触发 didEnterRegion?


                                            <p><p>我已经使用 ibeacons 设置了一个应用程序,我注意到当我在该区域内打开蓝牙时,<code>didEnterRegion</code> 从未被触发。但是,当我在蓝牙打开的情况下实际进入该区域时,它可以正常工作。</p>

<p>在前台时,我通过在 <code>didStartMonitoringForRegion</code> 中调用 <code></code> 来欺骗这种行为,并检查我是否在里面。 </p>

<p>但是,我不知道在后台做什么。我知道唯一可以触发的方法是 <code>didEnterRegion</code>,这意味着我在区域内仅打开蓝牙时无法发送通知。</p>

<p>有人做到了吗?</p>

<p>谢谢</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>想到的一个想法:给你的app添加<code>bluetooth-central</code>后台模式,实现<code>CBCentralManager</code>和<code>CBCentralManagerDelegate</code>的<a href="https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/CBCentralManagerDelegate_Protocol/index.html#//apple_ref/occ/intfm/CBCentralManagerDelegate/centralManagerDidUpdateState:" rel="noreferrer noopener nofollow"><code>centralManagerDidUpdateState</code></a> .这应该会在启用或禁用蓝牙时唤醒您的应用,您可以利用这段时间来<code>requestStateForRegion</code>。</p></p>
                                   
                                                <p style="font-size: 20px;">关于iOS/信标 - 打开蓝牙时如何触发 didEnterRegion?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/29278626/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/29278626/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: iOS/信标 - 打开蓝牙时如何触发 didEnterRegion?