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

FirebaseOverview.pdf

2594ac7ce91fd7d9a3ce71ca7cc2d0c0?s=47 d_date
September 01, 2018

 FirebaseOverview.pdf

DevFest Tokyo 2018

2594ac7ce91fd7d9a3ce71ca7cc2d0c0?s=128

d_date

September 01, 2018
Tweet

Transcript

  1. Firebase Overview for Native Application Daiki Matsudate (@d_date) GDG DevFest

    Tokyo 2018
  2. Daiki Matsudate @d_date FOLIO Co., Ltd.

  3. ͜ͷຊͷಋೖతͳ࿩Ͱ͢

  4. https://booth.pm/ja/ items/835645

  5. None
  6. Agenda • ͱΓ͋͑ͣೖΕ͍ͨFirebase • Prediction·ΘΓͷ࿩ • Firestore·ΘΓͷ࿩

  7. લఏ

  8. 1. iOSΤϯδχΞͰ͢

  9. 2. Έͳ͞ΜͰͭ͘Δ ηογϣϯͰ͢

  10. ޿͘ઙ͘࿩͍ͯ͘͠͠ͷͰ ࣭໰ߟ͑ͱ͍͍ͯͩ͘͞

  11. ͱΓ͋͑ͣೖΕ͍ͨ Firebase

  12. ͱΓ͋͑ͣೖΕ͍ͨFirebase • Crashlytics • Performance Monitoring • Google Analytics for

    Firebase • App Indexing
  13. None
  14. • ΞϓϦͷΫϥογϡϩάΛऩूɾղੳ͢Δ͓ͳ͡Έͷπʔ ϧ • Fabric ͕ Googleʹങऩ͞Ε͔ͯΒ౷߹͕ਐΊΒΕɺ2017 ೥10݄ʹ౷߹ (Crash Reporting͸deprecated)

    • Cloud Functionͱ࿈ܞՄೳ
  15. None
  16. - Automatic Trace • ΞϓϦͷύϑΥʔϚϯεΛଌఆ͢Δ • Automatic trace • App

    start • Network • App in foreground / background • Screen
  17. - Screen Trace iOS keyWindow಺ʹ͋ΔUIViewControllerͷ ɾStart: viewDidAppear:͕ݺ͹Εͨͱ͖ ɾStop: viewDidDisappear:͕Α͹Εͨͱ͖ɻ ※Container

    View ControllerͰ͸Ωϟϓνϟ͠ͳ͍
  18. Android ͢΂ͯͷActivityͷ ɾStart: onActivityStarted()͕ݺ͹Εͨͱ͖ ɾStop: onActivityStopped()͕ݺ͹Εͨͱ͖ - Screen Trace

  19. https://www.youtube.com/watch?v=e-8fiv-vteQ&t=16

  20. https://www.youtube.com/watch?v=e-8fiv-vteQ&t=16

  21. NetworkΛτϨʔε͢Δࡍͷ஫ҙ఺ • ඪ४ͷAPIҎ֎ʢ௿ϨϕϧAPI΍Socket௨৴ͳ Ͳʣͷ৔߹͸ࣗಈτϨʔε͞Εͳ͍

  22. Appendix: Performance Monitoring - Custom Trace let trace = Performance.startTrace(name:

    "request_trace") let contents: String do { contents = try String(contentsOfFile: fileName, encoding: .utf8) } catch { print("Log file doesn't exist yet") contents = "" } let fileLength = contents.lengthOfBytes(using: .utf8) trace?.incrementMetric("log_file_size", by: Int64(fileLength))
  23. let trace = Performance.startTrace(name: "request_trace") let contents: String do {

    contents = try String(contentsOfFile: fileName, encoding: .utf8) } catch { print("Log file doesn't exist yet") contents = "" } let fileLength = contents.lengthOfBytes(using: .utf8) trace?.incrementMetric("log_file_size", by: Int64(fileLength)) 1. Call startTrace with 2. Set your metric with Appendix: Performance Monitoring - Custom Trace
  24. let target = "https://www.google.com/images/branding/googlelogo/2x/ googlelogo_color_272x92dp.png" guard let targetUrl = URL(string:

    target) else { return } guard let metric = HTTPMetric(url: targetUrl, httpMethod: .get) else { return } metric.start() var request = URLRequest(url:targetUrl) request.httpMethod = "GET" let task = URLSession.shared.dataTask(with: request) { data, response, error in if let httpResponse = response as? HTTPURLResponse { metric.responseCode = httpResponse.statusCode } metric.stop() ɾSpecified network trace Appendix: Performance Monitoring - Custom Trace
  25. let target = "https://www.google.com/images/branding/googlelogo/2x/ googlelogo_color_272x92dp.png" guard let targetUrl = URL(string:

    target) else { return } guard let metric = HTTPMetric(url: targetUrl, httpMethod: .get) else { return } metric.start() var request = URLRequest(url:targetUrl) request.httpMethod = "GET" let task = URLSession.shared.dataTask(with: request) { data, response, error in if let httpResponse = response as? HTTPURLResponse { metric.responseCode = httpResponse.statusCode } metric.stop() 1. Initialize HTTPMetric 3. Call stop() when finished 2.Call start() ɾSpecified network trace Appendix: Performance Monitoring - Custom Trace
  26. Google Analytics for Firebase

  27. Google Analytics for Firebase • ϞόΠϧ޲͚Google Analytics • WebͷGoogle Analytics

    • BigQuery -> Data Studioͱ͍͏ར༻Λ૝ఆ • WebଆͷGAͱ౷߹͢ΔͷʹTag ManagerΛ࢖ͬͨΓ͢Δ
  28. App Index

  29. App Index • ݕࡧ݁ՌʹΞϓϦΛදࣔ͢Δ • μ΢ϯϩʔυϘλϯ͖ͭ • iOS: Universal LinksΛ༗ޮʹ

    • Android: AppIndexͷϥΠϒϥϦΛೖΕΔ • apple-app-site-associationΛϗετ͢Δ
  30. ͱΓ͋͑ͣೖΕ͍ͨFirebase ·ͣ͸ೖΕͯΈΑ͏ͥʂ

  31. Predictionपล

  32. Firebase Prediction • 7೔ؒͷσʔλΛݩʹϢʔβʔͷ࣍ͷߦಈΛ༧ଌ ͢Δ • ʮ཭୤ͦ͠͏(churn)ʯʮ཭୤͠ͳͦ͞͏ʯʮ՝ۚ ͦ͠͏(purchase)ʯʮ՝ۚ͠ͳͦ͞͏ʯͷ̐ଐੑ ΛσϑΥϧτͰਪଌͰ͖Δ •

    AnalyticsͷEventΛݩʹΧελϜ͢Δ͜ͱ΋Ͱ͖Δ
  33. Prediction x Remote Config • PredictionͰ༧ଌͨ͠Ϣʔβʔଐੑʹରͯ͠ɺ Remote ConfigΛઃఆͰ͖Δ → ʮ཭୤ͦ͠͏ʯͳϢʔβʔʹରͯ͠ɺΩϟϯϖʔ

    ϯΛଧͭ
  34. A/B Testing • ର৅ͷϢʔβʔଐੑΛࢦఆͯ͠ɺA/BςετͰ͖Δ • ςετର৅ʹ͸PredictionͰ༧ଌͨ͠ଐੑ΋ར༻Մೳ

  35. Prediction x Messaging • PredictionͰ༧ଌͨ͠Ϣʔβʔଐੑʹରͯ͠ɺNotification ΛൃՐͰ͖Δ → ʮ཭୤ͦ͠͏ʯͳϢʔβʔʹରͯ͠ɺ௨஌ΛૹΔ

  36. In-app messaging

  37. None
  38. None
  39. None
  40. Predictionपล • PredictionͰϢʔβʔͷߦಈΛ༧ଌ • ༧ଌͰ͖ͨΒ࿈ܞ͢Δ • A / B Testing

    • Cloud Messaging • In-App Messaging
  41. Firestoreपล

  42. Firestoreपล • Firebase Realtime Database • Firebase Firestore • Firebase

    Cloud Function
  43. Firebase Database

  44. • NoSQL cloud database • Realtime Data Sync with JSON

    Tree • Available data on offline Firebase Database
  45. Firebase Database

  46. NoSQL

  47. NoSQL = Denormalization

  48. Denormalization in NoSQL { "users": { "user1": { "name": "Alice"

    }, "user2": { "name": "Bob" } }, "links": { "link1": { "title": "Example", "href": "http://example.org", "submitted": "user1" } }, "comments": { "comment1": { "link": "link1", "body": "This is awesome!", "author": "user2" } } }
  49. Denormalization in NoSQL { "users": { "user1": { "name": "Alice"

    }, "user2": { "name": "Bob" } }, "links": { "link1": { "title": "Example", "href": "http://example.org", "submitted": "user1" } }, "comments": { "comment1": { "link": "link1", "body": "This is awesome!", "author": "user2" } } }
  50. Denormalization in NoSQL { "users": { "user1": { "name": "Alice"

    }, "user2": { "name": "Bob" } }, "links": { "link1": { "title": "Example", "href": "http://example.org", "submitted": "user1" } }, "comments": { "comment1": { "link": "link1", "body": "This is awesome!", "author": "user2" } } } Join data in client
  51. • 10:40 - Firestore Database Design / Room I •

    13:30 - Realtime Database for High traffic production application / Room J • 14:50 - Realtime Database in Production / Room C + D • Related Session
  52. • NoSQL cloud database • Realtime Data Sync with JSON

    Tree • Available data on offline Firebase Database
  53. Cloud Firestore

  54. • Stores data in documents organized in collections • Sending

    data with protobuf, which have more types • Introduced reference type, so requires less denormalization and data flattening • Indexed queries with compound sorting and filtering Cloud Firestore
  55. Cloud Firestore

  56. Cloud Firestore Reference type

  57. None
  58. Cloud Functions • Firebase΍HTTPϦΫΤετΛτϦΨʔʹͯ͠ɺόοΫΤ ϯυͷίʔυΛ࣮ߦ͢Δ • ίʔυ͸Google ͷCloudʹϓογϡ͢Δ

  59. Cloud Functions • Cloud Firestore • Realtime Database • Firebase

    Authentication • Google Analytics for Firebase • Crashlytics • Cloud Storage • Cloud Pub/Sub • HTTP
  60. Ex: Cloud Firestore • υΩϡϝϯτ͕ੜ੒͞Εͨͱ͖ • υΩϡϝϯτ͕ߋ৽͞Εͨͱ͖ • υΩϡϝϯτ͕࡟আ͞Εͨͱ͖ •

    ্هͷΠϕϯτ͕ൃੜͨ͠ͱ͖
  61. Use Case: Firestore x Function • AlgoliaʹΑΔશจݕࡧ • BigQuery •

    etc…
  62. Recap • ͱΓ͋͑ͣೖΕ͓͖͍ͯͨFirebase • Predictionͱͦͷपล • ௨஌ͱͦͷपล • Databaseͱͦͷपล

  63. Thank you!

  64. Q & A