Firebaseで解決するAndroidの機種依存 / Firebase solve android device difference

Dcdd84d8d73255508b38a4a04e6c2f68?s=47 gyamoto
December 18, 2018

Firebaseで解決するAndroidの機種依存 / Firebase solve android device difference

Dcdd84d8d73255508b38a4a04e6c2f68?s=128

gyamoto

December 18, 2018
Tweet

Transcript

  1. FirebaseͰղܾ͢Δ Androidͷػछґଘ Kohei Yamamoto

  2. Kohei Yamamoto • ࣾձਓ4೥໨ͷAndroidΤϯδχΞ • ઈࢍDroidKaigi2019ͷൃද४උத • teamLabͰಇ͍͍ͯ·͢ • GitHubɿgyamoto

    • Twitterɿfarundorl
  3. Androidͷػछґଘ

  4. ࠓճग़ձͬͨػछґଘ Bluetooth Low Energy (BLE) ͷΞυόλΠζΛ͓͜ͳ͏ͱɺ ग़ྗڧ౓[db]ͱΞυόλΠζִؒ[Hz]͕ػछʹΑͬͯҟͳΔ

  5. Example: startAdvertising // val bleAdvertiser: BluetoothLeAdvertiser bleAdvertiser.startAdvertising( AdvertiseSettings.Builder() .setTxPowerLevel(ADVERTISE_TX_POWER_MEDIUM) .setAdvertiseMode(ADVERTISE_MODE_BALANCED)

    .setConnectable(true) .build(), AdvertiseData.Builder() .build(), callback )
  6. Example: startAdvertising // val bleAdvertiser: BluetoothLeAdvertiser bleAdvertiser.startAdvertising( AdvertiseSettings.Builder() .setTxPowerLevel(ADVERTISE_TX_POWER_MEDIUM) .setAdvertiseMode(ADVERTISE_MODE_BALANCED)

    .setConnectable(true) .build(), AdvertiseData.Builder() .build(), callback ) ग़ྗڧ౓Λ High, Medium, Low, UltraLow ͔Βઃఆ
  7. Example: startAdvertising // val bleAdvertiser: BluetoothLeAdvertiser bleAdvertiser.startAdvertising( AdvertiseSettings.Builder() .setTxPowerLevel(ADVERTISE_TX_POWER_MEDIUM) .setAdvertiseMode(ADVERTISE_MODE_BALANCED)

    .setConnectable(true) .build(), AdvertiseData.Builder() .build(), callback ) ΞυόλΠζִؒΛ LowLatency, Balanced, LowPower ͔Βઃఆ
  8. BLEͷڧ౓ͱִ͕ؒػछґଘ • Xperiaܥ: ग़ྗ͕ऑ͍ • Galaxyܥ: ग़ྗΛ্͛ͳ͍ͱΞυόλΠζִ͕ؒ҆ఆ͠ͳ͍ • Huaweiܥ: ΞυόλΠζִ͕ؒ҆ఆͯ͠ͳ͍


    ※ Huaweiܥ͸ࠓճͷํ๏Ͱ͸ղܾͰ͖ͳ͔ͬͨ
  9. ػछґଘͷݏͳͱ͜Ζ ઃఆ͸ಉ͕ͩ͡ɺػछʹΑͬͯ࠷దͳग़ྗڧ౓ͱΞυόλΠζ ִ͔ؒΒ཭Εͯ͠·͏ʢͱͯ΋ͭΒ͍ʣ ↓↓↓ ػछ͝ͱʹઃఆ͍͚ͨ͠ͲϋʔυίʔσΟϯά͸ͨ͘͠ͳ͍ɻ
 Firebase UserProperty & RemoteConfigͰύϥϝʔλઃఆ

  10. Firebase
 UserProperty & RemoteConfig

  11. Firebase UserProperty • ݴޠ΍஍ҬͳͲϢʔβʔ૚Λࣔ͢ଐੑΛઃఆͰ͖ΔϓϩύςΟ • RemoteConfigͳͲFirebaseͷଞαʔϏεͰϢʔβ൑ఆͷ
 ϑΟϧλϦϯάͱͯ͠࢖͑Δ • ϓϩδΣΫτ͝ͱʹ25ݸ·ͰઃఆͰ͖Δ

  12. Firebase RemoteConfig • ؅ཧը໘Ͱઃఆͨ͠஋Λ഑৴͢Δ࢓૊Έ • ΞϓϦ͔Βઃఆ͞Εͨ஋Λऔಘͯ͠ӬଓԽɺࢀরͰ͖Δ • ΞϓϦΛߋ৽ͤͣʹύϥϝʔλͷมߋ΍A/BςετΛ࣮ݱ
 ͢ΔͨΊͷσʔλιʔε

  13. UserProperty x RemoteConfig 1. ػछΛಛఆͰ͖Δ୺຤৘ใΛUserPropertyʹઃఆ 2. UserProperty͔Βػछ͝ͱͷ஋ΛRemoteConfigʹઃఆ 3. RemoteConfigʹΑͬͯΞϓϦͷৼΔ෣͍͕มΘΔΑ͏࣮૷

  14. 1. ػछ৘ใΛUserPropertyʹઃఆ val analytics = FirebaseAnalytics.getInstance(context) // ୺຤໊(ྫ: Pixel 3,

    SOV34, SC-01F, SHV39) analytics.setUserProperty("device_model", Build.MODEL) // ੡଄ऀ໊(ྫ: Google, Sony, samsung, SHARP) analytics.setUserProperty(“device_manufacturer", Build.MANUFACTURER)
  15. 2. ػछ͝ͱͷ஋ΛRemoteConfigʹઃఆ

  16. 3. RemoteConfigʹΑͬͯৼΔ෣͍Λม͑Δ val config = FirebaseRemoteConfig.getInstance() init { // ύϥϝʔλ͝ͱʹσϑΥϧτ஋Λઃఆ

    config.setDefaults( "advertise_power" to ADVERTISE_TX_POWER_MEDIUM.toLong(), "advertise_mode" to ADVERTISE_MODE_BALANCED.toLong() ) }
  17. 3. RemoteConfigʹΑͬͯৼΔ෣͍Λม͑Δ val config = FirebaseRemoteConfig.getInstance() // ઃఆ͞Εͨ஋ͷϑΣονɺ༗ޮԽ fun fetch()

    { config.fetch(cacheExpiration).addOnSuccessListener { config.activateFetched() } } val advertisePower: Int get() = config.getLong("advertise_power").toInt() val advertiseMode: Int get() = config.getLong("advertise_mode").toInt()
  18. 3. RemoteConfigʹΑͬͯৼΔ෣͍Λม͑Δ // RemoteConfigͷ஋Λࢀর͢ΔΑ͏ʹஔ͖׵͑ bleAdvertiser.startAdvertising( AdvertiseSettings.Builder() .setTxPowerLevel(advertisePower) .setAdvertiseMode(advertiseMode) .setConnectable(true) .build(),

    AdvertiseData.Builder() .build(), callback ) ϋʔυίʔσΟϯάɺΞϓϦͷߋ৽Λͤͣʹػछґଘʹཱͪ޲͔͏
  19. FirebaseͰղܾ͢ΔAndroidͷػछґଘ 1. ػछΛಛఆͰ͖Δ୺຤৘ใΛUserPropertyʹઃఆ 2. UserProperty͔Βػछ͝ͱͷ஋ΛRemoteConfigʹઃఆ 3. RemoteConfigʹΑͬͯΞϓϦͷৼΔ෣͍͕มΘΔΑ͏࣮૷