Safari Extensibility: Content Blocking and Shared Links · is awesome")...

100
© 2015 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. Media #WWDC15 Brian Weinstein Safari and WebKit Engineer Alex Christensen Safari and WebKit Engineer Safari Extensibility: Content Blocking and Shared Links Session 511

Transcript of Safari Extensibility: Content Blocking and Shared Links · is awesome")...

Page 1: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

© 2015 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

Media #WWDC15

Brian Weinstein Safari and WebKit EngineerAlex Christensen Safari and WebKit Engineer

Safari Extensibility: Content Blocking and Shared LinksSession 511

Page 2: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Safari Extensibility

Content BlockersChanges to the Extensions GalleryShared Links App Extensions

What’s new

Page 3: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Safari Extensibility

Content BlockersChanges to the Extensions GalleryShared Links App Extensions

What’s new

Page 4: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Safari Extensibility

Content BlockersChanges to the Extensions GalleryShared Links App Extensions

What’s new

Page 5: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Safari ExtensibilityWhat’s new

Content BlockersChanges to the Extensions GalleryShared Links App Extensions

Page 6: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Content BlockersiOS and OS X

Page 7: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can Do

Page 8: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can Do

Page 9: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoHide an element

Page 10: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoHide an element

Page 11: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can Do

<div id=“links”>…</div>

Hide an element

Page 12: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can Do

<div id=“links”>…</div>

Hide an element

Page 13: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can Do

<div id=“links”>…</div>

Hide an element

Page 14: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoHide an element

"action": { "type": "css-display-none", "selector": "#links" }

Page 15: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoHide an element

"action": { "type": "css-display-none", "selector": "#links" }

Page 16: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoHide an element

"action": { "type": "css-display-none", "selector": "#links" }

Page 17: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoHide an element

"trigger": { "if-domain": ["bigbearsgolfblog.com"], "url-filter": ".*" }

Page 18: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoHide an element

"trigger": { "if-domain": ["bigbearsgolfblog.com"], "url-filter": ".*" }

Page 19: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoHide an element

"trigger": { "if-domain": ["bigbearsgolfblog.com"], "url-filter": ".*" }

Page 20: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoHide an element

{ "action": { "type": "css-display-none", "selector": "#links" }, "trigger": { "if-domain": ["bigbearsgolfblog.com"], "url-filter": ".*" } }

Page 21: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoHide an element

{ "action": { "type": "css-display-none", "selector": "#links" }, "trigger": { "if-domain": ["bigbearsgolfblog.com"], "url-filter": ".*" } }

Page 22: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can Do

{ "action": { "type": "css-display-none", "selector": "#links" }, "trigger": { "if-domain": ["bigbearsgolfblog.com"], "url-filter": ".*" } }

Hide an element

Page 23: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can Do

{ "action": { "type": "css-display-none", "selector": "#links" }, "trigger": { "if-domain": ["bigbearsgolfblog.com"], "url-filter": ".*" } }

Hide an element

Page 24: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can Do

{ "action": { "type": "css-display-none", "selector": "#links" }, "trigger": { "if-domain": ["bigbearsgolfblog.com"], "url-filter": ".*" } }

Hide an element

Page 25: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoHide an element

Page 26: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoHide an element

Page 27: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can Do

Page 28: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can Do

Page 29: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can Do

tracking_script.js — example.com

Page 30: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can Do

Page 31: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can Do

Page 32: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can Do

You’ve been tracked

Page 33: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoBlock a load

"action": { "type": "block" }

Page 34: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoBlock a load

"action": { "type": "block" }

Page 35: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoBlock a load

"trigger": { "url-filter": "tracking_script", "resource-type": ["script"], "load-type": ["third-party"] }

Page 36: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoBlock a load

"trigger": { "url-filter": "tracking_script", "resource-type": ["script"], "load-type": ["third-party"] }

Page 37: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoBlock a load

"trigger": { "url-filter": "tracking_script", "resource-type": ["script"], "load-type": ["third-party"] }

Page 38: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoBlock a load

"trigger": { "url-filter": "tracking_script", "resource-type": ["script"], "load-type": ["third-party"] }

Page 39: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoBlock a load

{ "action": { "type": "block" }, "trigger": { "url-filter": "tracking_script", "resource-type": ["script"], "load-type": ["third-party"] } }

Page 40: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoBlock a load

Page 41: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoBlock a load

Page 42: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoBlock a load

Page 43: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoBlock a load

