Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

React native-firebase startup-mtup

646 views

Published on

tips for react-native-firebase

Published in: Engineering
  • Be the first to comment

React native-firebase startup-mtup

  1. 1. • Leverages • • teratail • K Kubernetes 
 • 
 

  2. 2. 🎉
  3. 3. 
 
 
 https://github.com/invertase/react-native-firebase/tree/v5.x.x
  4. 4.
  5. 5. 
 https://github.com/invertase/react-native-firebase/tree/v5.x.x
  6. 6. https://firebase.google.com/docs/auth/?hl=ja
  7. 7. firebase.auth().onAuthStateChanged(_user => { if(_user) { // login } else { // logout } }) 
 eventListener
  8. 8. import { AccessToken, LoginManager, LoginResult } from 'react-native-fbsdk' import firebase from 'react-native-firebase' const getFacebookCredential = async () => { try { const login: LoginResult = await LoginManager.logInWithReadPermissions( [ 'public_profile', 'email' ] ) if (login.isCancelled) { return false } const result = await AccessToken.getCurrentAccessToken(); if (!result) { throw new Error('Something went wrong obtaining the users access token') } return firebase.auth.FacebookAuthProvider.credential(result.accessToken) } catch (error) { console.log(error) return false } } WebAuth OAuth
  9. 9. const login = async (credential) => { try { const result = await firebase.auth().signInWithCredential(credential) return result } catch (error) { console.log(error) } } signInWithCredential AuthListener
  10. 10.
  11. 11.
  12. 12. const linkCredential = async (callback) => { const credential = await getFacebookCredential() if (credential) { const currentUser = firebase.auth().currentUser if (currentUser) { const result = await currentUser.linkWithCredential(credential) return result } } } 
 

  13. 13.
  14. 14.
  15. 15. 
 

  16. 16. https://facebook.github.io/react-native/docs/linking.html
  17. 17. https://firebase.google.com/docs/dynamic-links/ios/receive?hl=ja
  18. 18. https://rnfirebase.io/docs/v5.x.x/links/ios
  19. 19.
  20. 20. loginUser.sendEmailVerification({ url: `${DEEP_LINK}`, iOS : { bundleId: bundleIdentifier, }, android: { packageName: ‘appName’, }, handleCodeInApp: true, }) 

  21. 21. firebase.links().onLink(url => { if(url){ const isLoginUrl = url.includes(DEEP_LINK) const canOpen = Linking.canOpenURL(url) if (canOpen && isLoginUrl) { Linking.openURL(url) } } })
  22. 22. admin.firestore().collection(`users`)
 .where('status', '==', 'login').orderBy('updatedAt','desc').limit(20); 

  23. 23.
  24. 24. 
 
 

  25. 25.
  26. 26. 
 

  27. 27. 
 
 
 

  28. 28. 
 


×