iOS Custom URL Scheme - get source URL - iphone

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.

Related

How to fire an UILongPressGestureRecognizer on a position programmatically

I need to send an UILongPressGestureRecognizer without user interaction on an specific position of an UIWebView. The proyect I'm working on is intended to be uploaded to the AppStore, so the given solution must be "legal".
Thanks.
Have the click on the webpage send a URL to the application when the conditions are met on the webpage. Do a google search on URL schemes (there's quite a few examples) and set up a handler in your app. Use your webpage html/javascript code to detect the long press, and when it happens send the URL scheme. For example, just like you send a "mailto:" url to send an signal to your email app, you use a "myFoobarapp:" url to trigger signals to your app. The application detects the URL scheme and does what you want. Using URL schemes is the approved method of communicating from a web page to your app. Make sure you look at the existing url schemes so the one you pick (i.e., myFoobarapp) isn't already taken.

How to handle navigation within a Facebook page tab application

I am working on a page tab application and am having an issue with navigation. My application, written in MVC3, is displaying and authenticating just fine as a page tab. When I click on my tab, my app receives a POST with the signed_request object as expected.
My question is, how can I support links to other pages in my application? When a user clicks on a link, I want an action to be called in my application and to not leave the Facebook iframe. In addition, I need the signed_request to be passed along so I have a user context.
At first, I thought this was not supported and that all page tab applications had to be written as Single Page Applications. However, I found examples that do exactly what I am looking for.
Click on an image:
https://www.facebook.com/Sephora/app_305927716147259
And:
http://woobox.com/pinterest
How are these apps handling page navigation within the iframe?
The performance of clicking on an image seems to be pretty bad. What are they doing behind the scenes and is there a more direct way of handling navigation?
I will also need to handle POSTs.
Thank you.
When a user clicks on a link, I want an action to be called in my application and to not leave the Facebook iframe.
Well, that’s what normal HTML links do – so no extra effort required at this point :-)
In addition, I need the signed_request to be passed along so I have a user context.
You could pass it as a GET parameter with every link – but this way the user can easily “see” it, and it might also get transfered to external servers (if any external resources are embedded within your page) via the HTTP referrer.
The better solution IMHO is store the signed request server-side in your session (parsed already, if you like), so that you have access to it on the following pages of your app.

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

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...

How to relaunch an app like facebook-ios-sdk does?

Question:
I am actively looking in the source code on Github's facebook-ios-sdk project myself but I was wondering if anyone already knows how to relaunch an app that sent an iPhone user to Safari, such that the user can come back after some work has been finished?
Example:
When using facebook to login, the original app is relaunched after the facebook login page has authenticated the user.
Motivation:
I would like to be able to do the same for youtube videos without having to completely lose the user. I don't want to use the standard webview approach because I don't want to provide extra space to first let the video load for the user and then have the user click the play button. I want to skip the play button and its associated click entirely! Instead I want the user to be able to click on just an everyday regular iPhone button and be shown the video with the navigation for coming back to the app via relaunch.
You need your app to register a "custom URL scheme". Then get the callback in the remote web service to return a URL with that scheme. iOS will then launch your application.
More (somewhat old) info available here.
A list of common custom URL schems on iOS can be found here.
Generally, as part of the OAuth login process, you supply a callback URL as one of the paramaters. What this does, is tell the remote server (YouTube), that on successful authentication, redirect the user to the supplied URL. If YouTube supports this (does it support OAuth?) then on successful user login within safari, youtube will tell users safari to redirect to the supplied url. If this url is a "custom URL scheme" it will cause your app to relaunch and you can handle the situation from there.

Facebook External Widget development with a single app

We're trying to develop a widget that uses Facebook APIs and other websites (e.g different domains) could embed. We do not want every website to create it's on Facebook app but we'd like everyone using this widget to be connected to our Facebook app.
The problem is that Facebook seems to authenticate only a specific domain for an app (Canvas URL).
Ideas?
Guy
Update: I just realized that for Facebook server API as long as I set the redirect_uri to a valid URL (as defined by the site url) then everything is OK. So I can let my widget call the login and set the redirect_uri to some page we hold on our server that will communicate with the origin. So far so good. Now the problem that remains is whether there's a way to do it using the Facebook JS sdk rather then having to invent the wheel. From what I see there I could find a way to make the JS SDK not use the window.location.href. Ideas?
you just need to create the app, then from the profile site of your app there is an link to let users add the app to their page. (this is also possible via a special link (see the docs))
but be aware, one page can only include your app once. so if you like your "customers" to have your app multiple times on the same page you have to create multiple apps but point the canvas and tab url to the same script.
The other way would be to add child applications directly for the user, so you can let your customers even set a customized icon. This is hard to code couse you have to use old apis (newer one doesnt support the functions anymore) and there is none to null documentation for it. (I have such an app running, if you want to see some examples drop me a note)