Chapter 9. Using Sensors
Mobile phones aren’t just for making phone calls anymore. The iPhone, like a lot of high-end smartphones these days, comes with a number of sensors: camera, accelerometer, GPS module, and digital compass. We’re entering a period of change: more and more users expect these sensors to be integrated into the “application experience.” If your application can make use of them, it probably should.
Hardware Support
Unique among modern mobile platforms, Apple has gone to great lengths to ensure that your code will run on all of the current iOS-based devices. Yet despite this, there is still some variation in hardware between the various models (see Table 9-1).
Hardware features |
iPhone |
iPod touch |
iPad |
iPad 2 | New iPad | iPad Mini | |||||||||||
3G |
3GS |
4 and 4S |
5 |
1st gen |
2nd gen |
3rd gen |
4th gen |
5th gen |
WiFi |
3G |
WiFi |
3G |
WiFi |
3G |
WiFi |
3G | |
Cellular |
✓ |
✓ |
✓ |
✓ |
✗ |
✗ |
✗ |
✗ |
✗ |
✗ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
WiFi |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
Bluetooth |
✓ |
✓ |
✓ |
✓ |
✗ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
Speaker |
✓ |
✓ |
✓ |
✓ |
✗ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
Audio In |
✓ |
✓ |
✓ |
✓ |
✗ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
Accelerometer |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
Magnetometer |
✗ |
✓ |
✓ |
✓ |
✗ |
✗ |
✗ |
✗ |
✗ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
Gyroscope |
✗ |
✗ |
✓ |
✓ |
✗ |
✗ |
✗ |
✓ |
✓ |
✗ |
✗ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
GPS |
✓ |
✓ |
✓ |
✓ |
✗ |
✗ |
✗ |
✗ |
✗ |
✗ |
✓ |
✗ |
✓ |
✗ |
✓ |
✗ |
✓ |
Proximity Sensor |
Get Learning iOS Programming, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.