Providing A Failover URL When A Custom URL Scheme Cannot Be Handled - iphone

I have two iPhone apps that I've built that have their own custom URLs and are in the app store. Let's call them App A and App B.
App A's interface is a UIWebView that gets its markup from a remote server that I run. The behavior I want to implement in app A is this:
If a link is generated with the custom URL for App B, and App B is installed on the device, open App B. This is easily done by checking UIApplication canOpenURL: and, if it returns YES, calling UIApplication openURL:.
If a link is generated with the custom URL for App B, and App B is not installed on the device, go to the app store page for App B.
Here is how I plan on handling that second one:
Include a URL parameter in the custom URL that contains the link to the app store page for App B. If canOpenURL: returns NO for the whole URL, open the URL specified by that parameter instead.
That should work. But it feels a bit hacky because it means App A has to know how to parse the custom URL for App B to retrieve the alternate link. That seems to be less-than-ideal encapsulation. Is there some other convention I should be using to provide the failover URL when canOpenURL: returns NO?

Will you always be opening these URLs for AppB from within AppA?
If so, then why do you need to add the link to the App Store page for AppB in the URL?
Why can't AppA already "know" the App Store URL for AppB, and if "canOpenURL" returns NO for the Custom URL Scheme, then it will just send the user to that App Store page?
This seems like a much cleaner solution.
PS: I know this is an old question, but the question has a couple of upvotes, and hasn't been answered, so perhaps this will help someone...

Related

Opening Another Application From My App

this is my first question on the site so if i don't cover anything please let me know and i'll try and fix it :P
I'm trying to make my application load another app from inside the app. An example which i can use to make what I'm trying to do more clear is, I want to load FaceBook from my application without it loading a UIWebView. I would like to do this for Facebook, YouTube, Twitter & Instagram. Also if possible all going to specific areas on the site, so the Facebook profile, YouTube channel, Twitter Page & Instagram profile!
Also I know i would have to write an if statement for it to be, if the user has set application on their device then load in that application else if they don't then load in the web view
You want to use the URL schemes of the other apps. If you know the URL scheme of an app then you can use openUrl: to send a message to another application and bring it to the foreground.
After a quick search you can find some popular app url schemes here along with some examples.
You need to use URL Schemes, this wiki has the major ones listed
http://wiki.akosma.com/IPhone_URL_Schemes

iOS Custom URL Scheme - get source URL

I'm working on an app which launches from a custom url scheme.
I've managed to get the url and its parameters and everything, however, our app launches a web view. we want that when the user clicks a link with this scheme, the same page he is on would open up in our web view (it's needed because other functions run in the background, and allowing the user to keep browsing the website he was on)
Is it even possible to get the location of the clicked url? I know I can get the source application, but is there any way (other than adding the link to the scheme itself as parameters) to get the source link?
Thanks!
If you need information passed in to your application, that information must be somehow represented by in URL itself.
Adding a generic interface for that purpose wouldn't make sense as those URLs could be hosted inside an email message or an SMS, for example.

How to launch iOS app via custom URL and allow to open a webpage if it's not installed?

I'd like to be able to send invitation in an email to a specific "event" happening inside my iOS app. So I figured I'd need to use custom URL. That's fine.
But I'd also like to be able to handle the user that doesn't have the app installed yet, to be taken to a mobile Safari and to the webpage with installation instructions for the app.
What would be the best way to do it?
I could try the following:
In the email I send a link to a http://www.example.com/joinevent/?id=foo
User is taken to a Safari webpage that sends a redirect to mycustomscheme://joinevent/?id=foo
If the user doesn't have the app installed this redirection won't work and he stays in the Safari - I could then handle the displaying of installation instructions probably.
But this approach doesn't seem "natural" for me. Is there a better/more native way to do it?
Try http://rdrct.it
It is a web service that allows you to achieve exactly this functionality very easily.
Full disclosure - I created rdrct.it
Here's the basics:
Login to the site, create a project for your particular app. Choose a unique code (this could be the name of your app).
You'll then be provided with a URL in the form: http://rdrct.it/uniqueCode
Once you've done that, you need to register the app's ID in the app store, and also details about the custom URL scheme. Tick "Auto-redirect" - what it will then do is try to open the app, and if that fails, it will automatically send the user to the app store.
If the app is opened, then the querystring is also passed to the app, so in your example case, the device will have been served: mycustomscheme://joinevent/?id=foo
It also works across multiple device types, so if you have the app available for Blackberry, Android or Windows Phone, then it will also do the same for those depending on which device type the user is using.
Like I said, I created it, but it should solve your problem.
If you are using Distimo to track you app analytics, they provide a shortlink to your apps that can be used also used to track conversions. It shows a custom page depending on the device used to access. This is especially convenient if you have the same app published in the AppStore, Google Play, Amazon, etc.

iPhone: launch app with YouTube URL?

I want to register a custom URL scheme that will enable my app to be launched whenever the user goes to a YouTube URL (http://www.youtube.com/watch?v=VIDEO_IDENTIFIER) in the browser.
Is this possible?
Edit:
After poking around I realized that YouTube's URL scheme is simply youtube://. What I want to do is that whenever there is a call to YouTube with the URL scheme, I want my app to be launched instead of the YouTube app - is this possible? What happens when there are conflicting URL schemes?
URL scheme is the thing preceding ://. It means you can't assign your app to handle youtube urls or any other http urls.
Update
Although Apple mentions YouTube URL Scheme in the docs, in the context of implementing custom URL schemes only the part before :// can be specified.
Update 2
Regarding your updated question. I'm pretty sure Apple wants YouTube app launched for youtube:// URLs. Since I haven't found an explicit note about conflicting URL schemes, I can't tell how the OS chooses an app to launch in general for a custom URL scheme.
As for the URLs handled by the built-in apps, they are very likely to remain so, i.e. it's impossible to override a built-in app and handle an http:// or a youtube:// URL with your own app.
You can do that and it will work on the simulator but the app will never get past the App review process.
On a side note, why would you want to do such thing as redirect youtube urls to your app, it's at least confusing to the user.

How can I add a link to my app on the homescreen

On iphone my native app has an URL, so that if you type an url starting with myapp:// it will open my app and it will handle the URL and go to the relevant place.
Is there a way to get these urls as a web app bookmark on the iphone's homescreen?
EDIT: To put it another way, I want add a webapp to link to my native app.
This is not possible. Never will be, as duplicates may occur then, e.g. two web apps with goatse://…, as Apple cannot check web apps.
It is possible to add Web Clips without going into Safari, and to specify a custom URL. But the Apple docs say that Web Clips will only work if the protocol is http or https (i.e. not my app://)