ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Flutter + Firebase ์—ฐ๋™
    Flutter ํ…Œํฌ 2023. 11. 24. 12:14

    Firebase ์—ฐ๋™

    1. Firebase ์ฝ˜์†”์ด๋™ ํ›„ ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ -> ํ”„๋กœ์ ํŠธ ์ด๋ฆ„์ž…๋ ฅ

     

    2. ์• ๋„๋ฆฌํ‹ฑ์Šค๋Š” ํ™œ์šฉ๋„๊ฐ€ ๋งŽ๊ณ  ๊ธฐ๋ณธ์ ์œผ๋กœ ์ ์šฉํ•˜๋Š” ๊ธฐ๋Šฅ์ด๊ธฐ์— ์‚ฌ์šฉ์„ค์ • ๊ทธ๋Œ€๋กœ ๋‘๊ณ  ๊ณ„์†

     

    3. ์• ๋„๋ฆฌํ‹ฑ์Šค ๊ณ„์ • ์„ ํƒ ๋˜๋Š” ์ƒ์„ฑ ํ›„ ์ ์šฉ, ์• ๋„๋ฆฌํ‹ฑ์Šค ์œ„์น˜๋Š” ๋ฏธ๊ตญ์œผ๋กœ ๋‘๊ณ  ๊ณ„์†

     

    4. ํ•„์š”ํ•œ ํŒจํ‚ค์ง€ ๋‹ค์šด๋กœ๋“œ (/pubspec.yaml)

    firebase_core: ^3.1.1

     

    5. Firebase ์ฝ˜์†”์—์„œ ์šฐ์ธก์— ์žˆ๋Š” Flutter ์•„์ด์ฝ˜์„ ๋ˆŒ๋Ÿฌ ์—ฐ๋™ ์‹œ์ž‘

     

    6. Firebase CLI ์„ค์น˜ ๋ฐ ๋กœ๊ทธ์ธ, ์‹คํ–‰ 

     

    ํ„ฐ๋ฏธ๋„์—์„œ ์•„๋ž˜๊ฐ’ ์ž…๋ ฅ

    npm install -g firebase-tools
    firebase login

     

    ๋‹ค์Œ ๋‹จ๊ณ„์— ๋‚˜์˜ค๋Š” ๋ช…๋ น์–ด๋“ค์„ ํ„ฐ๋ฏธ๋„์— ์ž…๋ ฅ

     

    ๋งŒ์•ฝ ์•„๋ž˜์™€ ๊ฐ™์ด ๊ฒฝ๊ณ ๊ฐ€ ๋œฌ๋‹ค๋ฉด ํ„ฐ๋ฏธ๋„์— export PATH="$PATH":"$HOME/.pub-cache/bin"์ž…๋ ฅ

     

    ์œ„์˜ ๋ฐฉ๋ฒ•์ด ์•ˆ๋  ๊ฒฝ์šฐ ์•„๋ž˜์™€ ๊ฐ™์€ ๋ฐฉ๋ฒ•์œผ๋กœ ํ•ด๊ฒฐ, ๋น„๋ฐ€๋ฒˆํ˜ธ๋Š” android์ด๋‹ค.

    keytool -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore

     

     

    Platform์„ ํƒ์˜ ๊ฒฝ์šฐ ์‚ฌ์šฉํ•˜๊ณ ์ž ํ•˜๋Š” ํ”Œ๋žซํผ์— ๋งž๊ฒŒ ์„ ํƒ(Space bar๋ฅผ ํ†ตํ•ด ์„ ํƒ๊ฐ€๋Šฅ) ํ›„ ์—”ํ„ฐ

     

    7. Firebase ์—ฐ๋™์ฝ”๋“œ ์ถ”๊ฐ€

    void main() async {
      WidgetsFlutterBinding.ensureInitialized();
    
      await Firebase.initializeApp(
        options: DefaultFirebaseOptions.currentPlatform,
      );
    
      runApp(const MyApp());
    }

     

    8. Firebase ์ฝ˜์†” -> ํ†ฑ๋‹ˆ๋ฐ”ํ€ด ๋ชจ์–‘ ํด๋ฆญ์„ ํ†ตํ•ด ํ”„๋กœ์ ํŠธ ์„ค์ • ํŽ˜์ด์ง€๋กœ ์ด๋™

     

    9. ๊ธฐ๋ณธ GCP us-central๋กœ ์„ค์ •

     

    10. ์•ˆ๋“œ๋กœ์ด๋“œ ๋””์ง€ํ„ธ ์ง€๋ฌธ์ถ”๊ฐ€(ํ•˜๋‹จ์˜ ๋ฉ”๋‰ด ์ค‘ ์•ˆ๋“œ๋กœ์ด๋“œ ํด๋ฆญ)

     

    [10 - 1] ํ„ฐ๋ฏธ๋„์— cd android && ./gradlew signingReport ์ž…๋ ฅ

     

    [10 - 2] ํ„ฐ๋ฏธ๋„์— ์ญ‰ ๋œจ๋Š” ๋ฆฌ์ŠคํŠธ ์ค‘ ์ตœ์ƒ๋‹จ์˜ debug์ •๋ณด๋กœ ๋“ฑ๋ก(์•ˆ๋“œ๋กœ์ด๋“œ๋А ์ถ”ํ›„ ์ถœ์‹œ์‹œ PlayConsole์—์„œ ์–ป์€ sha์ •๋ณด๋„ ๋“ฑ๋กํ•ด์•ผํ•จ)

     

    11. iOS App Store ID ์ถ”๊ฐ€

    [11 - 1] ์• ํ”Œ ๊ฐœ๋ฐœ์žํŽ˜์ด์ง€ AppStore -> ์•ฑ ์„ ํƒ -> ์ขŒ์ธก ๋ฉ”๋‰ด ์ค‘ ์ผ๋ฐ˜ ์ •๋ณด -> ์•ฑ์ •๋ณด ํ•˜๋‹จ์˜ "์ผ๋ฐ˜ ์ •๋ณด"์— ์žˆ๋Š” Apple ID ์ž…๋ ฅ

     

    [11 - 2] Firebase์— ์ž…๋ ฅ

     

    12. GCP ์„ค์ •

    [12 - 1] Firebase ํ”„๋กœ์ ํŠธ ์„ค์ • ํŽ˜์ด์ง€์˜ ํด๋ผ์šฐ๋“œ ๋ฉ”์‹œ์ง• ํƒญ ํด๋ฆญ ํ›„ "Firebase Cloud Messaging API(V1)"์šฐ์ธก์˜ ์ 3๊ฐœ ๋ฉ”๋‰ด ํด๋ฆญ ํ›„ ์ฝ˜์†”์—์„œ ๊ด€๋ฆฌ ํด๋ฆญ( ๊ตฌ๊ธ€์—์„œ GCP ๊ฒ€์ƒ‰ ํ›„ ์ ‘์†๋„ ๊ฐ€๋Šฅ)

     

    [12 - 2] GCP์˜ ์ขŒ์ธก ๋ฉ”๋‰ด์—์„œ "API ๋ฐ ์„œ๋น„์Šค" -> "์‚ฌ์šฉ์ž ์ธ์ฆ์ •๋ณด"ํด๋ฆญ

     

    [12 - 3] ๊ฒฝ๊ณ ํ‘œ์‹œ๋˜์–ด์žˆ๋Š” ๋ถ€๋ถ„๋“ค์„ ์ˆ˜์ •ํ•ด์ค˜์•ผ ํ•œ๋‹ค.

     

    [12 - 4] iOS keyํด๋ฆญ -> "iOS ์•ฑ"ํด๋ฆญ -> iOS ์ œํ•œ์‚ฌํ•ญ -> +๋ฒ„ํŠผํด๋ฆญ -> ๋ฒˆ๋“คID์ž…๋ ฅ

     

    [12 - 5] API ์ œํ•œ์‚ฌํ•ญ์—์„œ ํ‚ค์ œํ•œ์•ˆํ•จ์œผ๋กœ ๋‘๊ณ  ์ €์žฅ

     

    [12 - 6] Android ์„ ํƒ -> Android์•ฑ ์„ ํƒ -> Android ์ œํ•œ์‚ฌํ•ญ์—์„œ +ADD๋ฒ„ํŠผ ํด๋ฆญ ํ›„ ํŒจํ‚ค์ง€์ด๋ฆ„๊ณผ SHA-1์ž…๋ ฅ ํ›„ ์ €์žฅ

    ํŒจํ‚ค์ง€์ด๋ฆ„๊ณผ SHA-1์€ Firebase์— ์—ฐ๋™๋˜์–ด์žˆ๋Š” ์ •๋ณด๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค

     

    [12 - 7] API ์ œํ•œ์‚ฌํ•ญ์—์„œ ํ‚ค์ œํ•œ์•ˆํ•จ์œผ๋กœ ๋‘๊ณ  ์ €์žฅ

     

     

    ๋Œ“๊ธ€

Designed by Tistory.