Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

About me ৽ݟ ߊฏ גࣜձࣾηϑϦͱ͍͏ձࣾͰɺYAMAPͷAndroidΞϓϦΛ࡞͍ͬͯΔ iOSΤϯδχΞͰ͢ɻ ࠷ۙ͸ɺTensorFlow, Docker, Angular2ͳͲ΍͍ͬͯͯiOSશવ Ͱ͖ͯͳ͍ʢٽʣ » Twitter: @gupuru » GitHub: gupuru

Slide 3

Slide 3 text

ηϑϦ͸ɺͲΜͳاۀ͔ͱݴ͏ͱ…ࣾ௕͕ݘͰ͢ʂ

Slide 4

Slide 4 text

FirebaseͬͯɺԿʁ

Slide 5

Slide 5 text

Firebase » mBaaS » ΞϓϦ΍Web։ൃʹඞཁͳػೳ͕਺ଟ͘ఏڙ͞Ε͍ͯΔ » Google͕ӡӦ͍ͯ͠ΔαʔϏε » 2011೥ελʔτ(2014೥ޙ൒ʹGoogle͕ങऩ) » ແྉͰ͔ͭ͑Δ΋ͷ͕ଟ͍

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

͕࣌ؒڐ͢ݶΓɺ঺հ͍ͯ͘͠Αʔ

Slide 9

Slide 9 text

Analytics

Slide 10

Slide 10 text

Analytics » ϞόΠϧΞϓϦʹಛԽͨ͠ Google ΞφϦςΟΫεΈ͍ͨͳ΋ͷ » Πϕϯτܕ෼ੳπʔϧ » ແྉ » iOS, Android

Slide 11

Slide 11 text

iOSͷಋೖ pod 'Firebase/Core' import UIKit import Firebase @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { //௥Ճ FIRApp.configure() return true } }

Slide 12

Slide 12 text

Androidͷಋೖ compile 'com.google.firebase:firebase-core:9.6.1' public class MainActivity extends AppCompatActivity { private final MainActivity self = this; private FirebaseAnalytics mFirebaseAnalytics; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); } }

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

Cloud Messaging

Slide 15

Slide 15 text

Cloud Messaging » ϓογϡ௨஌ » iOS, Android, Web » ແྉ » Notification MessageͱData Messageͷ̎छྨ

Slide 16

Slide 16 text

Notification Message { "to" : "HHwgIpoDKCIZvvDMExUdFQ3P1...", "notification" : { "body" : "΅Ͱ͍", "title" : "͍ͨͱΔ", "icon" : "myicon" } } curl --header "Authorization: key=...guQidTc7xzs8" \ --header Content-Type:"application/json" \ https://fcm.googleapis.com/fcm/send \ -d "{\"to\": \"...ifS-oaJevN_VwU0Y\",\"priority\":\"high\",\"notification\": {\"title\": \"this is title\", \"body\": \"this is body\"}}"

Slide 17

Slide 17 text

Data Message { "to" : "xUdFQ3P1...", "data" : { "name" : "fox", "body" : "neko", "Place" : "horaana" }, } curl --header "Authorization: key=...guQidTc7xzs8" \ --header Content-Type:"application/json" \ https://fcm.googleapis.com/fcm/send \ -d "{\"to\": \"...aJevN_VwU0Y\",\"priority\":\"high\",\"data\": {\"custom_title\": \"this is custom title\", \"custom_body\": \"this is custom body\", \"icon\": \"ic_stat_ic_notification\"}}"

Slide 18

Slide 18 text

Androidͷಋೖ compile 'com.google.firebase:firebase-messaging:9.6.1'

Slide 19

Slide 19 text

tokenऔಘ FirebaseInstanceId.getInstance().getToken();

Slide 20

Slide 20 text

