Today I came across a PhoneGap problem that had me racking my brains for hours. Not sure if anyone has had the same problem?
The app I’m working on needs to work on both iOS and Android, and also Blackberry OS at a later date. After some time debugging and Googling, it turns out, PhoneGap has a different Javascript, dependant on the platform. For some reason, this isn’t very well documented.
PhoneGap build also has limitations, in that you cannot specify a set of files to build for a specific platform. Whatever you upload, gets built for all platforms.
The only solution is to check what platform the device is, and then load the correct platforms PhoneGap.
<script type=”text/javascript” charset=”utf-8″>
var ua = navigator.userAgent;
var platform = {
iphone: ua.match(/(iPhone|iPod|iPad)/),
android: ua.match(/Android/)
};if (platform.android) {
document.write(‘<script src=”phonegap_android_1_2_0.js”><\/script>’);
} else if (platform.iphone) {
document.write(‘<script src=”phonegap_ios_1_2_0.js”><\/script>’);
}
</script>
Hopefully this will save someone else hours of debugging.