Rails: redirect_to 'myapp://' to call iOS app from mobile safari

前端 未结 1 465
野的像风
野的像风 2020-12-10 10:01

I have a native iOS app that can be called from Mobile Safari in iOS via myiosapp://. I also have a simple Rails app that SHOULD redirect to the native app when

相关标签:
1条回答
  • 2020-12-10 10:39

    Turns out there's a simple solution that is enough for the context of my app as of the moment. I just needed to handle the redirect in javascript. Other solutions are still welcome. :)

    <html><head>
        <script type="text/javascript">
          var userAgent = window.navigator.userAgent;
          if (userAgent.match(/iPad/i) || userAgent.match(/iPhone/i)) {
            window.location = "myiosapp://"
          }
        </script>
      </head>
      <body>
        Some html page
      </body>
    </html>
    
    0 讨论(0)
提交回复
热议问题