௨஌ͷϋϯυϦϯά public class MyFirebaseMessagingService extends FirebaseMessagingService { public void onMessageReceived(RemoteMessage remoteMessage) { Log.d(TAG, "From: " + remoteMessage.getFrom()); if (remoteMessage.getData() != null) { //data } if (remoteMessage.getNotification() != null) { //notification } } }

Slide 21

Slide 21 text

Notifications

Slide 22

Slide 22 text

Notifications » ϓογϡ௨஌ » Webίϯιʔϧ͔Β࢖͏(ίʔυΛॻ͘ඞཁͳ͠) » ແྉ » iOS, Android

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

Authentication

Slide 25

Slide 25 text

Authentication » ϩάΠϯपΓ » ϝΞυ, ಗ໊ΞΧ΢ϯτ, Google, Facebook, Twitter, GitHubͳͲʹରԠ » ແྉ » FirebaseUIΛ࢖͑͹ɺuiͳͲ΋؆୯ʹ࣮૷Ͱ͖Δ » iOS, Android, Web

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

Androidͷಋೖ(firebase UI) compile 'com.firebaseui:firebase-ui-auth:0.6.0' FirebaseAuth auth = FirebaseAuth.getInstance(); if (auth.getCurrentUser() != null) { //ϩάΠϯࡁΈ } else { startActivityForResult( AuthUI.getInstance().createSignInIntentBuilder().build(), RC_SIGN_IN); } protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RC_SIGN_IN) { if (resultCode == RESULT_OK) { // ϩάΠϯ੒ޭ } } }

Slide 28

Slide 28 text

Webͷ৔߹ Firebase ui sample // FirebaseUI config. var uiConfig = { 'signInSuccessUrl': '੒ޭޙͷurl', 'signInOptions': [ firebase.auth.FacebookAuthProvider.PROVIDER_ID, firebase.auth.EmailAuthProvider.PROVIDER_ID ], }; var ui = new firebaseui.auth.AuthUI(firebase.auth()); ui.start('#firebaseui-auth-container', uiConfig);

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

Realtime Database

Slide 31

Slide 31 text

Realtime Database » NoSQL JSON σʔλϕʔε » ϦΞϧλΠϜಉظ(ΦϑϥΠϯରԠ) » iOS, Android, Web » ༗ྉ(ແྉ࿮͋Γ)

Slide 32

Slide 32 text

iOSͷಋೖ pod 'Firebase/Database' import UIKit import Firebase @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { //௥Ճ FIRApp.configure() return true } }

Slide 33

Slide 33 text

import UIKit import FirebaseDatabase class ViewController: UIViewController { let rootRef = FIRDatabase.database().reference() override func viewDidLoad() { super.viewDidLoad() //ಡΈࠐΈ rootRef.observe(.value, with: { snapshot in print("\(snapshot.key) -> \(snapshot.value)") }) //ॻ͖ࠐΈ rootRef.child("food").setValue("ΓΜ͝͞·") } }

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

Storage

Slide 36

Slide 36 text

Storage » ετϨʔδ(S3ʹ͍͔ۙ΋) » ը૾, ಈը, Ի੠ͳͲͷμ΢ϯϩʔυ, Ξοϓϩʔυ » iOS, Android, Web » ༗ྉ(ແྉ࿮͋Γ)

Slide 37

Slide 37 text

iOSͷಋೖ pod 'Firebase/Storage' import UIKit import Firebase @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { //௥Ճ FIRApp.configure() return true } }

Slide 38

Slide 38 text

Ξοϓϩʔυ import FirebaseStorage class ViewController: UIViewController { let storage = FIRStorage.storage() override func viewDidLoad() { super.viewDidLoad() let storageRef = storage.reference(forURL: "gs://fir-handson-ce2a8.appspot.com") if let data = UIImagePNGRepresentation(UIImage(named: "ie")!) { let riversRef = storageRef.child("images/ie.png") riversRef.put(data, metadata: nil, completion: { metaData, error in print(metaData) print(error) }) } } }

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

μ΢ϯϩʔυ import FirebaseStorage class ViewController: UIViewController { let storage = FIRStorage.storage() override func viewDidLoad() { super.viewDidLoad() let storageRef = storage.reference(forURL: "gs://fir-handson-ce2a8.appspot.com") let ieRef = storageRef.child("images/hogehoge.png") ieRef.data(withMaxSize: 1 * 1024 * 1024) { (data, error) -> Void in if (error != nil) { print(error) } else { let image: UIImage! = UIImage(data: data!) } } } }

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

Hosting

Slide 43

Slide 43 text

Hosting » WebαΠτެ։ » HTTP/2, SSL » ༗ྉ(ແྉ࿮͋Γ) » ಠࣗυϝΠϯՄೳ(ແྉ)

Slide 44

Slide 44 text

ಋೖ npm install -g firebase-tools ॳظԽ firebase init

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

ެ։ firebase deploy ֬ೝ firebase open

Slide 47

Slide 47 text

Crash Reporting

Slide 48

Slide 48 text

Crash Reporting » ΫϥογϡϨϙʔτ » ϕʔλ » ແྉ » iOS, Android

Slide 49

Slide 49 text

Androidͷಋೖ compile 'com.google.firebase:firebase-crash:9.6.1'

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

Remote Config

Slide 52

Slide 52 text

Remote Config » Ϋϥ΢υͰϞόΠϧΞϓϦͷઃఆ஋Λ؅ཧͰ͖ΔαʔϏε » iOS, Android » ແྉ

Slide 53

Slide 53 text

Androidͷಋೖ compile 'com.google.firebase:firebase-config:9.6.1'

Slide 54

Slide 54 text

σϑΥϧτ஋ͷઃఆ test ͯ͢

Slide 55

Slide 55 text

FirebaseRemoteConfig remoteConfig; remoteConfig = FirebaseRemoteConfig.getInstansce(); //σϕϩούʔϞʔυࢦఆ FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder() .setDeveloperModeEnabled(BuildConfig.DEBUG) .build(); remoteConfig.setConfigSettings(configSettings); //σϑΥϧτͷ஋ΛಡΈࠐΉ remoteConfig.setDefaults(R.xml.remote_config_defaults); remoteConfig.fetch(43200) .addOnCompleteListener(new OnCompleteListener() { @Override public void onComplete(@NonNull Task task) { if (task.isSuccessful()) { //஋Λ൓ө remoteConfig.activateFetched(); } else { //fetchࣦഊ } } });

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

App Indexing

Slide 58

Slide 58 text

App Indexing » ΢ΣϒαΠτͱΞϓϦΛඥ෇͚Δ » ແྉ » iOS, Android

Slide 59

Slide 59 text

ɹσΟʔϓϦϯΫͷઃఆ(Andoirdͷ৔߹)

Slide 60

Slide 60 text

ςετ adb shell am start -a android.intent.action.VIEW -d "url" com.example.hoe

Slide 61

Slide 61 text

Dynamic Links

Slide 62

Slide 62 text

Dynamic Links » ΞϓϦͷΠϯετʔϧଅਐ » ແྉ » iOS, Android

Slide 63

Slide 63 text

Androidͷಋೖ compile 'com.google.firebase:firebase-invites:9.6.1'

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

Invites

Slide 66

Slide 66 text

Invites » γΣΞػೳ » ແྉ » iOS, Android

Slide 67

Slide 67 text

Androidͷಋೖ compile 'com.google.firebase:firebase-invites:9.6.1' ※Dynamic Linksͷ༗ޮ͕ඞཁ

Slide 68

Slide 68 text

ট଴ Intent intent = new AppInviteInvitation.IntentBuilder(getString(R.string.invitation_title)) .setMessage(getString(R.string.invitation_message)) .setDeepLink(Uri.parse(getString(R.string.invitation_deep_link))) .setCustomImage(Uri.parse(getString(R.string.invitation_custom_image))) .setCallToActionText(getString(R.string.invitation_cta)) .build(); startActivityForResult(intent, REQUEST_INVITE); ݁Ռ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_INVITE) { if (resultCode == RESULT_OK) { String[] ids = AppInviteInvitation.getInvitationIds(resultCode, data); for (String id : ids) { Log.d(TAG, "onActivityResult: sent invitation " + id); } } } }

Slide 69

Slide 69 text

ड৴ @Override protected void onCreate(Bundle savedInstanceState) { mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(AppInvite.API) .enableAutoManage(this, this) .build(); boolean autoLaunchDeepLink = true; AppInvite.AppInviteApi.getInvitation(mGoogleApiClient, this, autoLaunchDeepLink) .setResultCallback( new ResultCallback() { @Override public void onResult(AppInviteInvitationResult result) { if (result.getStatus().isSuccess()) { Intent intent = result.getInvitationIntent(); String deepLink = AppInviteReferral.getDeepLink(intent); String invitationId = AppInviteReferral.getInvitationId(intent); } } }); }

Slide 70

Slide 70 text

·ͱΊ

Slide 71

Slide 71 text

Firebaseศརͩͧ(ŋТŋ)b

Slide 72

Slide 72 text

࠷ޙʹݴ͍๨Εͨ͜ͱ͕...

Slide 73

Slide 73 text

ࣾ௕ͷ໊લ͸ɺϋφͪΌΜͰ͢ʢসʣ

Slide 74

Slide 74 text

͝ਗ਼ௌɺ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