Suppress Safari can't open the page because the address is invalid? custom app launch

前端 未结 1 359
走了就别回头了
走了就别回头了 2021-02-04 10:43

I\'m launching a custom app from a web browser on the iphone.

If the app is not installed I am redirecting to a web page on the website.

If it is installed it g

相关标签:
1条回答
  • 2021-02-04 11:00

    I did find a solution that worked for this. I had it working with a setTimeout of 25ms. But for some reason on a nexus 5 I needed to drop it down to 5ms.

    i ended up using the following:

        function goToApp(appLocation, fallbackLocation) {
    
            setTimeout(function() {
                window.location = fallbackLocation;
                 }, 5);
           window.location = "nativeappURL://" + appLocation;
        }
    
        function goToWeb(baseurl, webLocation) {
            window.location =baseurl + "/"+ webLocation;
        }
    </script>
    

    Then I just have two buttons that have an

     onclick="goToApp('appDestination', 'location')"
    

    and

     onclick="goToWeb('webDestination', 'location')"
    
    0 讨论(0)
提交回复
热议问题