

You just call UIApplications, openURL method and iOS will switch away from your app and over to Safari. And your first option is to simply delegate the responsibility of showing web content to Safari itself.
APPLE 2015 WWDC CODE
We're going to talk about how you can use either Safari or Safari View Controller to get a better experience for your users and to give you less code to write. I don't want to wire up my own back and forward buttons, then the rest of this talk is for you. But if you've have been sitting here thinking: I don't need that flexibility, I don't want to evaluate JavaScript against the page. So for web content that's in your app that you own, you control, or you're customizing, WKWebView is the right tool for the job.Īnd in iOS 9 and OS X El Capitan we've given you more flexibility than ever before.

And because the property, the store on your configuration is writable you can replace it with a configuration that's non-persistent which is exactly how you'd go about implementing private browsing. It's a read/write property on your web view's WKWebViewConfiguration.Īnd with the data store you can remove data by its type or you can do something like remove all data that was added in the last hour, which is pretty cool. We've also added a new API to manage the data that is stored by websites like cookies and caches and other stuff. And if you like, you can set your own customUserAgent string. RICKY MONDELLO: You can also loadData, say literal HTML string that you wanted this way. And new on iOS 9 and OS X El Capitan we've heard your feedback and we've incorporated some of the pieces of WKWebView that were missing.įirst and foremost, you can securely loadFileURLs now. Back, forward buttons, communicate progress, et cetera. And it's up to you to add your own user interface. You can modify navigations or outright block them. You load a page into it, you can evaluate JavaScript and get a result from that JavaScript against the current page. It was introduced in iOS 8 and OS X Yosemite, and basically it's just a rectangle around web content. If you're using web content within your app but in a way that doesn't look like a traditional web browser you might be using WKWebView or UIWebView, but WKWebView is the preferred tool to do this it's your friend. We're going to see how both Safari and Safari View Controller can add years of features and polish to your applications.īut before we do that I want to touch on that other use case real quick. This session is primarily focused on the second use case. When a user taps a link in your app and you want to show them a view that's kind of like Safari, so they can do some short-term browsing. It's not when a user is browsing on a website. The important part, is that it's not content that looks like a traditional web browser. It's content that you own or content that you're giving a special presentation to.

The first bucket is content within your app that just happens to be written in HTML, JavaScript, and CSS. And web content comes in all sorts of different shapes and sizes, but for today's discussion I'm going to lump it into two different buckets. At the center of this topic is web content. And to give your users features that they already love from Safari. RICKY MONDELLO: I'm going to show you how you can use either Safari or the new Safari View Controller to give you more time to focus on the parts of your app that are special to your app. Yes, my name is Ricky Mondello, I'm an engineer on the Safari and WebKit team, and my goal for the next half hour is to get all of you out of the business of writing those miniature web browsers. Not that many.īut how many of you have a miniature web browser that's within your application that you show whenever a user taps on - oh my God, all the hands are up.

And of all of those apps that you've built or you're thinking about building, how many of them are a dedicated web browser? Okay.
APPLE 2015 WWDC HOW TO
And how many of you are just learning how to write iOS, Mac, or Watch apps now and just getting started? A few of you. Welcome, you're at the right place, it's WWDC. Please raise your hand if you have an app that's currently being distributed on one of the App Stores. Before we get started I just want to get a little feel for the crowd.
