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

Firebase ♥️ Web

Firebase ♥️ Web

Get to know what Firebase improved support for web apps even more like Google Analytics, Remote Config, Cloud Messaging, and Performance Monitoring.

Firebase Thailand

November 09, 2019
Tweet

More Decks by Firebase Thailand

Other Decks in Technology

Transcript

  1. #FirebaseDevDay Integrations with other services - BigQuery - Crashlytics -

    Firebase Cloud Messaging - Firebase Remote Config - Firebase A/B Testing - Firebase Predictions - Google Tag Manager
  2. #FirebaseDevDay var firebaseConfig = { apiKey: "api-key", authDomain: "project-id.firebaseapp.com", databaseURL:

    "https://project-id.firebaseio.com", projectId: "project-id", storageBucket: "project-id.appspot.com", messagingSenderId: "sender-id", appId: "app-id", measurementId: "G-measurement-id", };
  3. #FirebaseDevDay const analytics = firebase.analytics() analytics.logEvent('login', { eventParameters }) firebase.auth().onAuthStateChanged(

    async user => { user && analytics.setUserId(user.uid) }) firebase.auth().onIdTokenChanged(async user => { user && analytics.setUserProperties({ userTokenParameters }) })
  4. #FirebaseDevDay exports.sendCouponOnPurchase = functions.analytics.event('in_app_purchase').onLog((event) => { const user = event.user;

    const uid = user.userId; const purchaseValue = event.valueInUSD; const userLanguage = user.deviceInfo.userDefaultLanguage; const Platform = event.user.appInfo.appPlatform if (purchaseValue > 500 && Platform === ‘Web’) { return sendHighValueCouponViaFCM(uid, userLanguage); } return sendCouponViaFCM(uid, userLanguage); }); Integrate with Firebase Cloud Functions
  5. #FirebaseDevDay const remoteConfig = firebase.remoteConfig(); remoteConfig.settings = { minimumFetchIntervalMillis: 3600000,

    }; remoteConfig.defaultConfig = ({ 'welcome_message': 'Welcome', }); remoteConfig.fetchAndActivate().then(() => { showWelcomeMessage(); }) const welcomeMessage = remoteConfig.getValue('welcome_message')
  6. #FirebaseDevDay Message JSON representation { "name": string, "data": { string:

    string, ... }, "notification": { object (Notification) }, "android": { object (AndroidConfig) }, "webpush": { object (WebpushConfig) }, "apns": { object (ApnsConfig) }, "fcm_options": { object (FcmOptions) }, // Pick 1 "token": string, "topic": string, "condition": string }
  7. #FirebaseDevDay Webpush JSON representation { "headers": { string: string, //

    Urgency: ’low’, TTL: 600 , Content-Type: text/plain;charset=utf8 }, "data": { string: string, }, "notification": { object }, "fcm_options": { { "link": string } } }
  8. #FirebaseDevDay POST https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send HTTP/1.1 Content-Type: application/json Authorization: Bearer ya29.ElqKBGN2Ri_Uz...PbJ_uNasm {

    "message": { "token" : <token of destination app>, "notification": { "title": "FCM Message", "body": "This is a message from FCM" }, "webpush": { "headers": { "Urgency": "high" }, "notification": { "body": "This is a message from FCM to web", "requireInteraction": "true", "badge": "/badge-icon.png" } } } }
  9. #FirebaseDevDay const fooQueryTrace = perf.trace('fooQuery') const fooQueryRef = firebase.firestore().collection('eiei') fooQueryTrace.start()

    const fooQueryRes = await fooQueryRef.get() fooQueryTrace.incrementMetric('totalFooSize', fooQueryRes.size) fooQueryTrace.putMetric('itemFooSize', fooQueryRes.size) fooQueryTrace.stop()