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

Universal Links対応をした話

Universal Links対応をした話

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

4ef794bdea63fc6153845bb26bac38a2?s=128

Chiharu Nameki

May 29, 2017
Tweet

Transcript

  1. Universal LinksରԠΛͨ͠࿩ iOS 10࣌୅ͷDeep Linkٕज़ 2017/5/24 potatotips #40 @ Rettyגࣜձࣾ

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


    AmebaΞϓϦ୲౰
 Ξϝϒϩͷ౤ߘɾӾཡΞϓϦͰ͢ʂ גࣜձࣾ nana music
 ԻָίϥϘϨʔγϣϯΞϓϦ nana
 Ի੠Τϯδϯ੡࡞ऀ Ի੠ॲཧٕज़͕޷͖Ͱ͢
  3. Ϟνϕʔγϣϯ • Universal Links͸iOS 9Ҏ߱ͷػೳ • iOS 10͕ීٴͨ͠ࠓɺαʔϏεʹಋೖ͠΍͘͢ͳͬͨ • ࣮ࡍʹରԠͯ͠ಘΒΕͨ஌ݟʢൃද౰࣌ͷ৘ใ͔ΒͷΞοϓσʔ

    τͳͲʣΛ·ͱΊΔ
  4. ͓͞Β͍
 ~ Ϣʔβࢹ఺ͰݟͨUniversal Links ~ HTTP·ͨ͸HTTPSͷϦϯΫΛλοϓͨ࣌͠ʹ
 υϝΠϯʹରԠ͢ΔΞϓϦ͕ىಈ͢Δ

  5. Universal Linksܦ༝ͰΞϓϦ͕։͍ͨ࣌ͷεςʔλεόʔ SafariͰදࣔ
 ʢࠓޙ΋SafariͰ։͘Α͏ʹͳΔʣ ભҠݩΞϓϦʹ໭Δ

  6. SafariͰදࣔ࣌ʹԼʹҾͬுΔͱ
 ΞϓϦͰ։ͨ͘Ίͷόʔ͕ग़ݱ ʮ։͘ʯΛબͿͱ࠶ͼΞϓϦͰ։͘Α͏ʹͳΔ ͜ͷखॱʹΑΓɺΞϓϦͰ։͔͘SafariͰ։͔͘͸Ϣʔβ͕બ୒Մೳ ʢਖ਼௚Θ͔Γʹ͍͘ʣ

  7. ΞϓϦ͕ىಈ͢Δ৚݅ • Ϣʔβ͕SafariͰ։͘͜ͱΛબ୒͍ͯ͠ͳ͍ • iOS 9Ҏ߱ • ΞϓϦ͕Πϯετʔϧ͞Ε͍ͯΔ
 ະΠϯετʔϧͷ৔߹ɺૢ࡞தͷΞϓϦͰͦͷ··ભҠ
 ετΞཱ͕͕ͪ͋ͬͨΓ͸͠ͳ͍

    • ಉҰυϝΠϯ಺ͷભҠͰ͸ͳ͍
 ݫີʹ͸εΩʔϚ͕ҟͳΔ৔߹͸ىಈͨ͠
 e.g.) http://hoge.com/ ͔Β https://hoge.com/ ΁ͷભҠ
  8. • 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 {}
  9. • 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 ΑΓ
  10. 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ͱҟͳΔͷͰ஫ҙ ←
  11. AASAϑΝΠϧͷهड़ํ๏ • details΋path΋ઌ಄͔ΒධՁ͞ΕΔ • Ϛονͨ͠Βͦ͜ͰධՁΛऴྃ • ෳ਺ͷΞϓϦ͕هड़ & Πϯετʔϧ͞Ε͍ͯͨΒɺઌʹॻ͔Εͯ ͍Δํ্ཱ͕͕ͪΔ

    • PathͷϚονϯάϧʔϧ • ΫΤϦ΍ϑϥάϝϯτ͸ର৅ʹͳΒͳ͍ • ? … ೚ҙͷ1จࣈ (/΋OK) • * … ೚ҙͷจࣈྻʢ0จࣈͰ΋/͕͍ࠞͬͯͯ͟΋ྑ͍ʣ • NOT ͸iOS 9.2Ҏ߱ • ࠷ޙͷεϥογϡͷ༗ແ͸Ϛονϯάʹد༩͠ͳ͔ͬͨ ղऍ͸OSόʔδϣϯʹґଘ͢ΔͷͰ஫ҙͯ͠ςετ͢Δ
  12. 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ͷΈʹݶఆՄ • ඇಉظʹͳͬͨ
  13. open()ϝιουΛݺͿͱ
 ֎෦ΞϓϦͰ։͘લʹ
 ֬ೝμΠΞϩάΛग़ͯ͘͠ΕΔΑ͏ʹͳͬͨ

  14. ʮΞϓϦͰ։͘ʯόʔ • SafariͷUI • දࣔ͸ΧελϚΠζෆՄ • දࣔ͞ΕΔ৚݅ • ରԠΞϓϦΛΠϯετʔϧࡁΈ •

    ରԠυϝΠϯΛSafariͰ։͘ઃఆʹ͍ͯ͠Δ • HTMLʹ͸Smart App BannerͳͲͷهड़͸ඞཁͳ͍
  15. ਪଌɿiOS͕࣮ࡍʹԿΛ͍ͯ͠Δ͔ • iOS୺຤্ʹυϝΠϯ - ΞϓϦͷϚοϐϯά৘ใ͕ଘࡏ • ΞϓϦͷΠϯετʔϧ/Ξοϓσʔτ࣌ʹϚοϐϯά৘ใΛߋ৽ • URLΛ։͘ࡍɺURLͷυϝΠϯʹରԠΞϓϦ͕ଘࡏͨ͠ΒΞϓϦͰ ։͘

    ΄΅୺຤্ͷॲཧͰ੒Γཱ͍ͬͯΔػೳ
  16. iOS 9ͱiOS 10Ͱͷڍಈͷҧ͍ iOS 9 ࠷ॳͷϦΫΤετ͕Universal Linksͷͱ͖ͷΈΞϓϦ͕ىಈ͢Δ
 
 iOS 10

    ϦμΠϨΫτઌ͕Universal Linksͷ৔߹΋ΞϓϦ͕ىಈ͢Δ
 
 ࠷ॳͷϦΫΤετͱϦμΠϨΫτઌ͕ͲͪΒ΋Universal Linksͩͬͨ৔߹ɺ application(application:continueUserActivity:restorationHandler:) ͕2ճݺͼग़͞ΕΔ ϦμΠϨΫτ࣌ͷڍಈ͕ҟͳ͍ͬͯͨ
  17. ςετํ๏ʢӡ༻લʣ • STGͰٕज़ݕূ • ຊ൪ʹAASAϑΝΠϧΛ഑ஔͯ͠ςετ
 STGͷURL͸GoogleͳͲʹΠϯσοΫε͞Ε͍ͯͳ͍ͨΊ
 Ϣʔβମݧ͕Ͳ͏มΘΔ͔ͷݕূʹ͸ຊ൪Λ࢖͏ඞཁ͕͋Δ • AASAϑΝΠϧʹ͸υϝΠϯґଘͷ৘ใ͕ͳ͍ͨΊɺSTGͱຊ൪Ͱ ಉ͡ϑΝΠϧΛར༻Մೳ

    • ΞϓϦͷ Associated Domains Λ؀ڥʹΑͬͯॻ͖׵͑Δ
  18. ςετํ๏ʢӡ༻ޙʣ ϢʔβମݧͷݕূͷͨΊʹຊ൪ͷAASAϑΝΠϧΛߋ৽ʁʂ
 … ͢ΔΘ͚ʹ͸͍͔ͳ͍ ϓϩΩγΛར༻͢ΔͳͲͯ͠ϧʔςΟϯάΛ޻෉ host
 ॻ͖׵͑ proxy ຊ൪ IP:

    xxxxxxx
 ࣾ಺͔ΒͷΈݟ͑Δ
 ຊ൪؀ڥ
  19. ӡ༻্ͷ՝୊ • ػೳΛ੾Γ໭ͨ͠ΓɺڍಈΛมߋ͢Δʹ͸
 ΞϓϦͷΞοϓσʔτ͕ඞཁ
 
 AASAϑΝΠϧΛߋ৽ͯ͠΋ɺΞϓϦͷΞοϓσʔτͷλΠϛϯάͰ͔͠औಘ͠ʹདྷ ͯ͘Εͳ͍ • ΞϓϦόʔδϣϯͱAASAϑΝΠϧͷ੔߹ੑͷอͪํ •

    ϦϑΝϥͳͲྲྀೖݩͷ৘ใ͕औಘͰ͖ͳ͍ͨΊɺSEOͷ؍఺ͰࠔΔ
  20. Ϣʔβͷ൓Ԡ • ͍͖ͳΓΞϓϦ͕։͘Α͏ʹͳͬͯ͏͍͟ • ݩʹ໭͍ͨ͠ͱ͍͏໰͍߹Θ͕ͤདྷͨ
 ˠ ૢ࡞ํ๏ΛҊ಺ Ή΍ΈʹΞϓϦ͕։͘ͷ͸ετϨε
 
 αʔϏεͷՁ஋Λຊ౰ʹߴΊΒΕ


    Ϣʔβʹ΋ೲಘײͷ͋Δ৔ॴͰ࢖Θͳ͍ͱ͍͚ͳ͍
  21. Appendix: Custom URL Scheme is dead? • URL͕։͚Δ͔Ͳ͏͔Λ֬ೝ͢Δ canOpenURL() ͸iOS

    9Ҏ߱ info.plistʹεΩʔϚͷهࡌ͕ඞཁʹͳͬͨ • iOS 8Ҏલ͸୅ΘΓʹ canOpenURL() ͷݺͼग़͠ճ਺͕50ճʹ੍ݶ͞Ε͍ͯͨ • ࣮ࡍʹΞϓϦΛ։͘ open() ϝιουʹ͸੍ݶ͕ͳ͍ • open()ϝιου͕֎෦ΞϓϦͰ։͘લʹ֬ೝμΠΞϩάΛग़ͯ͘͠ ΕΔΑ͏ʹͳͬͨ े෼ར༻Մೳ
  22. ΧελϜεΩʔϚ࠷େͷ໰୊఺ ΞϓϦ͕Πϯετʔϧ͞Ε͍ͯͳ͍ͱ
 SafariͰʮϖʔδΛͻΒ͚·ͤΜʯΤϥʔ͕දࣔ͞ΕΔ ެ։͞Ε͍ͯΔWeb໘ʹ࢖͏ͷ͸ݫ͍͠
 
 ΞϓϦؒભҠͰར༻͢Δ෼ʹ͸
 open()ϝιουͰΤϥʔϋϯυϦϯάͰ͖ΔͷͰྑͦ͞͏

  23. ॴײ ศརͦ͏੍͕ͩݶ͕ଟ͘ɺ࢖͍ॴ͕೉͍͠

  24. ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠

  25. WWDC 2017ʹࢀՃ͠·͢ Ͱ͖ͨͯͷApple ParkʹߦͬͯΈ͍ͨ

  26. ࠂ஌ɿCyberAgentͰલޙʹΠϕϯτΛ։࠵͠·͢ WWDC௚લ Pre-WWDC Gathering
 https://cyberagent.connpass.com/event/55235/
 5/30 19:30~
 ौ୩ϓϥΠϜϓϥβ4F Creative Lounge

    WWDCޙ CA.swift #3 WWDC 2017 Reporting
 6/19 ϙςν #41ʹ֎Εͯ͠·ͬͨΒੋඇ