Giter VIP home page Giter VIP logo

ios-safariview-example's Introduction

ios-safariview-example

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.

Screenshot

Allow custom URL scheme invocations

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.

Allow backwards compatibility

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.

How to test (callback via URL scheme)

  • 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

License

MIT License.

Last Updated: September 1, 2016

ios-safariview-example's People

Contributors

freedomofkeima avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.