Accessing the iPhone 6’s Barometer
In case you haven’t heard, Apple released two new iPhone’s last week, the iPhone 6 and the iPhone 6 Plus. Each comes with a host of new features including new Camera upgrades, Apple Pay and iOS 8, to name a few. They also host much larger screen sizes of 4.7” and 5.5” respectively, with better resolutions too. Some older applications may require tweaks to get them looking right. To take advantage of the higher resolutions you will also need to include higher res images with your application. Let us know if you need any assistance with this.
Today we wanted to focus on one of the other new additions to the iPhone 6, the barometer. A barometer is used to measure atmospheric pressure. What this means for the iPhone is that it can now take a baseline of atmospheric pressure and continue to monitor it over time. The first place we are likely to see this technology used is in run tracking apps. Using the initial baseline, applications will be able to access how much higher and lower a user has gone since starting their run and then display that to the user as well as producing more accurate statistics on things like calories burnt.
What the barometer cannot do is work out your actual altitude. On any given day the weather will cause atmospheric pressure to vary and so there is no easy translation from the barometers reading to an absolute value. We came up with a solution though, Google offer an API to return elevation of the ground for a given set of coordinates. The results of this should be more than accurate enough for non-scientific applications. So assuming the user has some form of data signal, this API could be combined with the barometer to give the user real world values, so if they are climbing a mountain an application could actually record it.
Now, the more technical bit for other software developers. The iPhone 6 barometer can be accessed through the CMAltimeter class, which is referenced here. You first need to check whether a barometer is present by using ‘isRelativeAltitudeAvailable’ before then subscribing to altitude updates.