user3788491
user3788491

Reputation: 99

script popup for android and iOS - for your device exist app, how?

I developed simple android and iOS app. I want when user is in my site (from mobile phone), to popup text with redirect to google play or apple store, "for your device is available android or iOS application".

My question is how to do that? Which script i can put in my website so when user surfing on my website from mobile device to popup information that exist mobile application for his device?

Thank you

Upvotes: 2

Views: 2797

Answers (3)

MBT
MBT

Reputation: 21

For Iphone devices
you need to add this in head <meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL"> affiliate-data and app-argument is optional

For Android Devices
There is no native support for App Banners You need to create yourself banner or use the jquery plugin click here to download

Here is the markup
<head> <!-- copy head --> <meta name="google-play-app" content="app-id=com.adianteventures.adianteapps.feliz_navidapp"> <link rel="stylesheet" href="jquery.smartbanner.css" type="text/css" media="screen"> <!-- end copy head --> </head> <body> ... <!-- copy body --> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script> <script src="jquery.smartbanner.js"></script> <script type="text/javascript"> $().smartbanner(); </script> <!-- end copy body --> </body>

Upvotes: 2

user3788491
user3788491

Reputation: 99

I have this code in my index.html

if((navigator.userAgent.match(/iPhone/i)) ) {
            if (document.cookie.indexOf('iphone_redirect=false') == -1) {
                if (confirm('for your device exist iphone app')) {
                    window.location = 'https://itunes.apple.com/us/app/....';
                }
            }
        }


        var ua = navigator.userAgent.toLowerCase();
        var isAndroid = ua.indexOf('android') > -1;
        if(isAndroid) {
            if (confirm('for your device exist iphone app')) { 
                window.location = 'https://play.google.com/store/apps/details?id=...';
            }
        }

But i don't know how to make cookie to remember my answer. If user click "cancel" or "OK" to remember "cancel" or "OK" until user clean cache.

Do you have idea how to make cookie to remember answer?

Upvotes: 0

Ramnath Suthakar
Ramnath Suthakar

Reputation: 19

The way I would do this, first find the mobile type using mobile agent and base on that will redirect to the correct locations. e.g. putting the java scripts on top of your header page between

<head></head>

<script>
if( /iPhone|iPod/i.test(navigator.userAgent) ) {
window.location = "YOUR apple app url goes here";
} else if( /Android/i.test(navigator.userAgent) ) {
window.location = "YOUR google play app url goes here";
}
</script>

Upvotes: 2

Related Questions