2

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.

pulkitsinghal
  • 3,855
  • 13
  • 45
  • 84
  • Does it really open Safari, or does it open a simple `UIWebView`? – tilo Jan 26 '12 at 16:45
  • When I look at it running on my iPhone, the swap effect that takes place indicates to me that it is Safari, because as far as I know that effect is reserved for a new app launching while the current goes into background. So no not a simple UIWebView. – pulkitsinghal Jan 26 '12 at 17:06

1 Answers1

4

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.

Damien
  • 2,421
  • 22
  • 38
  • The procedure for registering the "custom URL scheme" was well defined for facebook-ios-sdk as well so thanks for confirming the process. But could you shed more light on the key topic, which is: "get the callback in the remote web service to return a URL with that scheme" ... (1) how can Safari be told to do that? Or (2) the YouTube app for that matter, although I don't have high hopes from the YouTube app itself. Note: I'm asking how I can pass to safari some data via some param that the Safari app knows to use as a callback method or as the value for its existing callback method. – pulkitsinghal Jan 26 '12 at 18:14
  • 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. – Damien Jan 26 '12 at 18:45
  • @pulkitsinghal Please vote on my answer if you feel its the correct one. – Damien Jan 26 '12 at 20:36
  • I'll be sure to do that once the I have confirmed the answer given. Right now you've given really good input on the OAuth login process and the use of callback URL with YouTube (the exact url argument name is missing though). But the Q is not how to authN with YouTube, rather its more along the lines of how to finish the video and then come back. – pulkitsinghal Jan 29 '12 at 19:22