Search APIs & Universal Links
-
Upload
yusuke-kita -
Category
Technology
-
view
2.407 -
download
1
Transcript of Search APIs & Universal Links
![Page 1: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/1.jpg)
Search APIs & Universal LinksMercari Inc.
@kitasuke
![Page 2: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/2.jpg)
About me
![Page 3: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/3.jpg)
Mercari
![Page 4: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/4.jpg)
My works
→ Cardio -Simple HealthKit wrapper for workout app in watchOS 2-
→ PagingMenuController -Paging view controller with customizable menu-
→ GoogleMaterialIconFont -Google Material Design Icons for Swift and ObjC-
![Page 5: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/5.jpg)
My future talks
→ Introducing new features for watchOS 2@MOSA software meeting
![Page 6: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/6.jpg)
Search API
![Page 7: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/7.jpg)
Completely New Search Experience
![Page 8: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/8.jpg)
App results appear in Spotlight and Safari even
app not installed
![Page 9: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/9.jpg)
![Page 10: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/10.jpg)
Rich contents with powerful action
![Page 11: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/11.jpg)
![Page 12: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/12.jpg)
Universal and Seamless experience
![Page 13: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/13.jpg)
![Page 14: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/14.jpg)
How it works
![Page 15: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/15.jpg)
Index contents via Search APIs
![Page 16: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/16.jpg)
What to index?
![Page 17: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/17.jpg)
Index Architecture
![Page 18: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/18.jpg)
On-Device index
![Page 19: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/19.jpg)
Apple's cloud index
![Page 20: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/20.jpg)
Let's see in-depth features!
![Page 21: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/21.jpg)
3 Search APIs
![Page 22: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/22.jpg)
![Page 23: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/23.jpg)
NSUserActivity
![Page 24: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/24.jpg)
App Search
→ Activities can be designated as searchable→ Add indexable metadata
→ Results in Spotlight and Safari→ Revisit activity on Search selection
![Page 25: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/25.jpg)
Enable Capabilities
var eligibleForHandoff: Boolvar eligibleForSearch: Boolvar eligibleForPublicIndexing: Bool
![Page 26: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/26.jpg)
Provide Attributes and Keywords
var title: String?var keywords: Set<String>var contentAttributeSet: CSSearchableItemAttributeSet?var expirationDate: NSDate
![Page 27: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/27.jpg)
Restoring on the Web
var webpageURL: NSURL?
![Page 28: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/28.jpg)
Create Activity
var activity: NSUserActivity = NSUserActivity(activityType: "com.example")
activity.title = "Baked Potato Chips"activity.userInfo = ["id": "http://www.example.com/recipe/111"]
activity.eligibleForSearch = trueactivity.eligibleForPublicIndexing = trueactivity.becomeCurrent()
![Page 29: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/29.jpg)
![Page 30: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/30.jpg)
Continue Activity
func application(UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: [AnyObject]? -> Void) -> Bool { if userActivity.activityType == "com.example" { // Restore state for userActivity and userInfo } return true}
![Page 31: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/31.jpg)
Public Indexing
→ Activities can be designated as public→ Multiple users engage with device results
→ Popular public results available to other users→ Results in Search and Safari (if URL included)
![Page 32: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/32.jpg)
Public vs Private
→ Designated "public" if searchable activity fields are solely public
→ Provisions to prevent user-specific activities from being indexed
![Page 33: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/33.jpg)
Additional Benefits
![Page 34: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/34.jpg)
Handoff
![Page 35: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/35.jpg)
Siri suggestions
![Page 36: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/36.jpg)
CoreSpotlight
![Page 37: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/37.jpg)
CoreSpotlight
→ For any app content→ Methods to add, update and delete items→ Used by Messages, Mail, Calendar and Notes
![Page 38: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/38.jpg)
![Page 39: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/39.jpg)
Create item// Create attributeSet and populate with metadatalet attributeSet = CSSearchableItemAttributeSet(itemContentType: kUTTypeImage as String)
attributeSet.title = "Haleakala Sunrise"attributeSet.contentDescription = "May 12, 2015 Maui, Hawaii"
// Create item with unique identifier, domainIdentifier used to group itemslet item = CSSearchableItem(UniqueIdentifier: "1", domainIdentifier: "album-1", attributeSet: attributeSet)
![Page 40: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/40.jpg)
Index item
// Index itemCSSearchableIndex.defaultSearchableIndex().indexSearchableItems([item]) { error in if error != nil { print("Item indexed!") }}
![Page 41: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/41.jpg)
Restore
// Application delegate called when CoreSpotlight result is tappedfunc application(UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: [AnyObject]? -> Void) -> Bool { if userActivity.activityType == CSSearchableItemActionType { let uniqueIdentifier = userActivity.userInfo? [CSSearchableItemActivityIdentifier] as? String // Use 'uniqueIdentifier' } return true }
![Page 42: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/42.jpg)
Update
// Same method as adding item to indexfunc indexSearchableItems(items: [CSSearchableItem], completionHandler: ((NSError?) -> Void)?)
![Page 43: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/43.jpg)
Delete
// Identifiersfunc deleteSearchableItemsWithIdentifiers(identifiers: [String], completionHandler: ((NSError?) -> Void)?)
identifiers = ["1", "4", "5"]
![Page 44: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/44.jpg)
Delete
// DomainIdentifierfunc deleteSearchableItemsWithDomainIdentifiers(DomainIdentifiers: [String], completionHandler: ((NSError?) -> Void)?)
domainIdentifiers = ["domain-2"]
![Page 45: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/45.jpg)
Delete// Allfunc deleteAllSearchableItemsWithCompletionHandler(completionHandler: ((NSError?) -> Void)?)
![Page 46: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/46.jpg)
Web Markup
![Page 47: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/47.jpg)
Indexing Web Content
→ The content driving your app may live on the web, not locally inside the app
→ Deep linked pages from your app's website are indexed for app search
![Page 48: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/48.jpg)
Applebot finds deep links from the web
![Page 49: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/49.jpg)
![Page 50: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/50.jpg)
Enabling app search
1. Allow Apple to discover and index your app's website
2. Ensure your app's website contains markup for mobile deep links
3. Enable deep link handling for your app4. Add markup for structured data (optional, but
highly recommended)
![Page 51: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/51.jpg)
![Page 52: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/52.jpg)
Smart App Bannersif app is not installed, Safari prompts the user
<meta name="myApp" content="app-id=123, app-argument=https://example.com/about affiliate-date=optionalAffiliateData">
app-argument is passed to application(_:openURL:sourceApplication:annotation:), and is
also used to index your app
![Page 53: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/53.jpg)
Deep Linking
→ Universal linkhttps://developer.apple.com/videos/wwdc/2014/?
include=101#101→ Custom URL scheme
apple://wwdc/2014/?include=101#101
![Page 54: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/54.jpg)
Universal links advantages
→ Unique→ Secure→ Flexible
→ Work seamlessly across app and website
![Page 55: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/55.jpg)
Support Universal Link in your server
→ Create your apple-app-site-association file→ Generate an SSL certification
→ Sign your file→ Upload to your server
![Page 56: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/56.jpg)
Support Universal Link in your app
func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]!) -> Void) -> Bool
var webpageURL: NSURL?var activityType: Stringlet NSUserActivityTypeBrowsingWeb: Stringclass NSURLComponents: NSObject
![Page 57: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/57.jpg)
Configure your associated domains
![Page 58: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/58.jpg)
Other deep link schemesTwitter Cards
<meta name="twitter:app:name:iphone" content="myAppName"><meta name="twitter:app:id:iphone" content="myAppID"><meta name="twitter:app:url:iphone" content="myURL">
Facebook's App Links
<meta name="al:ios:app_name" content="myAppName"><meta name="al:ios:app_store_id" content="myAppID"><meta name="al:ios:url" content="myURL">
![Page 59: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/59.jpg)
Support deep linking
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool { // In this example, the URL is http://example.com/profile/?123 guard let component = NSURLComponents(URL: url, resolvingAgainstBaseURL: true), let path = component.path, let query = component.query else { return false }
if path == "/profile" { // Pass the profile ID from the URL, to the view controller return profileViewController.loadProfile(query) } return false}
![Page 60: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/60.jpg)
Rich Results
→ Go beyond just a title and description→ Results can contain images, structured data, and
even actions→ Rich results are more engaging to users and can
improve your ranking
![Page 61: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/61.jpg)
Other deep link schemesOpen Graph
<meta property="og:image" content="http://example.com/hello.jpg"><meta property="og:audio" content="http://example.com/music.m4a"><meta property="og:video" content="http://example.com/cats.mp4">
schema.org JSON-LD
<script type="application/ld+json">{ "@context": "http://schema.org", "@type": "AggregateRating", "ratingValue": "4", "reviewCount": "250"}</script>
![Page 62: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/62.jpg)
![Page 63: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/63.jpg)
Supported schemas
→ AggregateRating→ Offers
→ PriceRange→ InteractionCount→ Organization
→ Recipe
![Page 64: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/64.jpg)
App Search API Validation Tool
Test your webpage for iOS 9 Search APIs. Enter a URL and Applebot will crawl your webpage and show
how you can optimize for best results.https://search.developer.apple.com/appsearch-
validation-tool/
![Page 65: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/65.jpg)
Improve Ranking
![Page 66: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/66.jpg)
Relevance
![Page 67: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/67.jpg)
Linking 3 APIs
![Page 68: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/68.jpg)
Linking 2 APIs
![Page 69: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/69.jpg)
Relevance score
![Page 70: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/70.jpg)
User Experience
![Page 71: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/71.jpg)
Descriptive Results
![Page 72: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/72.jpg)
Richer results have better satisfaction and engagement
→ Thumbnail, well-structured description, ratings, and actions
→ Relevant and applealing image→ Key information user is looking for
![Page 73: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/73.jpg)
Keywords associate your result with queries
→ Typical items should have 3 to 5 keywords→ Category keywords, e.g., "ticket" or "recipe"→ Synonyms or abbreviations for item subject
![Page 74: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/74.jpg)
UI Behavior on App Launch
![Page 75: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/75.jpg)
Speed
Time from tapping a search result to the content in your app is measured and used in ranking.
![Page 76: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/76.jpg)
Data protection
Pay attention to the appropriate data protection level for your user's content.
![Page 77: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/77.jpg)
Common FAQs
![Page 78: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/78.jpg)
Not showing in the search results
→ Try using different keywords→ In the case of Web Markup, results will only show
up after the page has been crawled by Applebot, and once a certain level of relevance has been
attained
![Page 79: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/79.jpg)
Supported devices?
App Search is available with iOS9, However, the search functionality of NSUserActivity and
CoreSpotlight are not supported on the iPhone 4s, iPad 2, iPad (3rd generation), iPad mini, and iPod
touch (5th generation).
![Page 80: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/80.jpg)
Available on OS X?
CoreSpotlight and the search functionality of NSUserActivity are not supported. However, web
search results may be shown.
![Page 81: Search APIs & Universal Links](https://reader034.fdocuments.in/reader034/viewer/2022042908/58f2f5621a28ab52198b4585/html5/thumbnails/81.jpg)
ReferencesIntroducing Search APIs
Seamless Linking to Your AppiOS Search API Best Practices and FAQs