Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Universal Link on iOS

Universal Link on iOS

Tachibana Kaoru

April 27, 2016
Tweet

More Decks by Tachibana Kaoru

Other Decks in Programming

Transcript

  1. Universal Linkͱ͸ from iOS9 » ࣗ෼ͷΞϓϦ΍ଞͷΞϓϦΛىಈ͢ΔεΩʔϜɻ » iOS಺෦ͷʢઃఆͨ͠ʣURL Link͔ΒΞϓϦΛىಈ͢Δ͜ͱ͕Ͱ͖ Δɻ

    » ࠓ·ͰͷΧελϜURLεΩʔϜΛ͓͖͔͑Δػೳɻ » URL Schemeͷ৔߹ʹ͸ͦΕͧΕͷΞϓϦ͕޷͖ͳ΋ͷΛઃఆͰ͖Δ ͷͰɺΞϓϦؒͷॏෳͷةݥੑ͕͕͋ͬͨɺUniversal Linkͷ৔߹ʹ ͸ɺDomain໊ʹґଘ͢ΔͨΊɺҰҙੑ͕୲อͰ͖Δɻ
  2. Smart App Bannerͱͷҧ͍ » Universal Link͸ɺSmart App Bannerͱ͸໨త͕ҟͳΔͨΊɺ྆ ํ࣮૷͢Δඞཁ͕͋Γ·͢ɻ »

    Smart App BannerͰ͸ɺΞϓϦ͕Πϯετʔϧ͞Ε͍ͯͨΒΞϓϦ ͕ىಈ͞ΕɺΞϓϦ͕Πϯετʔϧ͞Ε͍ͯͳ͔ͬͨΒApp Store͕ ىಈ͢Δɻ <meta name="apple-itunes-app" content="app-id=400435286, app-argument=https://asajikan.jp/topics/">
  3. Smart App BannerͱUniversal LinkͷӅΕ ͨؔ܎ » Smart App Bannerͷcontentͷapp-argumentࢦఆ͕Universal LinkʹରԠ͍ͯ͠Δ͔Ͳ͏͔ͰUI͕มΘΔɻʢԼهͷϦϯΫΛ

    Mobile SafariͰνΣοΫͯ͠Έ͍ͯͩ͘͞ʣ » https://asajikan.jp/ (Universal LinkରԠ) » https://asajikan.jp/topics/ (Universal LinkඇରԠ)
  4. ࣮૷ํ๏ (Server) » server root(/)ʹ apple-app-site-association ͱ͍͏໊শͰjson ϑΥʔϚοτͷઃఆϑΝΠϧΛஔ͘ɻ » ʢ͜ͷϑΝΠϧʹॺ໊Λ͔͚Δඞཁ͕͋Δͱ͍͏৘ใ͕͚͋ͬͨ

    Ͳɺ͔͚Δඞཁ͸͋Γ·ͤΜɻʣ » iOS9.3.1Ҏ্Ͱ͸ɺapple-app-site-associationͷϑΝΠϧαΠζ ͸128KBʹ੍ݶ͞Εͯ·͢ɻ(9.3Ͱൃੜ͍ͯͨ͠ΫϥογϡͷݪҼ ͩͬͨΒ͍͠)
  5. apple-app-site-association format » Bundle IdentifierͱUniversal LinkʹରԠ͍ͤͨ͞pathΛهड़ɻ { "applinks": { "apps":

    [], "details": [ { "appID": "9JA89QQLNQ.com.apple.wwdc", "paths": [ "/wwdc/news/", "/videos/wwdc/2015/*"] }, { "appID": "ABCD1234.com.apple.wwdc", "paths": [ "*" ] } ] } }
  6. ࣮૷ํ๏ (Server) » ઃఆϑΝΠϧͷஔ͖৔ॴ͸ɺ9.3͔Β /.well-known/ ΋αϙʔτ͢Δ Α͏ʹͳΓ·ͨ͠ɻ » Technical Q&A

    QA1919 » Incoming requests for /.well-known/apple-app-site- association file https://developer.apple.com/library/ios/qa/qa1919/ index.html#//appleref/doc/uid/DTS40016874
  7. apple-app-site-association format asajikan.jpͷݱࡏͷઃఆ { "applinks": { "apps": [], "details": [

    { "appID": "94VJUJ8B7P.jp.asajikan.www", "paths": [ "/", "/article/*", "/recipe/*" ] } ] } }
  8. apple-app-site-association format » ?͕Ұจࣈɺ*͕ෳ਺จࣈ » NOTΛ࢖ͬͯର৅֎pathͷઃఆ΋Ͱ͖Δ͕ɺݹ͍iOSͰ͸ඇରԠ ʢ9.2.1Ͱ͸OKɺ9.1Ͱ͸NGʣ » "paths": [

    "/wwdc/news/", "NOT /videos/wwdc/2010/", "/ videos/wwdc/201?/"] » ͜͏͢Δͱɺwwdc/201*/ҎԼͷϑΝΠϧ͸wwdc/2010Λͷ͍ͧ ͯUniversal LinkରԠͱͳΔɻ
  9. func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void)

    -> Bool{ if userActivity.activityType == "com.apple.corespotlightitem" { // Core SearchͷॲཧΛهड़ } else if userActivity.activityType == NSUserActivityTypeBrowsingWeb { let url : NSURL? = userActivity.webpageURL // Universal LinkͷॲཧΛهड़ } return true }
  10. ·ͱΊ » Web Site࿈ܞΞϓϦ͸Universal Linkಋೖ͢΂͖ » Smart App Banner΋࿈ܞͤ͞Δͱϕλʔ »

    Universal LinkରԠpath͸ࡉ͔͘ઃఆͰ͖Δ͕ɺiOSͷόʔδϣϯ ʹΑͬͯಈ࡞͕ҟͳΔ͜ͱʹ஫ҙ