1

Say I create some custom iOS url: customurl

In my rails controller

redirect_to "customurl://"

produces at runtime:

ERROR URI::InvalidURIError: bad URI(absolute but no path): customurl:// 

When I append some arbitrary path the redirect is successful.

redirect_to "customurl://w"

(User must now accept the page load, as opposed to a seamless redirect, which is undesirable).

Anyone have a solution to redirect to a custom url without some arbitrary path?

Thanks.

gr8scott06
  • 903
  • 1
  • 11
  • 20

1 Answers1

2

custom:// is not a URI. You must have something after that or otherwise it's not saying to go anywhere. Try going to http://. That work? No, it's not a URI. Same principle here.

EDIT:

Apple does some strange stuff so you have to do something with JavaScript. That is not actually a valid URI, Safari just detects it and launches the app.

Community
  • 1
  • 1
hunterboerner
  • 1,264
  • 1
  • 11
  • 25
  • Thanks for your response. Entering "customurl://" into a mobile browser as shown [here](http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html) with the associated app installed produces the desired effect. Can this functionality be produced using rails' redirect_to? – gr8scott06 Mar 26 '14 at 00:39
  • Yes, have you tried using that piece of JS? Rails can't tell the browser to go to anything non URI but JS simply edits the text field for safari which then interprets it. – hunterboerner Mar 26 '14 at 00:40
  • Right I can accomplish it using JavaScript like [this](http://stackoverflow.com/questions/9688319/how-to-redirect-from-mobile-safari-to-native-ios-app-like-quora). Any way to keep it railsey. – gr8scott06 Mar 26 '14 at 00:42
  • Sorry, but there is no railsey way – hunterboerner Mar 26 '14 at 00:44