iOS 9 is the most successful iOS update to date, with Apple reporting that around 52% of all iPhones are now running it. To the surprise of many, a lot of apps began crashing after users updated because of BLE changes in the release.There’s been a couple of changes to the APIs in the latest version that can crash an app. So if you’re building a BLE App, it’s important to know what effect this update has on your iOS App.
We’ve seen and gotten reports of many apps breaking, such as TI’s Multitool App. During the beta, a lot of apps such as those from Garmin, Kevo, Wahoo and Kinetic, and others crashed, some fixed before the public release.Apps that didn’t get tested during the iOS 9 beta are much more likely to crash.
The issue is that the retrievePeripherals: and retrieveConnectedPeripherals methods were deprecated back in iOS 7.0 and were removed completely in iOS 9.0. Apple states that apps that use these methods will crash on launch, or when pairing an accessory, a pretty significant issue (even if the app isn’t using that functionality).
- Use retrievePeripheralsWithIdentifiers: instead of retrievePeripherals:
- Use retrieveConnectedPeripheralsWithServices: instead of retrieveConnectedPeripherals:
Both of these functions were made available starting with iOS 7.0. Thankfully iOS9 is in 52% of devices while iOS8 is in 41%. Earlier devices are just 8%, and most of these are likely iOS7.0. Because of this, there’s little downside to stop using the old functions completely.
So how did this happen? Part of the problem is that Apple has promoted the old API in its best practices guides for developing Bluetooth apps, so unless developers were checking whether the API you were using was deprecated, developers used them. After all, who better than Apple to give the right approach. Unfortunately there’s going to be a lot of developers rushing at the last minute to fix their Apps, as well as a lot of unhappy customers.
So what’s the best way to approach to avoid these kind of issues in the future?
First it’s important to take advantage of the Beta releases from Apple. iOS 9 had several betas that immediately showed the issue, so it could be caught early. The second practice is to really check for any APIs that are deprecated during development. Apple’s documentation is pretty good on specifying any API that shouldn’t be used, even if their guides don’t get updated as often.