简体   繁体   English

iOS 6 使用保存的 BLE 外设 UUID 重置所有设置问题

[英]iOS 6 Reset All Settings issue with saved BLE peripheral UUID

I am developing a BLE app on iOS where I saved to NSUSerDefaults the CBPeripheral UUID after a connection is formed to the BLE accessory.我正在 iOS 上开发一个 BLE 应用程序,在与 BLE 附件建立连接后,我将 CBPeripheral UUID 保存到 NSUSerDefaults。 This way, if the app is re-launched later on, and the BLE accessory is not turned-on or out of range, I can display the BLE accessory in the App's UI as "not found".这样,如果稍后重新启动应用程序,并且 BLE 附件未打开或超出范围,我可以在应用程序的 UI 中将 BLE 附件显示为“未找到”。 If the BLE accessory is then turn-on or the user becomes within BLE range, the app will automatically connect to the BLE accessory.如果 BLE 配件随后开启或用户进入 BLE 范围内,应用程序将自动连接到 BLE 配件。

The issue I am facing is that in iOS 6, if the user does a Settings -> General -> Reset -> Reset All Settings, the next time the app is launched the BLE accessory will have a different CBPeripheral UUID.我面临的问题是,在 iOS 6 中,如果用户执行设置 -> 常规 -> 重置 -> 重置所有设置,下次启动应用程序时,BLE 配件将具有不同的 CBPeripheral UUID。 This causes problems in my App and UI as then two BLE accessories will be displaying: one for the new UUID and one for the old UUID (that the user had connected to in the past but that no longer exists).这会导致我的应用程序和 UI 出现问题,因为将显示两个 BLE 附件:一个用于新的 UUID,另一个用于旧的 UUID(用户过去连接过但不再存在)。

Is there a way for the app to tell if the user has done a "Reset All Settings" so that I can clear my list of connected BLE accessories (UUIDs) that I have saved into preferences?应用程序是否有办法判断用户是否已执行“重置所有设置”,以便我可以清除已保存到首选项中的已连接 BLE 附件 (UUID) 列表?

Or any other ideas of how to deal in this situation?或者关于如何处理这种情况的任何其他想法?

Thanks,谢谢,

Store the UUID's in the Keychain instead of NSUserDefaults.将 UUID 存储在 Keychain 而不是 NSUserDefaults 中。 An app's keychain will be erased when the user performs a Reset All Settings, so either your UUID's will disappear.当用户执行重置所有设置时,应用程序的钥匙串将被删除,因此您的 UUID 将消失。

You could also just store some arbitrary flag in the Keychain, if you really wanted to use NSUserDefaults for the UUID's.如果您真的想将 NSUserDefaults 用于 UUID,您也可以在钥匙串中存储一些任意标志。 In that case, you'd just check if the flag was present in the keychain when your app starts.在这种情况下,您只需在应用程序启动时检查钥匙串中是否存在该标志。 If not, then trash the UUID's and create a new flag.如果没有,则丢弃 UUID 并创建一个新标志。

As adpalumbo suggested, use a Keychain to store your UDID.正如 adpalumbo 建议的那样,使用钥匙串来存储您的 UDID。

This UICkeychain library is a good one and easy-to-use.这个UICkeychain库是一个很好的并且易于使用的库。

Why don't you make a compression statement in every startup that check if the UDID is changed or not and you gotta save the current_udid in sqlite for example and application checks every time once it noticed that something change you can implement what you want ..为什么不在每次启动时都创建一个压缩语句来检查 UDID 是否已更改,并且您必须将 current_udid 保存在例如 sqlite 中,并且应用程序每次一旦注意到某些更改,您就可以实现您想要的内容时进行检查..

hopefully that will help希望这会有所帮助

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

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