Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

Androidͷػछґଘ

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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 )

Slide 6

Slide 6 text

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 ͔Βઃఆ

Slide 7

Slide 7 text

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 ͔Βઃఆ

Slide 8

Slide 8 text

BLEͷڧ౓ͱִ͕ؒػछґଘ • Xperiaܥ: ग़ྗ͕ऑ͍ • Galaxyܥ: ग़ྗΛ্͛ͳ͍ͱΞυόλΠζִ͕ؒ҆ఆ͠ͳ͍ • Huaweiܥ: ΞυόλΠζִ͕ؒ҆ఆͯ͠ͳ͍
 ※ Huaweiܥ͸ࠓճͷํ๏Ͱ͸ղܾͰ͖ͳ͔ͬͨ

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

Firebase
 UserProperty & RemoteConfig

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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)

Slide 15

Slide 15 text

2. ػछ͝ͱͷ஋ΛRemoteConfigʹઃఆ

Slide 16

Slide 16 text

3. RemoteConfigʹΑͬͯৼΔ෣͍Λม͑Δ val config = FirebaseRemoteConfig.getInstance() init { // ύϥϝʔλ͝ͱʹσϑΥϧτ஋Λઃఆ config.setDefaults( "advertise_power" to ADVERTISE_TX_POWER_MEDIUM.toLong(), "advertise_mode" to ADVERTISE_MODE_BALANCED.toLong() ) }

Slide 17

Slide 17 text

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()

Slide 18

Slide 18 text

3. RemoteConfigʹΑͬͯৼΔ෣͍Λม͑Δ // RemoteConfigͷ஋Λࢀর͢ΔΑ͏ʹஔ͖׵͑ bleAdvertiser.startAdvertising( AdvertiseSettings.Builder() .setTxPowerLevel(advertisePower) .setAdvertiseMode(advertiseMode) .setConnectable(true) .build(), AdvertiseData.Builder() .build(), callback ) ϋʔυίʔσΟϯάɺΞϓϦͷߋ৽Λͤͣʹػछґଘʹཱͪ޲͔͏

Slide 19

Slide 19 text

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