kSecAttrAccessibleAlways deprecated in ios 9

2019-04-15 14:55发布

问题:

I use keychain to authenticate and then send location info to server in background.

But since kSecAttrAccessibleAlways got depricated, I will have to use kSecAttrAccessibleAfterFirstUnlock. This allows use of keychain after first unlock after restarting phone.

Problem is if user restarts phone, and location changes before first unlock, then Authenticate will fail, since we can't fetch from keychain.

How can I solve this problem. How to find keychain cannot be accessed and stop authentication process.

Thanks.

回答1:

How would your app ever be running before the user first unlocks the device and launches it?

BTW, according to the latest docs, kSecAttrAccessibleAlways isn't deprecated. Maybe I'm missing something....



回答2:

This depends on your exact setup. For example, VoIP and region monitoring can auto launch the app before first unlock. Apple Watch enabled apps can start the phone app from background before the phone's first unlock. However, all other services including background fetch will not activate after restart of the phone until the user first enters their passcode so you are safe for those scenarios. But for region monitoring, a solution could be to change the functionality so that the user has to open the app once after first unlock to authenticate and send information to server. For example, cache the location data in the background and then when the user opens the app have it continue with the intended functionality.