Is there a simple way to notify iOS users about your app when they visit your website? While I know how to detect user agents and write JavaScript, I'm curious if there is an existing library for this purpose.
In the absence of such a solution, are there any effective methods to inform our users about our app, allow them to download it, and ensure that they don't see the message again if they have already downloaded or closed the dialog?
UPDATE: I previously used a method for detecting iPhone and iPad devices, but it seemed intrusive to the user experience. Therefore, I am searching for more lightweight alternatives.
/**
* Function to determine if the device is an iPhone
*
* @version $Revision: 0.1
*/
puc.isIphone = function(){
return (
(navigator.platform.indexOf("iPhone") != -1) ||
(navigator.platform.indexOf("iPod") != -1)
);
}//end
/**
* Function to determine if the device is an iPad
*
* @version $Revision: 0.1
*/
puc.isIpad = function(){
return (navigator.platform.indexOf("iPad") != -1);
}//end
/**
* Function to check for mobile browsers and provide an option to view a different site
*
* @access public
*/
puc.mobile = function() {
if (puc.isIphone() || puc.isIpad()) {
// Add link to remove cookie
$('#copyright').append('<p><a id="remove-iphone-cookie">Reset Mobile Preferences</a></p>');
// Allow Deleting of the cookie
$('#remove-iphone-cookie').click(function() {
$.cookie('use_mobile', null);
alert('Preferences have been reset.');
return false;
});
if ($.cookie('use_mobile') == null) {
var conf = confirm('Would you like to download the PUC Mobile iOS app?');
if (conf) {
document.location = 'http://itunes.apple.com/us/app/puc/id424617272?mt=8&ls=1';
$.cookie('use_mobile', 'true');
} else {
// Never ask them again, unless they empty their cookies
$.cookie('use_mobile', 'false');
}
}//end
}//end if mobile
}//end mobile