Quick and handy iPad version-detection plugin for PhoneGap
Our first idea was browser user agent string detection (like this), right? Simple. Too bad that doesn't actually work. The user agent string ("Mobile/xxxxx") isn't actually consistent. I don't know why, but it just isn't. So in-browser solutions are out. Next we started digging into the PhoneGap API.
PhoneGap core comes with the device API, which is great, but device.name (the most obvious option) for iOS returns the device's custom name. This wasn't useful, since "Hulk" isn't the answer I was looking for. There are ways to get the model name from iOS, but that didn't seem like the best (or even pseudo future proof) way either. I ended up checking for presence of camera to detect iPad 1, and presence of retina display for iPad 3+ and iPhone 4+.
To (hopefully) save some other non-objective-c devs some of the serious headaches I had, I threw it up on Github this morning for public use.
I'm totally open to improving this and making it super useful, so if you have code send me a pull request (I'm a web dev, so I'm guessing my C isn't all that pretty), and ideas are always welcome. Ideas with code are the best though, as we all know.