Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Firebaseを使ってみた
Search
Katsuya Kato
February 24, 2016
Technology
0
42
Firebaseを使ってみた
関西モバイルアプリ研究会 #11 資料
Katsuya Kato
February 24, 2016
Tweet
Share
More Decks by Katsuya Kato
See All by Katsuya Kato
複業メンバーと共に創るカウシェ
katsuyax
0
590
AndroidThingsとFirebaseで始めるホームセキュリティ / Android Things Home Security
katsuyax
2
4.9k
WWDCでこの先生きのこるには / WWDC2017
katsuyax
0
94
watchOS3の新機能 / watchos3
katsuyax
0
91
iPhone(iOS)のアプリ内課金 / in app purchase
katsuyax
0
100
Other Decks in Technology
See All in Technology
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
370
State of Open Source Web Mapping Libraries
dayjournal
0
230
メールサーバ管理者のみ知る話
hinono
1
110
Terraform CI/CD パイプラインにおける AWS CodeCommit の代替手段
hiyanger
1
190
いざ、BSC討伐の旅
nikinusu
2
730
地理情報データをデータベースに格納しよう~ GPUを活用した爆速データベース PG-Stromの紹介 ~
sakaik
1
130
Going down the RAT hole: Deep dive into the Vuln-derland of APT-class RAT Tools
nttcom
0
240
形式手法の 10 メートル手前 #kernelvm / Kernel VM Study Hokuriku Part 7
ytaka23
5
820
今、始める、第一歩。 / Your first step
yahonda
2
730
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
28
12k
元旅行会社の情シス部員が教えるおすすめなre:Inventへの行き方 / What is the most efficient way to re:Invent
naospon
2
300
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
1
130
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
264
13k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
505
140k
A Philosophy of Restraint
colly
203
16k
Navigating Team Friction
lara
183
14k
Measuring & Analyzing Core Web Vitals
bluesmoon
3
78
Teambox: Starting and Learning
jrom
133
8.8k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
231
17k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
42
2.2k
Documentation Writing (for coders)
carmenintech
65
4.4k
10 Git Anti Patterns You Should be Aware of
lemiorhan
654
59k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
Transcript
'JSFCBTFΛͬͯΈͨ ,BUTVZB,BUP
ࣗݾհ w Ճ౻উ w ΈࠐΈۀք͔ΒϞόΠϧۀքʹ ͖ͬͯͯ w ڈʹຊग़͠·ͨ͠
'JSFCBTFΛ ͬͯΈͨΛ͠·͢
'JSFCBTFͱ w ݄ʹ(PPHMFʹങऩ͞Εͨ#BB4ʢ#BDLFOEBTB 4FSWJDFʣ w ετϨʔδɺϢʔβʔཧͳͲΞϓϦέʔγϣϯͷόοΫΤϯ υͱͯ͠ඞཁͱͳΔػೳΛαʔϏεΛఏڙͯ͘͠ΕΔ w νϟοτΞϓϦͷΑ͏ͳϦΞϧλΠϜʹσʔλΛಉظ͢Δඞཁ ͕͋ΔαʔϏεʹద͍ͯ͠Δ
w /P42-ɻ+40/ΦϒδΣΫτͱͯ͠อ࣋͞ΕΔ w ΦϑϥΠϯͷॲཧ͍͍ײ͡ʹͬͯ͘ΕΔʢΒ͍͠ʣ
ͳͥ'JSFCBTF͔
ͳͥ'JSFCBTFͳͷ͔ w J04"OESPJEͰखܰʹ͏͜ͱ͕Ͱ͖ΔͷΛ ୳ͯͨ͠ w ಥવͷ1BSTFDPNऴྃͷ͓Βͤ w ͪΐͬͱ͏͚ͩͳΒֶशίετ͕ͯ͘ࡁΉ ͷͷΛɾɾɾ
ͬͯΈΔ
ΞΧϯτొ w IUUQTXXXpSFCBTFDPN
ཧը໘
ཧը໘ Ճ͞Εͨσʔλ͕ ͜͜ʹදࣔ͞Ε͍ͯ͘
νϟοτΞϓϦΛ ࡞ͬͯΈΔ
None
4%,ͷಋೖ
$PDPB1PET
pod 'Firebase'
ॳظઃఆˍಡΈॻ͖
ॳظઃఆ firebaseRef = Firebase(url:"https:// kanmoba.firebaseio.com/chat/message")
σʔλͷॻ͖ࠐΈ let messageData = ["name":nameTextField.text!, "message": messageTextField.text!] firebaseRef.childByAutoId().setValue(messageData) /4%JDUJPOBSZͰॻ͖ࠐΉσʔλΛ४උ *%ΛϥϯμϜͰੜ͢Δϝιου
σʔλͷॻ͖ࠐΈʢૹ৴ʣ
ཧը໘ͰݟͯΈΔ
σʔλͷಡΈग़͠ firebaseRef.observeEventType(.ChildAdded, withBlock: { snapshot in if let name =
snapshot.value.objectForKey("name") as? String, message = snapshot.value.objectForKey("message") as? String { self.textView.text = "\(self.textView.text)\n\(name) : \(message)" } }) ࢹ͢ΔΠϕϯτΛొ ࢠ͕Ճ͞Εͨͱ͖Λࢹ͢Δ LFZΛࢦఆͯ͠ΛಘΔ
σϞ
None
͘Β͍Ͱ Ͱ͖ͯ͠·ͬͨͷͰ
"OESPJEɾɾɾ
4%,
(SBEMF
HSBEMFCVMJE dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.firebase:firebase-client-android:2.5.2+' }
HSBEMFCVMJE packagingOptions { exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE-FIREBASE.txt' exclude 'META-INF/NOTICE' }
ॳظઃఆˍಡΈॻ͖
ͦͷલʹ1FSNJTTJPO <uses-permission android:name="android.permission.INTERNET" />
ॳظઃఆ Firebase.setAndroidContext(this); firebaseRef = new Firebase("https://kanmoba.firebaseio.com/ chat/message");
σʔλͷॻ͖ࠐΈ HashMap<String, String> post = ɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹnew HashMap<String, String>(); post.put("name", nameEditText.getText().toString());
post.put("message", messageEditText.getText().toString()); firebaseRef.push().setValue(post) DIJME#Z"VUP*Eϝιου͕ ແ͔ͬͨɾɾɾ
σʔλͷಡΈग़͠ firebaseRef.addChildEventListener(new ChildEventListener() { @Override public void onChildAdded(DataSnapshot dataSnapshot, String
s) { HashMap hash = (HashMap)dataSnapshot.getValue(); textView.setText(textView.getText() + ɹɹɹɹɹɹɹɹɹɹ ɹɹɹɹ"\n" + hash.get("name") + " : " + ɹɹɹɹɹɹɹɹɹɹɹɹɹɹ hash.get("message")); } } ϦεφʔΛొ
σϞ
None
ͦͷଞؾʹͳΔͱ͜ΖΛ
όΠφϦʁ w #"4&Τϯίʔυ͢Ε0,
Ձ֨
ηΩϡϦςΟ w ʮ3VMFTʯΛઃఆ͢Δ͜ͱͰΞΫηε੍ݶ͕Ͱ͖Δ
σʔλͷαΠζΛ੍ݶ
ϩάΠϯ͍ͯ͠ΔਓͷΈڐՄ
ؾʹͳΔ͜ͱ w σʔλ͕૿͑ͨ࣌ʹ͕͘ͳΒͳ͍͔ʁ w 'JSFCBTFʹ164)৴ػೳ͕ແ͍ w 1FSTFΛϗεςΟϯάͨ͠ํ͕ͬͺΓྑ͍ʁ w Φεεϝͷ#BB4͕Γ͍ͨ
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