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

Universal Links対応をした話

Universal Links対応をした話

iOS 10時代のDeep Link技術
potatotips #40

Chiharu Nameki

May 29, 2017
Tweet

More Decks by Chiharu Nameki

Other Decks in Technology

Transcript

  1. ࣗݾ঺հ ߦ໦ ઍय़ʢͳΊ͖ ͪ͸Δʣ
 ੲ macOS޲͚ΞϓϦɾϛυϧ΢ΣΞ։ൃऀ → ࠓ iOSΞϓϦ։ൃऀ גࣜձࣾαΠόʔΤʔδΣϯτ


    AmebaΞϓϦ୲౰
 Ξϝϒϩͷ౤ߘɾӾཡΞϓϦͰ͢ʂ גࣜձࣾ nana music
 ԻָίϥϘϨʔγϣϯΞϓϦ nana
 Ի੠Τϯδϯ੡࡞ऀ Ի੠ॲཧٕज़͕޷͖Ͱ͢
  2. ΞϓϦ͕ىಈ͢Δ৚݅ • Ϣʔβ͕SafariͰ։͘͜ͱΛબ୒͍ͯ͠ͳ͍ • iOS 9Ҏ߱ • ΞϓϦ͕Πϯετʔϧ͞Ε͍ͯΔ
 ະΠϯετʔϧͷ৔߹ɺૢ࡞தͷΞϓϦͰͦͷ··ભҠ
 ετΞཱ͕͕ͪ͋ͬͨΓ͸͠ͳ͍

    • ಉҰυϝΠϯ಺ͷભҠͰ͸ͳ͍
 ݫີʹ͸εΩʔϚ͕ҟͳΔ৔߹͸ىಈͨ͠
 e.g.) http://hoge.com/ ͔Β https://hoge.com/ ΁ͷભҠ
  3. • Entitlement ͷ Associated Domainsʹapplinks:Λ͚ͭͯυϝΠϯΛهࡌ
 e.g. applinks:example.com • Universal Linksܦ༝ͰΞϓϦ͕։͔Εͨ࣌ʹݺ͹ΕΔϝιουΛ࣮૷


    
 • ѻ͑ͳ͍URL͸open(_:options:completionHandler:)Ͱ։͖௚͢
 ΞϓϦཱ͕͕ͪ͋ͬͨޙɺ͞ΒʹผΞϓϦ͕ىಈ͢ΔͷͰUX্͍·͍ͪɻ
 ͳΔ΂͘ൃੜ͠ͳ͍Α͏ʹ͍ͨ͠ɻ ͓͞Β͍
 ~ ΞϓϦଆͷରԠ ~ func application(application: UIApplication,
 continueUserActivity userActivity: NSUserActivity,
 restorationHandler: ([AnyObject]?) -> Void) -> Bool {}
  4. • AASA (apple-app-site-association) ϑΝΠϧΛ഑ஔ • ϧʔτ·ͨ͸ .well-known αϒσΟϨΫτϦ഑Լʹஔ͘ • HTTPSͰ௚઀ΞΫηεͰ͖ΔΑ͏ʹ͢Δ


    HTTPͰ͸μϝ, ϦμΠϨΫτ΋NG • ΞϓϦͷΠϯετʔϧɺ·ͨ͸Ξοϓσʔτ࣌ʹOSʹऔಘ͞ΕΔ
 αʔόΤϥʔʢ500ܥʣͷ৔߹ɺ3࣌ؒޙʹ࠶औಘ ͓͞Β͍
 ~ αʔόଆͷରԠ ~ https://developer.apple.com/reference/security/shared_web_credentials API Reference: Shared Web Credentials ΑΓ
  5. AASA (apple-app-site-association) ϑΝΠϧ { "applinks": { "apps": [], "details": [

    { "appID": "XXXXXXXXXX.jp.co.hoge.AppName", "paths": [ "NOT /_*", "*" ] }, { "appID": "YYYYYYYYYY.jp.co.choge.AppName-ota", "paths": [ "NOT /_*", "*" ] } ] } } AppIDͷPrefixΛࢦఆ
 ੲͳ͕ΒͷΞϓϦͰ͸
 νʔϜIDͱҟͳΔͷͰ஫ҙ ←
  6. AASAϑΝΠϧͷهड़ํ๏ • details΋path΋ઌ಄͔ΒධՁ͞ΕΔ • Ϛονͨ͠Βͦ͜ͰධՁΛऴྃ • ෳ਺ͷΞϓϦ͕هड़ & Πϯετʔϧ͞Ε͍ͯͨΒɺઌʹॻ͔Εͯ ͍Δํ্ཱ͕͕ͪΔ

    • PathͷϚονϯάϧʔϧ • ΫΤϦ΍ϑϥάϝϯτ͸ର৅ʹͳΒͳ͍ • ? … ೚ҙͷ1จࣈ (/΋OK) • * … ೚ҙͷจࣈྻʢ0จࣈͰ΋/͕͍ࠞͬͯͯ͟΋ྑ͍ʣ • NOT ͸iOS 9.2Ҏ߱ • ࠷ޙͷεϥογϡͷ༗ແ͸Ϛονϯάʹد༩͠ͳ͔ͬͨ ղऍ͸OSόʔδϣϯʹґଘ͢ΔͷͰ஫ҙͯ͠ςετ͢Δ
  7. func open(_ url: URL, options: [String : Any] = [:],

    completionHandler completion: ((Bool) -> Void)? = nil) ΞϓϦ಺͔ΒURLΛUniversal Linksͱͯ͠։͘ʹ͸
 UIApplication ͷ open() ϝιουΛ࢖͏ • ֎෦ΞϓϦͰ։͚͔ͨͲ͏͔ͷ݁Ռ͕औಘͰ͖Δ • ࣗ෼ࣗ਎ͷରԠυϝΠϯͷURLΛ౉͢ͱSafari͕ىಈ͢Δ iOS 10Ҏ߱ iOS 9Ҏલͷ open(_ : URL) -> Bool ͱൺֱ͢Δͱ • ։͚ΔURLͷλΠϓΛUniversal LinksͷΈʹݶఆՄ • ඇಉظʹͳͬͨ
  8. ʮΞϓϦͰ։͘ʯόʔ • SafariͷUI • දࣔ͸ΧελϚΠζෆՄ • දࣔ͞ΕΔ৚݅ • ରԠΞϓϦΛΠϯετʔϧࡁΈ •

    ରԠυϝΠϯΛSafariͰ։͘ઃఆʹ͍ͯ͠Δ • HTMLʹ͸Smart App BannerͳͲͷهड़͸ඞཁͳ͍
  9. iOS 9ͱiOS 10Ͱͷڍಈͷҧ͍ iOS 9 ࠷ॳͷϦΫΤετ͕Universal Linksͷͱ͖ͷΈΞϓϦ͕ىಈ͢Δ
 
 iOS 10

    ϦμΠϨΫτઌ͕Universal Linksͷ৔߹΋ΞϓϦ͕ىಈ͢Δ
 
 ࠷ॳͷϦΫΤετͱϦμΠϨΫτઌ͕ͲͪΒ΋Universal Linksͩͬͨ৔߹ɺ application(application:continueUserActivity:restorationHandler:) ͕2ճݺͼग़͞ΕΔ ϦμΠϨΫτ࣌ͷڍಈ͕ҟͳ͍ͬͯͨ
  10. Appendix: Custom URL Scheme is dead? • URL͕։͚Δ͔Ͳ͏͔Λ֬ೝ͢Δ canOpenURL() ͸iOS

    9Ҏ߱ info.plistʹεΩʔϚͷهࡌ͕ඞཁʹͳͬͨ • iOS 8Ҏલ͸୅ΘΓʹ canOpenURL() ͷݺͼग़͠ճ਺͕50ճʹ੍ݶ͞Ε͍ͯͨ • ࣮ࡍʹΞϓϦΛ։͘ open() ϝιουʹ͸੍ݶ͕ͳ͍ • open()ϝιου͕֎෦ΞϓϦͰ։͘લʹ֬ೝμΠΞϩάΛग़ͯ͘͠ ΕΔΑ͏ʹͳͬͨ े෼ར༻Մೳ