Question

As an user of a mechanical compass, I noticed that the heading that the magnetometer delivers, is often off by 45 degrees or more, although the calibration display did not appear in that cases.

If I test, or use my app outdoors, I ever calibrate the magnetometer when my compass view comes up. This works, it seems that this is necessary.

I don't want to show the users of my app an inaccurate heading, when it is possible to achieve an more or less accurate one, by performig a frequent calibration with the figure eight motion.

Does anybody know a solution to force the display of the magnetometer calibration view, every time my compass view comes up?

I searched all(?) posts here, only one person had a similar idea, but without an answer.

Was it helpful?

Solution

I'm afraid there's no way to do this - whilst the API allows you to dismiss the calibration view (using the dismissHeadingCalibrationDisplay call) to prevent it from interrupting your app's interface, there's no way to force a calibration to start. I'd suggest filing a feature request with Apple if you think it's something that might be useful.

OTHER TIPS

I dont think there is any api for that in ios6 and below :(

    - (BOOL)locationManagerShouldDisplayHeadingCalibration:(CLLocationManager
*)manager {
        if(!manager.heading) return YES; // Got nothing, We can assume we got to calibrate.
        else if( manager.heading.headingAccuracy < 0 ) return YES; // 0 means invalid heading, need to calibrate
        else if( manager.heading.headingAccuracy > 5 )return YES; // 5 degrees is a small value correct for my needs, too.
        else return NO; // All is good. Compass is precise enough.
    }

Font: Compass calibration objective-c

Grab a fridge magnet and move it at around top of your iPhone's screen. You may also need to rotate your iPhone on a few axis at the same time; be creative.

Be aware that to fool the magnetometer again with a magnet, you may need to allow it to reset itself to the Earth magnetic field. You do this by rotating the iPhone over all axis.

I had a bug which occurred after the calibration screen disappeared again. The above method allowed me to force it to appear at will within 10 seconds or so.

Some additional information: When the calibration screen appears AppDelegate's applicationWillResignActive is called. Then when it's done: applicationDidBecomeActive. (My bug: I only restarted my motion manager in applicationWillEnterForeground, not in applicationDidBecomeActive.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top