Page 44: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What Content Blockers Can DoBlock a load

Page 45: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Creating Content Blockers on iOS

Page 46: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Creating Content Blockers on iOS

func beginRequestWithExtensionContext(context: NSExtensionContext) { let item = NSExtensionItem()

let blockerURL = NSBundle.mainBundle().URLForResource("blockerList", withExtension: "json") item.attachments = [ NSItemProvider(contentsOfURL: blockerURL)! ] context.completeRequestReturningItems([ item ], completionHandler: nil) }

Page 47: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Creating Content Blockers on iOS

Introducing Safari View Controller Nob Hill Tuesday 1:30PM

func beginRequestWithExtensionContext(context: NSExtensionContext) { let item = NSExtensionItem()

let blockerURL = NSBundle.mainBundle().URLForResource("blockerList", withExtension: "json") item.attachments = [ NSItemProvider(contentsOfURL: blockerURL)! ] context.completeRequestReturningItems([ item ], completionHandler: nil) }

Page 48: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Management settings in your appAPI in the SafariServices Framework

Updating Content Blockers

Page 49: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Management settings in your appAPI in the SafariServices Framework

Updating Content Blockers

Page 50: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Management settings in your appAPI in the SafariServices Framework

SFContentBlockerManager.reloadContentBlockerWithIdentifier( identifier: String, completionHandler: ((NSError?) -> Void)? )

Updating Content Blockers

Page 51: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

DemoContent Blockers on iOS

Alex ChristensenSafari and WebKit Engineer

Page 52: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Content Blocking on OS X

Brought the same model to the Mac

Page 53: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Content Blocking on OS X

Brought the same model to the MacFaster and more memory efficient

Page 54: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Content Blocking on OS X

Brought the same model to the MacFaster and more memory efficientcanLoad has been deprecated

Page 55: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Content Blocking on OS XExtension Builder

Page 56: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Content Blocking on OS XExtension Builder

Page 57: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Content Blocking on OS XExtension Builder

Page 58: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Content Blocking on OS XJavaScript API

Page 59: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Content Blocking on OS XJavaScript API

safari.extension.setContentBlocker(contentBlocker)

Page 60: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Content Blocking on OS XJavaScript API

safari.extension.setContentBlocker(contentBlocker)

• contentBlocker can either be an object or a JSON string

Page 61: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Content BlockersChanges to the Extensions GalleryShared Links App Extensions

What We Are Going to Talk About

Page 62: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What We Are Going to Talk About

Content BlockersChanges to the Extensions GalleryShared Links App Extensions

Page 63: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Changes to the Extensions Gallery

Page 64: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Safari Extension UpdatesExtensions Gallery

Page 65: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Safari Extension UpdatesExtensions Gallery

Page 66: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Safari Extension UpdatesExtensions Gallery

Page 67: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Safari Extension UpdatesExtensions Gallery

New Extension Guidelines• Extensions will now be signed and hosted by Apple• Please resubmit to the gallery

Page 68: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Safari Extension UpdatesExtensions Gallery

New Extension Guidelines• Extensions will now be signed and hosted by Apple• Please resubmit to the galleryNew flag in update manifest <key>Update From Gallery</key> <true/>

Page 69: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

What We Are Going to Talk About

Content BlockersChanges to the Extensions GalleryShared Links App Extensions

Page 70: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Content BlockersChanges to the Extensions GalleryShared Links App Extensions

What We Are Going to Talk About

Page 71: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Shared Links App ExtensionsiOS and OS X

Page 72: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Shared Links

Page 73: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Shared Links App Extensions

For apps to put their content in Safari’s Shared LinksSame API on iOS and OS X

Page 74: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Shared Links App Extensions

For apps to put their content in Safari’s Shared LinksSame API on iOS and OS X

Page 75: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Creating a Shared Links App Extension

Page 76: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Creating a Shared Links App Extension

let extensionItem = NSExtensionItem()

Page 77: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Creating a Shared Links App Extension

let extensionItem = NSExtensionItem()

Page 78: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Creating a Shared Links App Extension

