• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - 使ios7 BLE外围设备在后台工作

[复制链接]
菜鸟教程小白 发表于 2022-12-13 05:48:14 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我已阅读有关它的所有相关信息,但仍然无法让我的 iOS7 设备在后台像外围广告商一样工作。它在前台工作正常,但在后台我什至可以发现它。我在 plist 文件中添加了 App 使用 CoreBluetooth 共享数据。我读到进入后台后,它会将我的自定义 UUID 放入溢出数据中。我也试过这个(但没有运气)。

NSDictionary *advertisingData = @{
 CBAdvertisementDataServiceUUIDsKey : @[CBUUID UUIDWithString:TRANSFER_SERVICE_UUID],
 CBAdvertisementDataOverflowServiceUUIDsKey : @[CBUUID UUIDWithString:TRANSFER_SERVICE_UUID]
};  
[manager startAdvertising:advertisingData];

在另一边的中央(MAC OS 应用程序),我只扫描我的:TRANSFER_SERVICE_UUID 服务。有什么我错过的东西我应该在中心侧额外实现吗?



Best Answer-推荐答案


请注意 startAdvertising: 方法文档中的这一行:

While an application is in the background, the local name will not be used and all service UUIDs will be placed in the "overflow" area. However, applications that have not specified the "bluetooth-peripheral" background mode will not be able to advertise anything while in the background.

也就是说,后台外围设备会从广告中删除所有内容, iOS 应用程序只能检测到它的存在。 iOS 应用程序能够到达溢出区域,但 MacOS 应用程序不能。您需要在 MacOS 端关闭服务过滤才能检测到外设并连接到它以发现它是否具有搜索到的服务。

仅供引用,这种情况没有解决方法,它已在 Apple bluetooth-dev 邮件列表和许多 SO 问题中讨论过多次。

另请注意,CBAdvertisementDataOverflowServiceUUIDsKey 不是 startAdvertising: 的有效输入键。 CBAdvertisementDataOverflowServiceUUIDsKey 由 iOS 在 didDiscoverPeripheral 回调中返回,如果它在溢出区域中发现了某些东西。仅使用 CBAdvertisementDataServiceUUIDsKey 来定义广告服务列表。

关于ios - 使ios7 BLE外围设备在后台工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20915249/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap