This repository contains an example of SFSafariViewController for iOS 9 and up in Objective-C. This repository is mainly created because there is no proper documentation on how to pass data between Safari and your native apps in Objective-C.
By using this example, you will learn how to:
- Open your web content via SFSafariViewController directly
- Implement a callback when "Done" button is pressed via
safariViewControllerDidFinish
(normal way) - Invoke a callback via custom URL scheme (e.g.: redirection) & NSNotificationCenter
- Allow backwards compatibility with iOS 8 and below (of course, without this functionality)
As a reference, this repository is inspired from mackuba/SafariAutoLoginTest. In addition to seamless auto-login, one of the other motivation in using this technique is to support certificate sharing between native apps which are not signed under same publishers.
You need to configure the value of LSApplicationQueriesSchemes
and URL types
in your Info.plist
. In this example, it's already provided so you don't need to change anything.
In order to use lower deployment target (e.g.: iOS 8.1) safely, you need to change the binary which is linked from Required
to Optional
.
-
Clone this project
-
In your website, use the following example code to redirect your client to
freedomofkeima://?ThisIsResponseSample
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Refresh" content="3; URL='freedomofkeima://?ThisIsResponseSample'">
</head>
<body>
</body>
</html>
-
Add your
url_endpoint
here -
Open this project in Xcode and run it
MIT License.
Last Updated: September 1, 2016