How can a user open my iOS/Android app from my website when my app is already installed on his iOS/Android device?

WhiteHorse7 0 Zuverlässigkeitspunkte
2026-07-28T22:42:08.16+00:00

I have created a QR code with Adobe Express and I used my domain for the QR code. I want that the user gets redirected to my Apple App Store/Google Play Store product page when he scans my QR code with his iOS/Android device when my app is not installed on his device. But when my app is already installed on his device then I want that my app is opened on the user's device when he scans my QR code.

The following code is executed on my website when the user scans my QR code but my app is not opened when the app is already installed on the iOS/Android device.

What is wrong with the code? Is it necessary to add something in my Visual Studio iOS/Android project settings so that my app gets opened on the user's device after scanning my QR code?

<script>
    (function() {
        
        const CONFIG = {
            
            appSchema: "nameofmyapp://app",
  
            
            playStore: "https://play.google.com/store/apps/details?id=com.company.nameofmyapp“,
            appStore: "https://apps.apple.com/app/id…“,   
            desktopFallback: "https://www.xxx.com"
        };

        const userAgent = navigator.userAgent || navigator.vendor || window.opera;
        let redirectUrl = CONFIG.desktopFallback;
        let isMobile = false;

        
        if (/android/i.test(userAgent)) {
            redirectUrl = CONFIG.playStore;
            isMobile = true;
        } else if ((/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) || (/Macintosh/.test(userAgent) && navigator.maxTouchPoints && navigator.maxTouchPoints > 1 && !window.MSStream)) {
            redirectUrl = CONFIG.appStore;
            isMobile = true;
        }

        
        if (isMobile) {
            
            window.location.href = CONFIG.appSchema;

            
            setTimeout(function() {
                window.location.href = redirectUrl;
            }, 1500);
        } else {
            
            window.location.href = redirectUrl;
        }
    })();
</script>

Entwicklertechnologien | .NET | Andere
Entwicklertechnologien | .NET | Andere

Microsoft-Technologien, die auf dem .NET-Softwareframework basieren. Verschiedene Themen, die nicht in bestimmte Kategorien passen.


1 Antwort

Sortieren nach: Am hilfreichsten
  1. Ercan Bozzkurt 0 Zuverlässigkeitspunkte
    2026-07-29T00:49:57.21+00:00

    <script>

    (function() {
    
        
    
        const CONFIG = {
    
            
    
            appSchema: "nameofmyapp://app",
    
    
    
            
    
            playStore: "https://play.google.com/store/apps/details?id=com.company.nameofmyapp“,
    
            appStore: "https://apps.apple.com/app/id…“,   
    
            desktopFallback: "https://www.xxx.com"
    
        };
    
        const userAgent = navigator.userAgent || navigator.vendor || window.opera;
    
        let redirectUrl = CONFIG.desktopFallback;
    
        let isMobile = false;
    
        
    
        if (/android/i.test(userAgent)) {
    
            redirectUrl = CONFIG.playStore;
    
            isMobile = true;
    
        } else if ((/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) || (/Macintosh/.test(userAgent) && navigator.maxTouchPoints && navigator.maxTouchPoints > 1 && !window.MSStream)) {
    
            redirectUrl = CONFIG.appStore;
    
            isMobile = true;
    
        }
    
        
    
        if (isMobile) {
    
            
    
            window.location.href = CONFIG.appSchema;
    
            
    
            setTimeout(function() {
    
                window.location.href = redirectUrl;
    
            }, 1500);
    
        } else {
    
            
    
            window.location.href = redirectUrl;
    
        }
    
    })();
    

    </script>

    War diese Antwort hilfreich?

    0 Kommentare Keine Kommentare

Ihre Antwort

Antworten können von Fragestellenden als „Angenommen“ und von Moderierenden als „Empfohlen“ gekennzeichnet werden, wodurch Benutzende wissen, dass diese Antwort das Problem des Fragestellenden gelöst hat.