extensionItem.userInfo = [ "uniqueIdentifier": "A1B2-C3D4"

Page 79: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Creating a Shared Links App Extension

extensionItem.userInfo = [ "uniqueIdentifier": "A1B2-C3D4", "urlString": "http://webkit.org"

Page 80: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Creating a Shared Links App Extension

extensionItem.userInfo = [ "uniqueIdentifier": "A1B2-C3D4", "urlString": "http://webkit.org", "date": NSDate( timeIntervalSinceReferenceDate: 455474512)

Page 81: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Creating a Shared Links App Extension

extensionItem.userInfo = [ "uniqueIdentifier": "A1B2-C3D4", "urlString": "http://webkit.org", "date": NSDate( timeIntervalSinceReferenceDate: 455474512), "displayName": "WebKit News" ]

Page 82: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Creating a Shared Links App Extension

extensionItem.userInfo = [ "uniqueIdentifier": "A1B2-C3D4", "urlString": "http://webkit.org", "date": NSDate( timeIntervalSinceReferenceDate: 455474512), "displayName": "WebKit News" ]

uniqueIdentifier must be consistent across instantiations of the extension

Page 83: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Creating a Shared Links App Extension

extensionItem.userInfo = [ "uniqueIdentifier": "A1B2-C3D4", "urlString": "http://webkit.org", "date": NSDate( timeIntervalSinceReferenceDate: 455474512), "displayName": "WebKit News" ]

uniqueIdentifier must be consistent across instantiations of the extensionIf displayName is not set, Safari falls back to display name of the App Extension

Page 84: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Creating a Shared Links App Extension

extensionItem.attributedTitle = NSAttributedString(string: "WebKit is awesome")

Page 85: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Creating a Shared Links App Extension

extensionItem.attributedTitle = NSAttributedString(string: "WebKit is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Page 86: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Creating a Shared Links App Extension

extensionItem.attributedTitle = NSAttributedString(string: "WebKit is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Page 87: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Creating a Shared Links App Extension

extensionItem.attributedTitle = NSAttributedString(string: "WebKit is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Title and content text will be automatically ellipsized if they are too long

Page 88: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

let bundle = NSBundle.mainBundle() let iconURL = bundle.URLForResource("icon", withExtension: "png") extensionItem.attachments = [ NSItemProvider(contentsOfURL: iconURL )! ]

Creating a Shared Links App Extension

Page 89: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

let bundle = NSBundle.mainBundle() let iconURL = bundle.URLForResource("icon", withExtension: "png") extensionItem.attachments = [ NSItemProvider(contentsOfURL: iconURL )! ]

Creating a Shared Links App Extension

Page 90: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

let bundle = NSBundle.mainBundle() let iconURL = bundle.URLForResource("icon", withExtension: "png") extensionItem.attachments = [ NSItemProvider(contentsOfURL: iconURL )! ]

Icon in top right corner is your app's icon

Creating a Shared Links App Extension

Page 91: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

let bundle = NSBundle.mainBundle() let iconURL = bundle.URLForResource("icon", withExtension: "png") extensionItem.attachments = [ NSItemProvider(contentsOfURL: iconURL )! ]

Icon in top right corner is your app's icon

Creating a Shared Links App Extension

Page 92: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

let bundle = NSBundle.mainBundle() let iconURL = bundle.URLForResource("icon", withExtension: "png") extensionItem.attachments = [ NSItemProvider(contentsOfURL: iconURL )! ]

Icon in top right corner is your app's iconAll properties must be set after userInfo

Creating a Shared Links App Extension

Page 93: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

DemoCreating a Shared Links App Extension

Alex ChristensenSafari and WebKit Engineer

Page 94: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Summary

Write content blockersSubmit your extensions to the Safari Extensions GalleryPut your content in Shared Links

Page 95: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Summary

Write content blockersSubmit your extensions to the Safari Extensions GalleryPut your content in Shared Links

Page 96: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Summary

Write content blockersSubmit your extensions to the Safari Extensions GalleryPut your content in Shared Links

Page 97: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

More Information

Technical SupportApple Developer Forumshttp://developer.apple.com/forums

http://webkit.org/blog/

General InquiriesJon Davis, Web Technologies [email protected]

Page 98: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Related Sessions

Introducing Safari View Controller Nob Hill Tuesday 1:30PM

Using Safari to Deliver and Debug a Responsive Web Design Mission Wednesday 9:00AM

What’s New in Network Extension and VPN Nob Hill Friday 9:00AM

Page 99: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")

Related Labs

Safari and WebKit Lab Graphics, Games, and Media Lab A Friday 12:00PM

Page 100: Safari Extensibility: Content Blocking and Shared Links · is awesome") extensionItem.attributedContentText = NSAttributedString(string: "Here are some reasons why WebKit is awesome.")