Firebase in React-Native

박정빈·2025년 11월 26일

React Native 사용기

목록 보기
24/28

공식문서

블로그 참고

firebase 프로젝트 만들기

  • android
    google-sercives.json을 앱수준 디렉토리에 배치한다.
    firebase sdk는 안받아도 됨
  • ios
    GoogleService-Info.plist를 프로젝트 루트에 넣는다.(파란색 앱이름)
    xcode에서 프로젝트 루트에서 add files to[프로젝트명]> copy files to destination를 통해 GoogleService-Info.plist를 프로젝트에 포함시킨다.(앱 타겟 체크 해야함)

파일 설정

  • android
    /android/build.gradle
buildscript {
  dependencies {
    // ... other dependencies
    classpath 'com.google.gms:google-services:4.4.4'
    // Add me --- /\
  }
}

/android/app/build.gradle

apply plugin: 'com.google.gms.google-services' // <- Add this line
  • ios
    /ios/{projectName}/AppDelegate.swift
import Firebase <- Add this line

override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
  // Add me --- \/
  FirebaseApp.configure()
  // Add me --- /\
  // ...
}

/ios/Podfile

use_frameworks! :linkage => :static // Add me 
$RNFirebaseAsStaticFramework = true // Add me 

패키지 설치

npm install @react-native-firebase/app @react-native-firebase/analytics

코드 작성

analitics전용 스토어를 만들어고
공용 init 스토어에 연결했다.

0개의 댓글