Reputation: 595
I send emails to my iOS customers with links to our app. When they tap the link, I want to check if they have the app installed.
If the app is installed I want to open it. If not it will redirect to download the app in the App Store.
The URL I'm using to open the app is:
rva://store?uuid=EFBBD9FF-3976-4816-8B77-C1462C99E256
And the check I was using is:
def responds_to_url?(url)
response = Net::HTTP.get_response(URI(url)).code
if response == "200"
return true
else
false
end
end
The problem is that passing my URL above to URI() returns a Generic (capital G) URI object, whereas it should (if it were http) return an HTTP object.
How can I do a similar check with just a link (i.e. no javascript)?
I thought about passing the URL to Mobile Safari and seeing if it responds, but I don't know how to do that or even if it's possible.
Upvotes: 0
Views: 674
Reputation: 2685
What you describe is not possible. Your rails app will have very limited knowledge of the client—mostly in the form of the User Agent—and there is no way for your Rails app to query for more information while handling a request.
Upvotes: 0
Reputation: 86
You could do client browser detection with HTTP_USER_AGENT, I believe there is a gem for that: Rails Browser Detection Methods
Upvotes: 1