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

アプリへの導線の増やし方.pdf

PKPK-Carnage
December 24, 2019

 アプリへの導線の増やし方.pdf

PKPK-Carnage

December 24, 2019
Tweet

More Decks by PKPK-Carnage

Other Decks in Programming

Transcript

  1. About me • Tomosuke Okada • iOSྺ3೥ • ອըͷΞϓϦΛ࡞ͬͯ·͢ •

    SNS • Qiita → @fr0g_fr0g • Github → Frog-Frog • Twitter → @fr0g_fr0g • μϒϧϑϩοά
  2. 10

  3. 13 struct Movie { /// өըݻ༗ͷࣝผ൪߸ let id = 0

    /// ໊લ let title = "εύΠμʔϚϯ" /// ͋Β͢͡ let summary = "ฏຌͳগ೥ɺϐʔλʔɾύʔΧʔ͸์ࣹೳԚછ͞Εͨ஖ᥨʹט·Εͨ͜ͱͰɺ௒ਓతͳ ೳྗΛಘͯ͠·͏ɾɾɾ" /// ը૾ let thumbnail = UIImage(named: "spider") /// ໾ऀ໊ͷ഑ྻ let actorNames = ["τϏʔɾϚάϫΠΞ", "ΩϧεςΟϯɾμϯετ", "δΣʔϜζɾϑϥϯί"] }
  4. 14 import Foundation import CoreSpotlight import MobileCoreServices final class SpotlightManager

    { func save(_ movie: Movie) { let attributeSet = CSSearchableItemAttributeSet(itemContentType: kUTTypeData as String) // ᶃλΠτϧ attributeSet.title = movie.title // ᶄઆ໌จ attributeSet.contentDescription = movie.summary // ᶅը૾ attributeSet.thumbnailData = movie.thumbnail?.pngData() // Ωʔϫʔυʢදࣔ͞Εͳ͍͕ɺλΠτϧ΍આ໌จʹೖͬͯͳ͍จݴΛ͜͜ʹೖΕ͓͚ͯ͹ɺݕࡧͨ࣌͠ʹҾ͔͔ͬΔΑ͏ʹͳΔʣ attributeSet.keywords = movie.actorNames /* uniqueIdentifier͸AppDelegateͰऔΓग़͢͜ͱ͕Ͱ͖ΔͷͰɺ Spotlightݕࡧܦ༝ͰΞϓϦΛ։͍ͨ࣌ͷͨΊͷURLεΩʔϜΛೖΕ͓ͯ͘ */ let item = CSSearchableItem( uniqueIdentifier: "my-app://open/movie?id=\(movie.id)", domainIdentifier: "my-app", attributeSet: attributeSet ) CSSearchableIndex.default().indexSearchableItems([item], completionHandler: nil) } }
  5. 15

  6. 16

  7. 18 import CoreSpotlight extension AppDelegate { func application(_ application: UIApplication,

    continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { // SpotlightͰ։͔Ε͔ͨͲ͏͔ΛνΣοΫ͢Δ switch userActivity.activityType { case CSSearchableItemActionType: return self.openApplicationFromSpotlight(userActivity) default: return false } } private func openApplicationFromSpotlight(_ userActivity: NSUserActivity) -> Bool { // userActivity͔ΒURLεΩʔϜΛऔಘ͢Δ guard let urlScheme = userActivity.userInfo?[CSSearchableItemActivityIdentifier] as? String else { return false } // URLεΩʔϜΛ։͍ͨ࣌ͷॲཧΛ࣮૷͢Δ return true } }
  8. 32

  9. 35