1

I want to make a link in an email, that opens my app, if the app is installed. If it isn't installed, I want it to open either google play or Appstore depending on the phone people use. If they are on a desktop pc / anything else than android and IOS, it should open another normal weblink.

How is this possible?

Nikolai Hvid
  • 29
  • 1
  • 5
  • This may help you http://stackoverflow.com/questions/34942269/downloadmanager-illegalstateexception-creating-a-download-in-directory-downloads/34942270#34942270 – Divyang Panchal Oct 10 '16 at 12:25
  • I'd suggest u use 2 different buttons for botht he playstore and the appstore. So you wont need to fiddle with external websides detecting the device the consumer is on – Niqql Oct 11 '16 at 08:57

1 Answers1

0

Detect the user agent first, then according to that navigate the user to different locations. here is the simple javascript code which you can add up in your site, then give the site url in the email. Hope this help.

//Useragent detection from http://stackoverflow.com/questions/21741841/detecting-ios-android-operating-system
        function getMobileOperatingSystem() {
          var userAgent = navigator.userAgent || navigator.vendor || window.opera;

              // Windows Phone must come first because its UA also contains "Android"
            if (/windows phone/i.test(userAgent)) {
                //Code here for windows phone.
            }

            if (/android/i.test(userAgent)) {
                window.location = 'https://play.google.com/store/apps/details?id=YOUR_APPLICTION_ID';
            }

            // iOS detection from: http://stackoverflow.com/a/9039885/177710
            if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
               //Code here for itunes. 
            }

           //Code to navigation for your website.
        }

Opening apps in Android needs specific URI implementation in android, then you can redirect the users to that URI to open your application.

Aimanzaki
  • 566
  • 6
  • 9
  • Problem is, it is for an HTML email, so Javascript is probably not a possibility? – Nikolai Hvid Oct 11 '16 at 06:54
  • create a simple page that holds that javascript, Redirect your user to that page using href in html. From there you can decide which user agent it is. – Aimanzaki Mar 21 '17 at 04:49