mikemeli
mikemeli

Reputation: 725

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. 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". If the BLE accessory is then turn-on or the user becomes within BLE range, the app will automatically connect to the BLE accessory.

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. 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).

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?

Or any other ideas of how to deal in this situation?

Thanks,

Upvotes: 2

Views: 333

Answers (3)

Sreejith
Sreejith

Reputation: 1355

As adpalumbo suggested, use a Keychain to store your UDID.

This UICkeychain library is a good one and easy-to-use.

Upvotes: 1

mustafa96m
mustafa96m

Reputation: 337

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 ..

hopefully that will help

Upvotes: -1

adpalumbo
adpalumbo

Reputation: 3031

Store the UUID's in the Keychain instead of NSUserDefaults. An app's keychain will be erased when the user performs a Reset All Settings, so either your UUID's will disappear.

You could also just store some arbitrary flag in the Keychain, if you really wanted to use NSUserDefaults for the UUID's. 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.

Upvotes: 1

Related Questions