How to use barometer of iPhone6 with new APIs available in iOS 8?

I am looking for, how to use barometer apis which are available in iOS 8 for iPhone6.

I have used following code

if([CMAltimeter isRelativeAltitudeAvailable]){
    CMAltimeter *altimeter = [[CMAltimeter alloc] init];
    [altimeter startRelativeAltitudeUpdatesToQueue:queue withHandler:^(CMAltitudeData *altitudeData, NSError *error) {

        if(error)
            [label setText:[NSString stringWithFormat:@"%@",error.localizedDescription]];
        else
            [label setText:[NSString stringWithFormat:@"%@",altitudeData.relativeAltitude]];

    }];
}
else{
    [label setText:@"That's not iPhone 6 for sure ;)"];
}

But its not working even not returning any error value. It seems like completion block is not working coz my label is not updating. I am testing it on my iPhone 6.

IMHO: When the Block gets executed the object altimeter is already wiped by ARC. Try to make altimeter a property and it will work.

Xcode 6 and iOS 8 Hint at iPhone 6 Barometer & Air Pressure , I am looking for, how to use barometer apis which are available in iOS 8 for iPhone6. I have used following code if([CMAltimeter� With more than 4,000 new APIs, iOS 8 allows developers to further customize the user experience with major extensibility features and robust frameworks such as HealthKit and HomeKit. iPhone 6 and iPhone 6 Plus users also have access to the revolutionary App Store, which offers more than 1.3 million apps to iPhone, iPad® and iPod touch® users

Try to use Swift code example and see the results. I am using this code sniper and it works.

let altimeter = CMAltimeter()
if CMAltimeter.isRelativeAltitudeAvailable() {
    altimeter.startRelativeAltitudeUpdatesToQueue(NSOperationQueue.mainQueue(), withHandler: { data, error in
        if !error {
            println("Relative Altitude: \(data.relativeAltitude)")
        }
    })
}

iOS 8 Shows Evidence of Barometric Sensors in iPhone 6, Xcode 6 and iOS 8 Hint at iPhone 6 Barometer & Air Pressure Sensors updated CoreMotion APIs, which clearly show the new altitude measuring capabilities. Current altitude tracking applications use the iOS Device's existing GPS and Motion chips to New 21.5″ Entry-Level iMac Benchmarks Released [ Geekbench]. Barometer Plus kann für praktisch alle Ihrer Im neuen iPhone 6 und iPhone 6 Plus verbaut Apple nun auch ein Barometer. Der Hersteller gebraucht die Daten momentan ausschließlich in der eigenen Health-App unter iOS 8 , um zurückgelegte. Das iPhone 8 Plus ist dicker, länger, breiter und schwerer geworden als das iPhone 7 Plus.

The question is about Barometric Pressure. Here is Swift 4.2 code to retrieve and display the iPhone 6 pressure readings. Note: I converted the reading result to milibars. Remember to make an entry in the Info.plist file for: Privacy - Motion Usage Description. hth

import UIKit
import CoreMotion

class ViewController: UIViewController
{
        @IBOutlet weak var pressureLabel: UILabel!

        var rawPressure = 999.99
        let altimeter = CMAltimeter()

        override func viewDidLoad()
        {
            super.viewDidLoad()
            getSensorData()
        }

        func getSensorData()
        {
            if CMAltimeter.isRelativeAltitudeAvailable()
            {
                altimeter.startRelativeAltitudeUpdates(to: OperationQueue.main)
                {
                    (data, error) in
                    if !(error != nil)
                    {
                        self.rawPressure = Double(truncating: (data?.pressure)!) * 10.00
                        self.pressureLabel.text = String(format: "%.0f", self.rawPressure)+" mb"
    //                    print("Relative Pressure: \(self.pressureLabel.text ?? "error: 02")")
                    } else {
                        self.pressureLabel.text = " Oops! 😕 1 "
                    }
                }
            }  else {
                self.pressureLabel.text = " Oops! 😕 2 "
            }
        }

    }

Barometer Plus on the App Store, New APIs in iOS 8 reference altitude data. One called “ isRelativeAltitudeAvailable” lets apps know if a device “supports reporting relative� A barometer measures atmospheric pressure at a point, and Evidence of a barometer sensor were found in the iOS 8 SDK, that includes new methods to get altitude data. The methods are a part of the CoreMotion.. Cordova plugin for barometer (iOS iPhone6, iPhone6Plus). iPhone 6 and iPhone 6 Plus have a built in barometer.

iPhone 6 likely to sport barometer/air pressure sensors to measure , It only works on devices that contain a barometer, such as iPhone 6/6s/7/8/X ( including Plus models), iPad Mini 4/Air 2/Pro or later. Barometer� Developers can use CoreMotion APIs that take advantage of M8 and HealthKit to create apps that help you take better care of your health and fitness." Like the regular iPhone 6, the Plus version is equipped with the new 8 MegaPixel iSight camera with improved sensor that now comes with 'Focus Pixels' for faster autofocus in addition to its large

Use Barometer data from iPhone 6 – Strava Support, Current altitude tracking applications use the iOS Device's existing GPS and The barometer will also extensively integrate with iOS 8's new� Older external GPS devices (destined more than a year old using an older API) are now messed up on iOS 8.3. This effects older external GPS devices, or even newer GPS devices that use the broken API to be backwards compatibility for 30 pin iOS devices. iOS 8.4 beta 2 appears to fix this issue with the broken API.

Apple motion coprocessors, With today's announcement that the new iPhone 6's will have a built in Barometer We use a publicly available database of surveyed elevation which is the best that's available right now. reading from the iPhoneyou use the new API call for barometric. George Vargas REV Cycling 1/16/15, 8:46 AM. sep-17-2015: iOS 9, Chrome 45, Opera 32, Firefox 40. Added support for Service Workers. dec-01-2014: Support for iOS 8.1, Chrome 40 beta, Opera 26, Firefox 34 beta, IE11 for Windows Phone 8.1. Added support for Ambient Light Events and Battery Status API. Bug fixed on Opera Mini and Viewport. jun-12-2014: Support for iOS 8 Beta, Chrome, Firefox

Comments
  • What is the value of queue? If it’s not the main queue (and it shouldn’t be), updating your UI from it isn’t going to work.
  • possible duplicate of CMAltimeter callback never fires
  • i have to do in objective c, because the project is already written in objective c
  • Any APIs available to Swift are also available to Objective-C.
  • Try to create test example in separate project to be sure it is not problem with iOS version.
  • Does anyone now how accurate this is?
  • Found exactly what I need. Thank you!