์ฝ˜ํ…์ธ  ๋Œ€ํ‘œ ์ด๋ฏธ์ง€ - ๐Ÿ”” React Native์—์„œ ํ‘ธ์‹œ ์•Œ๋ฆผ ๊ตฌํ˜„ํ•˜๊ธฐ: ์•ฑ ์‚ฌ์šฉ์ž์™€์˜ ์‹ค์‹œ๊ฐ„ ์†Œํ†ต ๋น„๋ฒ• ๐Ÿ””

๐Ÿ”” React Native์—์„œ ํ‘ธ์‹œ ์•Œ๋ฆผ ๊ตฌํ˜„ํ•˜๊ธฐ: ์•ฑ ์‚ฌ์šฉ์ž์™€์˜ ์‹ค์‹œ๊ฐ„ ์†Œํ†ต ๋น„๋ฒ• ๐Ÿ””

์•ˆ๋…•, ๊ฐœ๋ฐœ์ž ์นœ๊ตฌ๋“ค! ์˜ค๋Š˜์€ ๋ชจ๋ฐ”์ผ ์•ฑ ๊ฐœ๋ฐœ์—์„œ ๋นผ๋†“์„ ์ˆ˜ ์—†๋Š” ํ‘ธ์‹œ ์•Œ๋ฆผ ๊ตฌํ˜„ ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ํ•จ๊ป˜ ์•Œ์•„๋ณผ ๊ฑฐ์•ผ. React Native๋กœ ๊ฐœ๋ฐœํ•˜๋Š” ์•ฑ์— ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ์ถ”๊ฐ€ํ•˜๋ฉด ์‚ฌ์šฉ์ž ์ฐธ์—ฌ๋„๋ฅผ ๋†’์ด๊ณ  ์•ฑ์˜ ๊ฐ€์น˜๋ฅผ ํ•œ์ธต ๋” ๋Œ์–ด์˜ฌ๋ฆด ์ˆ˜ ์žˆ์–ด. ์ด ๊ธ€์„ ํ†ตํ•ด ํ‘ธ์‹œ ์•Œ๋ฆผ์˜ A๋ถ€ํ„ฐ Z๊นŒ์ง€ ์‰ฝ๊ณ  ์žฌ๋ฏธ์žˆ๊ฒŒ ์•Œ์•„๋ณด์ž! ๐Ÿš€

๐Ÿ“š ๋ชฉ์ฐจ

  1. ํ‘ธ์‹œ ์•Œ๋ฆผ์ด ๋ญ๊ธธ๋ž˜? ๊ธฐ๋ณธ ๊ฐœ๋… ์ดํ•ดํ•˜๊ธฐ
  2. React Native ํ‘ธ์‹œ ์•Œ๋ฆผ ๊ตฌํ˜„์„ ์œ„ํ•œ ์ค€๋น„๋ฌผ
  3. Firebase Cloud Messaging(FCM) ์„ค์ •ํ•˜๊ธฐ
  4. iOS์—์„œ ํ‘ธ์‹œ ์•Œ๋ฆผ ๊ตฌํ˜„ํ•˜๊ธฐ
  5. Android์—์„œ ํ‘ธ์‹œ ์•Œ๋ฆผ ๊ตฌํ˜„ํ•˜๊ธฐ
  6. react-native-push-notification ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ํ™œ์šฉํ•˜๊ธฐ
  7. ํ‘ธ์‹œ ์•Œ๋ฆผ ๋””์ž์ธ๊ณผ ์‚ฌ์šฉ์ž ๊ฒฝํ—˜ ์ตœ์ ํ™”
  8. ํ‘ธ์‹œ ์•Œ๋ฆผ ํ…Œ์ŠคํŠธ ๋ฐ ๋””๋ฒ„๊น… ๋ฐฉ๋ฒ•
  9. ์‹ค์ „ ํ™œ์šฉ ์‚ฌ๋ก€์™€ ๋ฒ ์ŠคํŠธ ํ”„๋ž™ํ‹ฐ์Šค
  10. ์ž์ฃผ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ์™€ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

1. ํ‘ธ์‹œ ์•Œ๋ฆผ์ด ๋ญ๊ธธ๋ž˜? ๊ธฐ๋ณธ ๊ฐœ๋… ์ดํ•ดํ•˜๊ธฐ ๐Ÿค”

ํ‘ธ์‹œ ์•Œ๋ฆผ์€ ์•ฑ์„ ์‹คํ–‰ํ•˜์ง€ ์•Š์•„๋„ ์‚ฌ์šฉ์ž์˜ ๊ธฐ๊ธฐ์— ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋Š” ๊ฐ•๋ ฅํ•œ ์ปค๋ฎค๋‹ˆ์ผ€์ด์…˜ ๋„๊ตฌ์•ผ. ์ƒˆ๋กœ์šด ๋ฉ”์‹œ์ง€๊ฐ€ ๋„์ฐฉํ–ˆ์„ ๋•Œ, ํŠน๋ณ„ ํ• ์ธ ์ด๋ฒคํŠธ๊ฐ€ ์‹œ์ž‘๋์„ ๋•Œ, ๋˜๋Š” ์ค‘์š”ํ•œ ์—…๋ฐ์ดํŠธ๊ฐ€ ์žˆ์„ ๋•Œ ์‚ฌ์šฉ์ž์—๊ฒŒ ์ฆ‰์‹œ ์•Œ๋ ค์ค„ ์ˆ˜ ์žˆ์ง€. ๋งˆ์น˜ ์นœ๊ตฌ๊ฐ€ "์•ผ, ์ด๊ฑฐ ๋ด๋ด!"๋ผ๊ณ  ์–ด๊นจ๋ฅผ ํˆญ ์น˜๋Š” ๊ฒƒ๊ณผ ๊ฐ™์€ ๋А๋‚Œ์ด๋ž„๊นŒ? ๐Ÿ˜‰

ํ‘ธ์‹œ ์•Œ๋ฆผ์˜ ์ข…๋ฅ˜

  1. ๋กœ์ปฌ ํ‘ธ์‹œ ์•Œ๋ฆผ: ์•ฑ ๋‚ด์—์„œ ์ƒ์„ฑ๋˜์–ด ๊ธฐ๊ธฐ ์ž์ฒด์—์„œ ์Šค์ผ€์ค„๋ง๋˜๋Š” ์•Œ๋ฆผ์ด์•ผ. ์˜ˆ๋ฅผ ๋“ค๋ฉด, ์•Œ๋žŒ ์•ฑ์—์„œ ์„ค์ •ํ•œ ์‹œ๊ฐ„์ด ๋˜๋ฉด ์šธ๋ฆฌ๋Š” ์•Œ๋ฆผ์ด ๋ฐ”๋กœ ์ด๊ฑฐ์ง€.
  2. ์›๊ฒฉ ํ‘ธ์‹œ ์•Œ๋ฆผ: ์„œ๋ฒ„์—์„œ ๋ณด๋‚ด๋Š” ์•Œ๋ฆผ์œผ๋กœ, ์•ฑ์ด ์‹คํ–‰ ์ค‘์ด์ง€ ์•Š์•„๋„ ๋ฐ›์„ ์ˆ˜ ์žˆ์–ด. ์ƒˆ ๋ฉ”์‹œ์ง€ ์•Œ๋ฆผ์ด๋‚˜ ๋‰ด์Šค ์†๋ณด ๊ฐ™์€ ๊ฒƒ๋“ค์ด ์—ฌ๊ธฐ์— ํ•ด๋‹น๋ผ.
  3. ์‚ฌ์ผ๋ŸฐํŠธ ํ‘ธ์‹œ ์•Œ๋ฆผ: ์‚ฌ์šฉ์ž์—๊ฒŒ ๋ณด์ด์ง€ ์•Š์ง€๋งŒ ์•ฑ์„ ๊นจ์›Œ์„œ ๋ฐฑ๊ทธ๋ผ์šด๋“œ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•˜๊ฒŒ ํ•˜๋Š” ์•Œ๋ฆผ์ด์•ผ. ๋ฐ์ดํ„ฐ ๋™๊ธฐํ™” ๊ฐ™์€ ์ž‘์—…์— ์œ ์šฉํ•˜์ง€.
์„œ๋ฒ„ FCM ์‚ฌ์šฉ์ž ๊ธฐ๊ธฐ ์ƒˆ ๋ฉ”์‹œ์ง€! ์•Œ๋ฆผ ์š”์ฒญ ํ‘ธ์‹œ ์ „์†ก

ํ‘ธ์‹œ ์•Œ๋ฆผ์˜ ํ•ต์‹ฌ ์žฅ์ ์€ ์‚ฌ์šฉ์ž ์ฐธ์—ฌ๋„๋ฅผ ๋†’์ด๊ณ  ์•ฑ์˜ ํ™œ์„ฑ ์‚ฌ์šฉ์ž ์ˆ˜๋ฅผ ์œ ์ง€ํ•˜๋Š” ๋ฐ ์žˆ์–ด. ํŠนํžˆ ์š”์ฆ˜์ฒ˜๋Ÿผ ์•ฑ์ด ๋„˜์ณ๋‚˜๋Š” ์‹œ๋Œ€์— ์‚ฌ์šฉ์ž์˜ ๊ด€์‹ฌ์„ ๋‹ค์‹œ ๋Œ์–ด์˜ค๋Š” ๊ฑด ์ •๋ง ์ค‘์š”ํ•˜์ง€. ์žฌ๋Šฅ๋„ท ๊ฐ™์€ ํ”Œ๋žซํผ์—์„œ๋„ ์ƒˆ๋กœ์šด ์žฌ๋Šฅ์ด ๋“ฑ๋ก๋๊ฑฐ๋‚˜ ๋ฉ”์‹œ์ง€๊ฐ€ ์™”์„ ๋•Œ ํ‘ธ์‹œ ์•Œ๋ฆผ์œผ๋กœ ์•Œ๋ ค์ฃผ๋ฉด ์‚ฌ์šฉ์ž ๊ฒฝํ—˜์ด ํ›จ์”ฌ ์ข‹์•„์ง„๋‹ค๋Š” ๊ฑธ ์•Œ ์ˆ˜ ์žˆ์–ด.

๐Ÿ“Š ํ‘ธ์‹œ ์•Œ๋ฆผ ํšจ๊ณผ ํ†ต๊ณ„

โœ“ ์ ์ ˆํ•œ ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ๋ฐ›์€ ์‚ฌ์šฉ์ž๋Š” ์•ฑ ์ฐธ์—ฌ์œจ์ด ์ตœ๋Œ€ 88% ์ฆ๊ฐ€ํ•ด.

โœ“ ๊ฐœ์ธํ™”๋œ ํ‘ธ์‹œ ์•Œ๋ฆผ์€ ์ผ๋ฐ˜ ์•Œ๋ฆผ๋ณด๋‹ค ํด๋ฆญ๋ฅ ์ด 4๋ฐฐ ๋†’์•„.

โœ“ ํ•˜์ง€๋งŒ ๊ณผ๋„ํ•œ ์•Œ๋ฆผ์€ ์•ฑ ์‚ญ์ œ์˜ ์ฃผ์š” ์›์ธ ์ค‘ ํ•˜๋‚˜์ด๊ธฐ๋„ ํ•ด.

2. React Native ํ‘ธ์‹œ ์•Œ๋ฆผ ๊ตฌํ˜„์„ ์œ„ํ•œ ์ค€๋น„๋ฌผ ๐Ÿงฐ

์ž, ์ด์ œ ๋ณธ๊ฒฉ์ ์œผ๋กœ React Native์—์„œ ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ๊ตฌํ˜„ํ•˜๊ธฐ ์œ„ํ•œ ์ค€๋น„๋ฌผ์„ ์•Œ์•„๋ณด์ž! ๋งˆ์น˜ ์š”๋ฆฌ๋ฅผ ์‹œ์ž‘ํ•˜๊ธฐ ์ „์— ์žฌ๋ฃŒ๋ฅผ ์ค€๋น„ํ•˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ, ํ‘ธ์‹œ ์•Œ๋ฆผ ๊ตฌํ˜„๋„ ๋ช‡ ๊ฐ€์ง€ ํ•„์ˆ˜ ๋„๊ตฌ์™€ ์„ค์ •์ด ํ•„์š”ํ•ด. ๐Ÿณ

ํ•„์ˆ˜ ์ค€๋น„๋ฌผ

  1. React Native ํ”„๋กœ์ ํŠธ: ๋‹น์—ฐํžˆ React Native๋กœ ๋งŒ๋“  ์•ฑ ํ”„๋กœ์ ํŠธ๊ฐ€ ํ•„์š”ํ•˜๊ฒ ์ง€? ์•„์ง ์—†๋‹ค๋ฉด npx react-native init MyPushApp์œผ๋กœ ์ƒˆ ํ”„๋กœ์ ํŠธ๋ฅผ ๋งŒ๋“ค์–ด๋ณด์ž.
  2. ํ‘ธ์‹œ ์•Œ๋ฆผ ์„œ๋น„์Šค: Firebase Cloud Messaging(FCM)์ด ๊ฐ€์žฅ ๋„๋ฆฌ ์‚ฌ์šฉ๋ผ. iOS์™€ Android ๋ชจ๋‘ ์ง€์›ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ํฌ๋กœ์Šค ํ”Œ๋žซํผ ์•ฑ์— ๋”ฑ์ด์•ผ!
  3. iOS ๊ฐœ๋ฐœ์ž ๊ณ„์ •: iOS ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ํ…Œ์ŠคํŠธํ•˜๋ ค๋ฉด Apple Developer Program ๋ฉค๋ฒ„์‹ญ($99/๋…„)์ด ํ•„์š”ํ•ด.
  4. ์ธ์ฆ์„œ์™€ ํ‚ค: iOS์˜ ๊ฒฝ์šฐ ํ‘ธ์‹œ ์•Œ๋ฆผ ์ธ์ฆ์„œ, Android๋Š” Firebase ํ”„๋กœ์ ํŠธ์˜ ์„œ๋ฒ„ ํ‚ค๊ฐ€ ํ•„์š”ํ•ด.
  5. ํ‘ธ์‹œ ์•Œ๋ฆผ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ: react-native-push-notification์ด๋‚˜ @react-native-firebase/messaging ๊ฐ™์€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๊ตฌํ˜„์ด ํ›จ์”ฌ ์‰ฌ์›Œ์ ธ.

๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์„ค์น˜ํ•˜๊ธฐ

๊ฐ€์žฅ ๋งŽ์ด ์‚ฌ์šฉ๋˜๋Š” ๋‘ ๊ฐ€์ง€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์†Œ๊ฐœํ• ๊ฒŒ:

1. react-native-push-notification

npm install --save react-native-push-notification
# ๋˜๋Š”
yarn add react-native-push-notification

# iOS์˜ ๊ฒฝ์šฐ ์ถ”๊ฐ€ ์„ค์น˜ ํ•„์š”
cd ios && pod install

2. @react-native-firebase/messaging

npm install --save @react-native-firebase/app @react-native-firebase/messaging
# ๋˜๋Š”
yarn add @react-native-firebase/app @react-native-firebase/messaging

# iOS์˜ ๊ฒฝ์šฐ ์ถ”๊ฐ€ ์„ค์น˜ ํ•„์š”
cd ios && pod install

๋‘ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ค‘ ์–ด๋–ค ๊ฑธ ์„ ํƒํ•ด์•ผ ํ• ์ง€ ๊ณ ๋ฏผ๋œ๋‹ค๋ฉด, Firebase ์ƒํƒœ๊ณ„๋ฅผ ๋” ๋งŽ์ด ํ™œ์šฉํ•  ๊ณ„ํš์ด๋ผ๋ฉด @react-native-firebase/messaging์„, ๋” ๊ฐ„๋‹จํ•œ ์„ค์ •๊ณผ ๋กœ์ปฌ ์•Œ๋ฆผ ๊ธฐ๋Šฅ์ด ํ•„์š”ํ•˜๋‹ค๋ฉด react-native-push-notification์„ ์ถ”์ฒœํ•ด. ์ด ๊ธ€์—์„œ๋Š” ๋‘ ๊ฐ€์ง€ ๋ฐฉ๋ฒ• ๋ชจ๋‘ ๋‹ค๋ฃฐ ๊ฑฐ๋‹ˆ๊นŒ ๊ฑฑ์ •ํ•˜์ง€ ๋งˆ! ๐Ÿ˜Š

๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋น„๊ต

๊ธฐ๋Šฅ react-native-push-notification @react-native-firebase/messaging
์„ค์น˜ ๋‚œ์ด๋„ โญโญโญ (์ค‘๊ฐ„) โญโญโญโญ (์•ฝ๊ฐ„ ๋ณต์žก)
๋กœ์ปฌ ์•Œ๋ฆผ โœ… ์ง€์› โŒ ๋ณ„๋„ ์„ค์ • ํ•„์š”
์›๊ฒฉ ์•Œ๋ฆผ โœ… ์ง€์› โœ… ์ง€์›
Firebase ํ†ตํ•ฉ โญโญ (๊ธฐ๋ณธ) โญโญโญโญโญ (์™„๋ฒฝ)
์ปค์Šคํ„ฐ๋งˆ์ด์ง• โญโญโญโญ (๋‹ค์–‘ํ•œ ์˜ต์…˜) โญโญโญ (Firebase ๋ฐฉ์‹)
๋ฌธ์„œํ™” โญโญโญ (์ ์ ˆํ•จ) โญโญโญโญ (์ƒ์„ธํ•จ)

์ด์ œ ํ•„์š”ํ•œ ๋„๊ตฌ๋“ค์„ ์•Œ์•˜์œผ๋‹ˆ, ๋‹ค์Œ ๋‹จ๊ณ„๋กœ ๋„˜์–ด๊ฐ€์„œ Firebase Cloud Messaging์„ ์„ค์ •ํ•ด๋ณด์ž! ๐Ÿ”ฅ

3. Firebase Cloud Messaging(FCM) ์„ค์ •ํ•˜๊ธฐ ๐Ÿ”ฅ

Firebase Cloud Messaging(FCM)์€ ๊ตฌ๊ธ€์—์„œ ์ œ๊ณตํ•˜๋Š” ๋ฌด๋ฃŒ ํฌ๋กœ์Šค ํ”Œ๋žซํผ ๋ฉ”์‹œ์ง• ์†”๋ฃจ์…˜์ด์•ผ. iOS์™€ Android ๋ชจ๋‘ ์ง€์›ํ•˜๊ธฐ ๋•Œ๋ฌธ์— React Native ์•ฑ์—์„œ ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ๊ตฌํ˜„ํ•  ๋•Œ ๊ฐ€์žฅ ๋งŽ์ด ์‚ฌ์šฉ๋ผ. ๋งˆ์น˜ ์šฐ์ฒด๋ถ€์ฒ˜๋Ÿผ ์šฐ๋ฆฌ ์•ฑ์˜ ๋ฉ”์‹œ์ง€๋ฅผ ์‚ฌ์šฉ์ž์—๊ฒŒ ์•ˆ์ „ํ•˜๊ฒŒ ์ „๋‹ฌํ•ด์ฃผ๋Š” ์—ญํ• ์„ ํ•œ๋‹ค๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋ผ! ๐Ÿ“ฎ

Firebase ํ”„๋กœ์ ํŠธ ์„ค์ • ๋‹จ๊ณ„

  1. Firebase ์ฝ˜์†” ์ ‘์†ํ•˜๊ธฐ

    ๋จผ์ € Firebase ์ฝ˜์†”์— ์ ‘์†ํ•ด์„œ Google ๊ณ„์ •์œผ๋กœ ๋กœ๊ทธ์ธํ•ด. ์•„์ง ๊ณ„์ •์ด ์—†๋‹ค๋ฉด ๋งŒ๋“ค์–ด์•ผ ํ•ด.

  2. ์ƒˆ ํ”„๋กœ์ ํŠธ ๋งŒ๋“ค๊ธฐ

    "ํ”„๋กœ์ ํŠธ ์ถ”๊ฐ€" ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๊ณ  ํ”„๋กœ์ ํŠธ ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด. ์˜ˆ๋ฅผ ๋“ค๋ฉด "MyPushApp"์ด๋ผ๊ณ  ์ง€์„ ์ˆ˜ ์žˆ์–ด. ๊ทธ๋ฆฌ๊ณ  ์•ฝ๊ด€์— ๋™์˜ํ•˜๊ณ  "๊ณ„์†" ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ด.

  3. Google ์• ๋„๋ฆฌํ‹ฑ์Šค ์„ค์ •

    Google ์• ๋„๋ฆฌํ‹ฑ์Šค๋ฅผ ์‚ฌ์šฉํ• ์ง€ ์„ ํƒํ•ด. ํ‘ธ์‹œ ์•Œ๋ฆผ ์„ฑ๊ณผ๋ฅผ ์ธก์ •ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ํ™œ์„ฑํ™”ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์•„. ์„ค์ •์„ ๋งˆ์น˜๊ณ  "ํ”„๋กœ์ ํŠธ ๋งŒ๋“ค๊ธฐ" ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ด.

  4. Android ์•ฑ ๋“ฑ๋กํ•˜๊ธฐ

    ํ”„๋กœ์ ํŠธ๊ฐ€ ์ƒ์„ฑ๋˜๋ฉด Android ์•ฑ์„ ์ถ”๊ฐ€ํ•ด์•ผ ํ•ด. "Android" ์•„์ด์ฝ˜์„ ํด๋ฆญํ•˜๊ณ  ํŒจํ‚ค์ง€ ์ด๋ฆ„(์˜ˆ: com.mypushapp)์„ ์ž…๋ ฅํ•ด. ์ด ํŒจํ‚ค์ง€ ์ด๋ฆ„์€ android/app/build.gradle ํŒŒ์ผ์˜ applicationId์™€ ์ผ์น˜ํ•ด์•ผ ํ•ด.

  5. google-services.json ๋‹ค์šด๋กœ๋“œ

    ์•ฑ ๋“ฑ๋ก์ด ์™„๋ฃŒ๋˜๋ฉด google-services.json ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œ ๋ฐ›์„ ์ˆ˜ ์žˆ์–ด. ์ด ํŒŒ์ผ์„ android/app/ ๋””๋ ‰ํ† ๋ฆฌ์— ๋„ฃ์–ด์ค˜.

  6. iOS ์•ฑ ๋“ฑ๋กํ•˜๊ธฐ

    iOS ์•ฑ๋„ ์ง€์›ํ•˜๋ ค๋ฉด "iOS" ์•„์ด์ฝ˜์„ ํด๋ฆญํ•˜๊ณ  Bundle ID(์˜ˆ: org.reactjs.native.example.MyPushApp)๋ฅผ ์ž…๋ ฅํ•ด. ์ด ID๋Š” Xcode ํ”„๋กœ์ ํŠธ ์„ค์ •์˜ Bundle Identifier์™€ ์ผ์น˜ํ•ด์•ผ ํ•ด.

  7. GoogleService-Info.plist ๋‹ค์šด๋กœ๋“œ

    iOS ์•ฑ ๋“ฑ๋ก์ด ์™„๋ฃŒ๋˜๋ฉด GoogleService-Info.plist ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œ ๋ฐ›์„ ์ˆ˜ ์žˆ์–ด. ์ด ํŒŒ์ผ์„ Xcode ํ”„๋กœ์ ํŠธ์— ์ถ”๊ฐ€ํ•ด์•ผ ํ•ด. Xcode๋ฅผ ์—ด๊ณ  ํŒŒ์ผ์„ ๋“œ๋ž˜๊ทธ ์•ค ๋“œ๋กญํ•˜๋ฉด ๋ผ.

Firebase ์„ค์ • ๊ณผ์ • 1 Firebase ์ฝ˜์†” ์ ‘์† 2 ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ 3 ์•ฑ ๋“ฑ๋ก 4 ์„ค์ • ํŒŒ์ผ ๋‹ค์šด๋กœ๋“œ 5 ํ”„๋กœ์ ํŠธ์— ํŒŒ์ผ ์ถ”๊ฐ€ 6 ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์„ค์น˜

Android ํ”„๋กœ์ ํŠธ ์„ค์ •

Firebase์—์„œ ๋‹ค์šด๋กœ๋“œํ•œ google-services.json ํŒŒ์ผ์„ ํ”„๋กœ์ ํŠธ์— ์ถ”๊ฐ€ํ•œ ํ›„, ๋‹ค์Œ ์„ค์ •์„ ํ•ด์ค˜์•ผ ํ•ด:

  1. ํ”„๋กœ์ ํŠธ ์ˆ˜์ค€ build.gradle ์ˆ˜์ •
    // android/build.gradle
    buildscript {
        dependencies {
            // ... ๊ธฐ์กด ์˜์กด์„ฑ
            classpath 'com.google.gms:google-services:4.3.10'  // Google Services ํ”Œ๋Ÿฌ๊ทธ์ธ
        }
    }
  2. ์•ฑ ์ˆ˜์ค€ build.gradle ์ˆ˜์ •
    // android/app/build.gradle
    apply plugin: 'com.android.application'
    apply plugin: 'com.google.gms.google-services'  // Google Services ํ”Œ๋Ÿฌ๊ทธ์ธ ์ ์šฉ
    
    dependencies {
        // ... ๊ธฐ์กด ์˜์กด์„ฑ
        implementation 'com.google.firebase:firebase-messaging:23.0.0'  // FCM ์˜์กด์„ฑ ์ถ”๊ฐ€
    }

iOS ํ”„๋กœ์ ํŠธ ์„ค์ •

iOS์˜ ๊ฒฝ์šฐ ๋ช‡ ๊ฐ€์ง€ ์ถ”๊ฐ€ ์„ค์ •์ด ํ•„์š”ํ•ด:

  1. Podfile ์ˆ˜์ •
    // ios/Podfile
    target 'MyPushApp' do
      # ...
      pod 'Firebase/Core'
      pod 'Firebase/Messaging'
    end
  2. AppDelegate.m ์ˆ˜์ •
    #import <UserNotifications/UserNotifications.h>
    #import <Firebase.h>
    
    @implementation AppDelegate
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
      // ...
      [FIRApp configure];  // Firebase ์ดˆ๊ธฐํ™”
      
      // ํ‘ธ์‹œ ์•Œ๋ฆผ ๊ถŒํ•œ ์š”์ฒญ
      if ([UNUserNotificationCenter class] != nil) {
        UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
        center.delegate = self;
        [center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error) {
        }];
      }
      
      [application registerForRemoteNotifications];
      
      return YES;
    }
  3. Capabilities ์„ค์ •

    Xcode์—์„œ ํ”„๋กœ์ ํŠธ ์„ค์ • > Signing & Capabilities ํƒญ์œผ๋กœ ์ด๋™ํ•ด์„œ "+" ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๊ณ  "Push Notifications"์™€ "Background Modes"๋ฅผ ์ถ”๊ฐ€ํ•ด. Background Modes์—์„œ๋Š” "Remote notifications"๋ฅผ ์ฒดํฌํ•ด์ค˜.

์—ฌ๊ธฐ๊นŒ์ง€ Firebase ์„ค์ •์ด ์™„๋ฃŒ๋์–ด! ์ด์ œ FCM์„ ํ†ตํ•ด ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ๋ณด๋‚ด๊ณ  ๋ฐ›์„ ์ค€๋น„๊ฐ€ ๋œ ๊ฑฐ์•ผ. ๋‹ค์Œ ๋‹จ๊ณ„์—์„œ๋Š” iOS์™€ Android์—์„œ ๊ฐ๊ฐ ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ๊ตฌํ˜„ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ž์„ธํžˆ ์•Œ์•„๋ณผ๊ฒŒ. ๐Ÿš€

4. iOS์—์„œ ํ‘ธ์‹œ ์•Œ๋ฆผ ๊ตฌํ˜„ํ•˜๊ธฐ ๐ŸŽ

iOS์—์„œ ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ๊ตฌํ˜„ํ•˜๋Š” ๊ฑด Android๋ณด๋‹ค ์กฐ๊ธˆ ๋” ๊นŒ๋‹ค๋กœ์šธ ์ˆ˜ ์žˆ์–ด. Apple์˜ ์—„๊ฒฉํ•œ ๋ณด์•ˆ ์ •์ฑ… ๋•Œ๋ฌธ์ด์ง€. ํ•˜์ง€๋งŒ ์ฐจ๊ทผ์ฐจ๊ทผ ๋”ฐ๋ผ์˜ค๋ฉด ์–ด๋ ต์ง€ ์•Š์•„! ๋งˆ์น˜ ์• ํ”Œ ํŒŒ์ด๋ฅผ ๋งŒ๋“œ๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ์ •ํ™•ํ•œ ๋ ˆ์‹œํ”ผ๋งŒ ๋”ฐ๋ฅด๋ฉด ๋ผ. ๐Ÿฅง

iOS ํ‘ธ์‹œ ์•Œ๋ฆผ ๊ตฌํ˜„ ์ „ ํ•„์ˆ˜ ์š”์†Œ

  1. Apple Developer Program ๋ฉค๋ฒ„์‹ญ: iOS ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ํ…Œ์ŠคํŠธํ•˜๋ ค๋ฉด ๋ฐ˜๋“œ์‹œ ํ•„์š”ํ•ด ($99/๋…„).
  2. ์‹ค์ œ iOS ๊ธฐ๊ธฐ: ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ์—์„œ๋Š” ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ํ…Œ์ŠคํŠธํ•  ์ˆ˜ ์—†์–ด. ์‹ค์ œ iPhone์ด๋‚˜ iPad๊ฐ€ ํ•„์š”ํ•ด.
  3. APNs ์ธ์ฆ์„œ: Apple Push Notification service ์ธ์ฆ์„œ๋ฅผ ๋ฐœ๊ธ‰๋ฐ›์•„์•ผ ํ•ด.

APNs ์ธ์ฆ์„œ ๋ฐœ๊ธ‰ ๋ฐฉ๋ฒ•

  1. Apple Developer ๊ณ„์ • ๋กœ๊ทธ์ธ

    Apple Developer ์‚ฌ์ดํŠธ์— ๋กœ๊ทธ์ธํ•ด.

  2. ์ธ์ฆ์„œ ์ƒ์„ฑ

    Certificates, Identifiers & Profiles > Certificates > "+" ๋ฒ„ํŠผ ํด๋ฆญ > Apple Push Notification service SSL (Sandbox & Production) ์„ ํƒ.

  3. App ID ์„ ํƒ

    ์ธ์ฆ์„œ๋ฅผ ์ƒ์„ฑํ•  App ID๋ฅผ ์„ ํƒํ•ด. ์ด App ID๋Š” ์•ฑ์˜ Bundle Identifier์™€ ์ผ์น˜ํ•ด์•ผ ํ•ด.

  4. CSR ํŒŒ์ผ ์—…๋กœ๋“œ

    Certificate Signing Request(CSR) ํŒŒ์ผ์ด ํ•„์š”ํ•ด. Mac์˜ ํ‚ค์ฒด์ธ ์ ‘๊ทผ์—์„œ "์ธ์ฆ์„œ ์ง€์› > ์ธ์ฆ ๊ธฐ๊ด€์—์„œ ์ธ์ฆ์„œ ์š”์ฒญ" ๋ฉ”๋‰ด๋ฅผ ํ†ตํ•ด ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์–ด.

  5. ์ธ์ฆ์„œ ๋‹ค์šด๋กœ๋“œ ๋ฐ ์„ค์น˜

    ์ƒ์„ฑ๋œ ์ธ์ฆ์„œ๋ฅผ ๋‹ค์šด๋กœ๋“œํ•˜๊ณ  ๋”๋ธ”ํด๋ฆญํ•ด์„œ ํ‚ค์ฒด์ธ์— ์„ค์น˜ํ•ด.

  6. p12 ํŒŒ์ผ ๋‚ด๋ณด๋‚ด๊ธฐ

    ํ‚ค์ฒด์ธ์—์„œ ์„ค์น˜๋œ ์ธ์ฆ์„œ๋ฅผ ์ฐพ์•„ ์šฐํด๋ฆญ > "๋‚ด๋ณด๋‚ด๊ธฐ"๋ฅผ ์„ ํƒํ•ด p12 ํ˜•์‹์œผ๋กœ ์ €์žฅํ•ด. ์ด ํŒŒ์ผ์€ Firebase ์ฝ˜์†”์—์„œ ์‚ฌ์šฉํ•  ๊ฑฐ์•ผ.

Firebase์— APNs ์ธ์ฆ์„œ ์—…๋กœ๋“œ

  1. Firebase ์ฝ˜์†”์—์„œ ํ”„๋กœ์ ํŠธ ์„ค์ •์œผ๋กœ ์ด๋™ํ•ด.
  2. "Cloud Messaging" ํƒญ์„ ์„ ํƒํ•ด.
  3. iOS ์•ฑ ๊ตฌ์„ฑ ์„น์…˜์—์„œ "APNs ์ธ์ฆ์„œ ์—…๋กœ๋“œ" ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ด.
  4. ์•ž์„œ ๋‚ด๋ณด๋‚ธ p12 ํŒŒ์ผ๊ณผ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜๊ณ  ์—…๋กœ๋“œํ•ด.
iOS ํ‘ธ์‹œ ์•Œ๋ฆผ ํ๋ฆ„๋„ APNs Firebase ์•ฑ iOS ์•ฑ 2. ํ‘ธ์‹œ ์ „์†ก 3. ์•ฑ์— ์•Œ๋ฆผ ์ „๋‹ฌ 1. ํ† ํฐ ๋“ฑ๋ก ๋ฐ ์ธ์ฆ APNs(Apple Push Notification service)๋ฅผ ํ†ตํ•ด iOS ๊ธฐ๊ธฐ๋กœ ํ‘ธ์‹œ ์•Œ๋ฆผ์ด ์ „๋‹ฌ๋ฉ๋‹ˆ๋‹ค

React Native ์ฝ”๋“œ ๊ตฌํ˜„

์ด์ œ React Native ์ฝ”๋“œ์—์„œ ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ์•„๋ณด์ž. ์—ฌ๊ธฐ์„œ๋Š” @react-native-firebase/messaging ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ• ๊ฒŒ:

import React, { useEffect } from 'react';
import { Alert, Platform } from 'react-native';
import messaging from '@react-native-firebase/messaging';

function App() {
  // FCM ํ† ํฐ ์š”์ฒญ ๋ฐ ์ €์žฅ
  async function requestUserPermission() {
    const authStatus = await messaging().requestPermission();
    const enabled =
      authStatus === messaging.AuthorizationStatus.AUTHORIZED ||
      authStatus === messaging.AuthorizationStatus.PROVISIONAL;

    if (enabled) {
      console.log('Authorization status:', authStatus);
      getFcmToken();
    }
  }

  // FCM ํ† ํฐ ๊ฐ€์ ธ์˜ค๊ธฐ
  const getFcmToken = async () => {
    const fcmToken = await messaging().getToken();
    if (fcmToken) {
      console.log('Your Firebase Token is:', fcmToken);
      // ์—ฌ๊ธฐ์„œ ํ† ํฐ์„ ์„œ๋ฒ„์— ์ €์žฅํ•˜๋Š” API ํ˜ธ์ถœ
    } else {
      console.log('Failed to get FCM token');
    }
  };

  useEffect(() => {
    // iOS์—์„œ๋งŒ ๊ถŒํ•œ ์š”์ฒญ์ด ํ•„์š”ํ•จ
    if (Platform.OS === 'ios') {
      requestUserPermission();
    } else {
      getFcmToken();
    }

    // ํฌ๊ทธ๋ผ์šด๋“œ ์ƒํƒœ์—์„œ ๋ฉ”์‹œ์ง€ ์ˆ˜์‹ 
    const unsubscribe = messaging().onMessage(async remoteMessage => {
      Alert.alert('์ƒˆ ์•Œ๋ฆผ!', JSON.stringify(remoteMessage));
    });

    // ๋ฐฑ๊ทธ๋ผ์šด๋“œ์—์„œ ์•ฑ์ด ์—ด๋ ธ์„ ๋•Œ
    messaging().onNotificationOpenedApp(remoteMessage => {
      console.log(
        'Notification caused app to open from background state:',
        remoteMessage,
      );
      // ์—ฌ๊ธฐ์„œ ํŠน์ • ํ™”๋ฉด์œผ๋กœ ๋„ค๋น„๊ฒŒ์ด์…˜ ์ฒ˜๋ฆฌ
    });

    // ์•ฑ์ด ์ข…๋ฃŒ๋œ ์ƒํƒœ์—์„œ ์—ด๋ ธ์„ ๋•Œ
    messaging()
      .getInitialNotification()
      .then(remoteMessage => {
        if (remoteMessage) {
          console.log(
            'Notification caused app to open from quit state:',
            remoteMessage,
          );
          // ์—ฌ๊ธฐ์„œ ํŠน์ • ํ™”๋ฉด์œผ๋กœ ๋„ค๋น„๊ฒŒ์ด์…˜ ์ฒ˜๋ฆฌ
        }
      });

    return unsubscribe;
  }, []);

  return (
    // ์•ฑ ์ปดํฌ๋„ŒํŠธ
  );
}

iOS ์•Œ๋ฆผ ์นดํ…Œ๊ณ ๋ฆฌ ์„ค์ •ํ•˜๊ธฐ

iOS์—์„œ๋Š” ์•Œ๋ฆผ ์นดํ…Œ๊ณ ๋ฆฌ๋ฅผ ์„ค์ •ํ•ด ์‚ฌ์šฉ์ž๊ฐ€ ์•Œ๋ฆผ์—์„œ ๋ฐ”๋กœ ์•ก์…˜์„ ์ทจํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•  ์ˆ˜ ์žˆ์–ด. ์˜ˆ๋ฅผ ๋“ค์–ด, ๋ฉ”์‹œ์ง€ ์•Œ๋ฆผ์—์„œ "๋‹ต์žฅ" ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ๋ฐ”๋กœ ๋‹ต์žฅ ํ™”๋ฉด์ด ๋œจ๋Š” ์‹์ด์ง€.

// AppDelegate.m์— ์ถ”๊ฐ€
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
  // ์นดํ…Œ๊ณ ๋ฆฌ ์„ค์ •
  UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  
  // "์ฑ„ํŒ…" ์นดํ…Œ๊ณ ๋ฆฌ ์ƒ์„ฑ
  UNNotificationAction *replyAction = [UNNotificationAction actionWithIdentifier:@"REPLY_ACTION"
                                                                 title:@"๋‹ต์žฅ"
                                                               options:UNNotificationActionOptionForeground];
  
  UNNotificationCategory *chatCategory = [UNNotificationCategory categoryWithIdentifier:@"CHAT_CATEGORY"
                                                                actions:@[replyAction]
                                                      intentIdentifiers:@[]
                                                                options:UNNotificationCategoryOptionNone];
  
  [center setNotificationCategories:[NSSet setWithObjects:chatCategory, nil]];
}

iOS์—์„œ ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ๊ตฌํ˜„ํ•  ๋•Œ ๊ฐ€์žฅ ์ค‘์š”ํ•œ ๊ฒƒ์€ ์‚ฌ์šฉ์ž ๊ฒฝํ—˜์ด์•ผ. ๋„ˆ๋ฌด ๋งŽ์€ ์•Œ๋ฆผ์„ ๋ณด๋‚ด๋ฉด ์‚ฌ์šฉ์ž๊ฐ€ ์•Œ๋ฆผ์„ ๋Œ ์ˆ˜ ์žˆ์œผ๋‹ˆ ์ ์ ˆํ•œ ํƒ€์ด๋ฐ์— ์œ ์šฉํ•œ ์ •๋ณด๋ฅผ ๋‹ด์€ ์•Œ๋ฆผ์„ ๋ณด๋‚ด๋Š” ๊ฒŒ ์ค‘์š”ํ•ด. ์žฌ๋Šฅ๋„ท ๊ฐ™์€ ์„œ๋น„์Šค์—์„œ๋Š” ์ƒˆ๋กœ์šด ๋ฉ”์‹œ์ง€๋‚˜ ๊ฑฐ๋ž˜ ์ œ์•ˆ์ด ์™”์„ ๋•Œ ์•Œ๋ฆผ์„ ๋ณด๋‚ด๋ฉด ์‚ฌ์šฉ์ž ์ฐธ์—ฌ๋„๋ฅผ ๋†’์ผ ์ˆ˜ ์žˆ์„ ๊ฑฐ์•ผ! ๐Ÿ“ฑ

5. Android์—์„œ ํ‘ธ์‹œ ์•Œ๋ฆผ ๊ตฌํ˜„ํ•˜๊ธฐ ๐Ÿค–

Android์—์„œ ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ๊ตฌํ˜„ํ•˜๋Š” ๊ฑด iOS๋ณด๋‹ค ๋น„๊ต์  ๊ฐ„๋‹จํ•ด. Google Play ์„œ๋น„์Šค๊ฐ€ ๊ธฐ๋ณธ์ ์œผ๋กœ ์„ค์น˜๋œ ๋Œ€๋ถ€๋ถ„์˜ Android ๊ธฐ๊ธฐ์—์„œ๋Š” ๋ณ„๋„์˜ ์ธ์ฆ์„œ ์—†์ด๋„ FCM์„ ํ†ตํ•ด ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ๋ณด๋‚ผ ์ˆ˜ ์žˆ๊ฑฐ๋“ . ๋งˆ์น˜ ์•ˆ๋“œ๋กœ์ด๋“œ ๋งˆ์Šค์ฝ”ํŠธ์ฒ˜๋Ÿผ ์นœ์ ˆํ•˜๊ฒŒ ๋„์™€์ฃผ๋Š” ๋А๋‚Œ์ด๋ž„๊นŒ? ๐Ÿค–

AndroidManifest.xml ์„ค์ •

Android์—์„œ ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ๋ฐ›์œผ๋ ค๋ฉด ๋จผ์ € ๋งค๋‹ˆํŽ˜์ŠคํŠธ ํŒŒ์ผ์— ํ•„์š”ํ•œ ๊ถŒํ•œ์„ ์ถ”๊ฐ€ํ•ด์•ผ ํ•ด:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mypushapp">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

    <application
      android:name=".MainApplication"
      android:allowBackup="false"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:theme="@style/AppTheme">
      
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      
      <!-- FCM ์„œ๋น„์Šค ์ถ”๊ฐ€ -->
      <service
        android:name=".MyFirebaseMessagingService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
      </service>
      
    </application>
</manifest>

Firebase Messaging Service ๊ตฌํ˜„

๋‹ค์Œ์œผ๋กœ, FCM ๋ฉ”์‹œ์ง€๋ฅผ ์ฒ˜๋ฆฌํ•  ์„œ๋น„์Šค ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค์–ด์•ผ ํ•ด:

// android/app/src/main/java/com/mypushapp/MyFirebaseMessagingService.java

package com.mypushapp;

import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Build;
import androidx.core.app.NotificationCompat;

import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

public class MyFirebaseMessagingService extends FirebaseMessagingService {

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        // ๋ฐ์ดํ„ฐ ํŽ˜์ด๋กœ๋“œ๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ
        if (remoteMessage.getData().size() > 0) {
            // ์—ฌ๊ธฐ์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ฒ˜๋ฆฌ
            sendNotification(remoteMessage.getData().get("title"), 
                             remoteMessage.getData().get("body"));
        }

        // ์•Œ๋ฆผ ํŽ˜์ด๋กœ๋“œ๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ
        if (remoteMessage.getNotification() != null) {
            sendNotification(remoteMessage.getNotification().getTitle(), 
                             remoteMessage.getNotification().getBody());
        }
    }

    @Override
    public void onNewToken(String token) {
        // ์ƒˆ ํ† ํฐ์ด ์ƒ์„ฑ๋  ๋•Œ๋งˆ๋‹ค ์„œ๋ฒ„์— ํ† ํฐ์„ ๋ณด๋‚ด ์ €์žฅ
        sendRegistrationToServer(token);
    }

    private void sendRegistrationToServer(String token) {
        // ์—ฌ๊ธฐ์„œ ํ† ํฐ์„ ์„œ๋ฒ„์— ์ „์†กํ•˜๋Š” ๋กœ์ง ๊ตฌํ˜„
    }

    private void sendNotification(String title, String messageBody) {
        Intent intent = new Intent(this, MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
                PendingIntent.FLAG_ONE_SHOT);

        String channelId = "fcm_default_channel";
        Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.Builder notificationBuilder =
                new NotificationCompat.Builder(this, channelId)
                        .setSmallIcon(R.mipmap.ic_launcher)
                        .setContentTitle(title)
                        .setContentText(messageBody)
                        .setAutoCancel(true)
                        .setSound(defaultSoundUri)
                        .setContentIntent(pendingIntent);

        NotificationManager notificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        // Android Oreo ์ด์ƒ์—์„œ๋Š” ์ฑ„๋„ ์ƒ์„ฑ์ด ํ•„์š”
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            NotificationChannel channel = new NotificationChannel(channelId,
                    "Channel human readable title",
                    NotificationManager.IMPORTANCE_DEFAULT);
            notificationManager.createNotificationChannel(channel);
        }

        notificationManager.notify(0, notificationBuilder.build());
    }
}
Android ํ‘ธ์‹œ ์•Œ๋ฆผ ๊ตฌ์กฐ FCM ์„œ๋ฒ„ ์•ฑ ์„œ๋ฒ„ Android ์•ฑ FirebaseMessagingService NotificationManager MainActivity 1. ํ‘ธ์‹œ ๋ฉ”์‹œ์ง€ ์ „์†ก ํ† ํฐ ๋“ฑ๋ก 2. ๋ฉ”์‹œ์ง€ ์ˆ˜์‹  3. ์•Œ๋ฆผ ์ƒ์„ฑ 4. ์•Œ๋ฆผ ํด๋ฆญ ์‹œ ์‹คํ–‰

React Native์—์„œ Android ํ‘ธ์‹œ ์•Œ๋ฆผ ์ฒ˜๋ฆฌ

์ด์ œ React Native ์ฝ”๋“œ์—์„œ Android ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ์•„๋ณด์ž:

import React, { useEffect } from 'react';
import { Platform } from 'react-native';
import messaging from '@react-native-firebase/messaging';

function App() {
  // FCM ํ† ํฐ ๊ฐ€์ ธ์˜ค๊ธฐ
  const getFcmToken = async () => {
    const fcmToken = await messaging().getToken();
    if (fcmToken) {
      console.log('Your Firebase Token is:', fcmToken);
      // ์—ฌ๊ธฐ์„œ ํ† ํฐ์„ ์„œ๋ฒ„์— ์ €์žฅํ•˜๋Š” API ํ˜ธ์ถœ
    } else {
      console.log('Failed to get FCM token');
    }
  };

  useEffect(() => {
    getFcmToken();

    // ํ† ํฐ ๊ฐฑ์‹  ๋ฆฌ์Šค๋„ˆ
    const unsubscribe = messaging().onTokenRefresh(token => {
      console.log('FCM ํ† ํฐ์ด ๊ฐฑ์‹ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค:', token);
      // ์—ฌ๊ธฐ์„œ ์ƒˆ ํ† ํฐ์„ ์„œ๋ฒ„์— ์ €์žฅ
    });

    // ํฌ๊ทธ๋ผ์šด๋“œ ๋ฉ”์‹œ์ง€ ์ฒ˜๋ฆฌ
    const messageUnsubscribe = messaging().onMessage(async remoteMessage => {
      console.log('ํฌ๊ทธ๋ผ์šด๋“œ ๋ฉ”์‹œ์ง€:', remoteMessage);
      // ์—ฌ๊ธฐ์„œ ์ปค์Šคํ…€ ์•Œ๋ฆผ ํ‘œ์‹œ ๋กœ์ง ๊ตฌํ˜„
    });

    // ๋ฐฑ๊ทธ๋ผ์šด๋“œ์—์„œ ์•ฑ์ด ์—ด๋ ธ์„ ๋•Œ
    messaging().onNotificationOpenedApp(remoteMessage => {
      console.log('๋ฐฑ๊ทธ๋ผ์šด๋“œ์—์„œ ์•Œ๋ฆผ ํด๋ฆญ:', remoteMessage);
      // ์—ฌ๊ธฐ์„œ ํŠน์ • ํ™”๋ฉด์œผ๋กœ ๋„ค๋น„๊ฒŒ์ด์…˜
    });

    // ์•ฑ์ด ์ข…๋ฃŒ๋œ ์ƒํƒœ์—์„œ ์•Œ๋ฆผ์œผ๋กœ ์—ด๋ ธ์„ ๋•Œ
    messaging()
      .getInitialNotification()
      .then(remoteMessage => {
        if (remoteMessage) {
          console.log('์ข…๋ฃŒ ์ƒํƒœ์—์„œ ์•Œ๋ฆผ ํด๋ฆญ:', remoteMessage);
          // ์—ฌ๊ธฐ์„œ ํŠน์ • ํ™”๋ฉด์œผ๋กœ ๋„ค๋น„๊ฒŒ์ด์…˜
        }
      });

    return () => {
      unsubscribe();
      messageUnsubscribe();
    };
  }, []);

  return (
    // ์•ฑ ์ปดํฌ๋„ŒํŠธ
  );
}

Android ์•Œ๋ฆผ ์ฑ„๋„ ์„ค์ •ํ•˜๊ธฐ

Android 8.0(Oreo) ์ด์ƒ์—์„œ๋Š” ์•Œ๋ฆผ ์ฑ„๋„์„ ์„ค์ •ํ•ด์•ผ ํ•ด. ์ฑ„๋„์„ ํ†ตํ•ด ์‚ฌ์šฉ์ž๋Š” ํŠน์ • ์œ ํ˜•์˜ ์•Œ๋ฆผ๋งŒ ์„ ํƒ์ ์œผ๋กœ ๋ฐ›์„ ์ˆ˜ ์žˆ์–ด.

// ์•Œ๋ฆผ ์ฑ„๋„ ์ƒ์„ฑ ํ•จ์ˆ˜
import { Platform } from 'react-native';
import notifee, { AndroidImportance } from '@notifee/react-native';

async function createNotificationChannels() {
  if (Platform.OS === 'android') {
    // ์ค‘์š” ์•Œ๋ฆผ ์ฑ„๋„
    await notifee.createChannel({
      id: 'important',
      name: '์ค‘์š” ์•Œ๋ฆผ',
      description: '์ค‘์š”ํ•œ ์—…๋ฐ์ดํŠธ์™€ ๋ฉ”์‹œ์ง€๋ฅผ ์œ„ํ•œ ์ฑ„๋„',
      importance: AndroidImportance.HIGH,
    });

    // ์ผ๋ฐ˜ ์•Œ๋ฆผ ์ฑ„๋„
    await notifee.createChannel({
      id: 'default',
      name: '์ผ๋ฐ˜ ์•Œ๋ฆผ',
      description: '์ผ๋ฐ˜์ ์ธ ์ •๋ณด ์•Œ๋ฆผ์„ ์œ„ํ•œ ์ฑ„๋„',
      importance: AndroidImportance.DEFAULT,
    });

    // ๋งˆ์ผ€ํŒ… ์•Œ๋ฆผ ์ฑ„๋„
    await notifee.createChannel({
      id: 'marketing',
      name: '๋งˆ์ผ€ํŒ… ์•Œ๋ฆผ',
      description: 'ํ”„๋กœ๋ชจ์…˜๊ณผ ๋งˆ์ผ€ํŒ… ๋ฉ”์‹œ์ง€๋ฅผ ์œ„ํ•œ ์ฑ„๋„',
      importance: AndroidImportance.LOW,
    });
  }
}

Android์—์„œ ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ๊ตฌํ˜„ํ•  ๋•Œ๋Š” ์‚ฌ์šฉ์ž ๊ฒฝํ—˜๊ณผ ๋ฐฐํ„ฐ๋ฆฌ ์†Œ๋ชจ๋ฅผ ๊ท ํ˜• ์žˆ๊ฒŒ ๊ณ ๋ คํ•˜๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•ด. ํŠนํžˆ ์žฌ๋Šฅ๋„ท ๊ฐ™์€ ํ”Œ๋žซํผ์—์„œ๋Š” ๊ฑฐ๋ž˜๋‚˜ ๋ฉ”์‹œ์ง€ ๊ฐ™์€ ์ค‘์š” ์•Œ๋ฆผ๊ณผ ๋งˆ์ผ€ํŒ… ์•Œ๋ฆผ์„ ๋ถ„๋ฆฌํ•ด์„œ ์‚ฌ์šฉ์ž๊ฐ€ ์›ํ•˜๋Š” ์•Œ๋ฆผ๋งŒ ๋ฐ›์„ ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋ฉด ์ข‹์„ ๊ฑฐ์•ผ. ๐Ÿ”‹

6. react-native-push-notification ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ํ™œ์šฉํ•˜๊ธฐ ๐Ÿ“š

์ง€๊ธˆ๊นŒ์ง€ Firebase Messaging์„ ์ง์ ‘ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ์•„๋ดค์–ด. ํ•˜์ง€๋งŒ ๋” ์‰ฝ๊ฒŒ ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ๊ตฌํ˜„ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด react-native-push-notification ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ํ™œ์šฉํ•˜๋Š” ๊ฒƒ๋„ ์ข‹์€ ๋ฐฉ๋ฒ•์ด์•ผ. ์ด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋Š” FCM ์œ„์— ์ถ”์ƒํ™” ๋ ˆ์ด์–ด๋ฅผ ์ œ๊ณตํ•ด์„œ ๋” ๊ฐ„๋‹จํ•œ API๋กœ ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ค˜. ๋งˆ์น˜ ๋ณต์žกํ•œ ์š”๋ฆฌ ๊ณผ์ •์„ ๊ฐ„ํŽธ์‹์œผ๋กœ ๋งŒ๋“ค์–ด์ฃผ๋Š” ๋А๋‚Œ์ด๋ž„๊นŒ? ๐Ÿฒ

๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์„ค์น˜ ๋ฐ ์„ค์ •

๋จผ์ € ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์„ค์น˜ํ•ด๋ณด์ž:

npm install --save react-native-push-notification
# ๋˜๋Š”
yarn add react-native-push-notification

# iOS์˜ ๊ฒฝ์šฐ ์ถ”๊ฐ€ ์„ค์น˜ ํ•„์š”
npm install --save @react-native-community/push-notification-ios
# ๋˜๋Š”
yarn add @react-native-community/push-notification-ios

# ๊ทธ๋ฆฌ๊ณ  pod ์„ค์น˜
cd ios && pod install

Android ์„ค์ •

Android์—์„œ๋Š” ๋ช‡ ๊ฐ€์ง€ ์ถ”๊ฐ€ ์„ค์ •์ด ํ•„์š”ํ•ด:

  1. build.gradle ์ˆ˜์ •
    // android/build.gradle
    buildscript {
        dependencies {
            // ... ๊ธฐ์กด ์˜์กด์„ฑ
            classpath 'com.google.gms:google-services:4.3.10'  // Google Services ํ”Œ๋Ÿฌ๊ทธ์ธ
        }
    }
    
    // android/app/build.gradle
    apply plugin: 'com.android.application'
    apply plugin: 'com.google.gms.google-services'  // Google Services ํ”Œ๋Ÿฌ๊ทธ์ธ ์ ์šฉ
    
    dependencies {
        // ... ๊ธฐ์กด ์˜์กด์„ฑ
        implementation 'com.google.firebase:firebase-messaging:23.0.0'  // FCM ์˜์กด์„ฑ ์ถ”๊ฐ€
    }
  2. AndroidManifest.xml ์ˆ˜์ •
    <manifest ...>
        <uses-permission android:name="android.permission.VIBRATE" />
        <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    
        <application ...>
            <!-- ๋ณ€๊ฒฝ: launchMode๋ฅผ singleTop์œผ๋กœ ์„ค์ • -->
            <activity
                android:name=".MainActivity"
                android:launchMode="singleTop"
                ...>
            </activity>
    
            <!-- ์ถ”๊ฐ€: ๋ฆฌ์‹œ๋ฒ„ ๋“ฑ๋ก -->
            <meta-data android:name="com.dieam.reactnativepushnotification.notification_foreground"
                       android:value="false"/>
            <meta-data android:name="com.dieam.reactnativepushnotification.notification_color"
                       android:resource="@color/white"/>
    
            <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions" />
            <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
            <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
                <intent-filter>
                    <action android:name="android.intent.action.BOOT_COMPLETED" />
                    <action android:name="android.intent.action.QUICKBOOT_POWERON" />
                    <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
                </intent-filter>
            </receiver>
    
            <service
                android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
                android:exported="false" >
                <intent-filter>
                    <action android:name="com.google.firebase.MESSAGING_EVENT" />
                </intent-filter>
            </service>
        </application>
    </manifest>

iOS ์„ค์ •

iOS์—์„œ๋„ ๋ช‡ ๊ฐ€์ง€ ์„ค์ •์ด ํ•„์š”ํ•ด:

  1. AppDelegate.h ์ˆ˜์ •
    #import <UserNotifications/UNUserNotificationCenter.h>
    
    @interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate, UNUserNotificationCenterDelegate>
    // UNUserNotificationCenterDelegate ์ถ”๊ฐ€
    
  2. AppDelegate.m ์ˆ˜์ •
    #import <UserNotifications/UserNotifications.h>
    #import <RNCPushNotificationIOS.h>
    
    @implementation AppDelegate
    
    // ...
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
      // ...
      
      // ํ‘ธ์‹œ ์•Œ๋ฆผ ์„ค์ •
      UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
      center.delegate = self;
    
      return YES;
    }
    
    // ํ•„์ˆ˜ ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
    - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
    {
      [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
    }
    
    - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
    {
      [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
    }
    
    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
    {
      [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
    }
    
    - (void)userNotificationCenter:(UNUserNotificationCenter *)center
    didReceiveNotificationResponse:(UNNotificationResponse *)response
             withCompletionHandler:(void (^)(void))completionHandler
    {
      [RNCPushNotificationIOS didReceiveNotificationResponse:response];
      completionHandler();
    }
    
    - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
    {
      completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge);
    }
    
    @end
react-native-push-notification ์ž‘๋™ ๋ฐฉ์‹ React Native ์•ฑ react-native-push-notification iOS ๋ชจ๋“ˆ Android ๋ชจ๋“ˆ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ํ”Œ๋žซํผ๋ณ„ ํ‘ธ์‹œ ์•Œ๋ฆผ ๊ตฌํ˜„์˜ ๋ณต์žก์„ฑ์„ ์ถ”์ƒํ™”ํ•˜์—ฌ ๊ฐ„๋‹จํ•œ API ์ œ๊ณต ๋กœ์ปฌ ์•Œ๋ฆผ๊ณผ ์›๊ฒฉ ์•Œ๋ฆผ ๋ชจ๋‘ ํ†ตํ•ฉ๋œ ๋ฐฉ์‹์œผ๋กœ ์ฒ˜๋ฆฌ ๊ฐ€๋Šฅ

๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ ๋ฐฉ๋ฒ•

์ด์ œ React Native ์ฝ”๋“œ์—์„œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ดˆ๊ธฐํ™”ํ•˜๊ณ  ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ์•„๋ณด์ž:

import React, { useEffect } from 'react';
import { View, Text, Button } from 'react-native';
import PushNotification from 'react-native-push-notification';

// ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ดˆ๊ธฐํ™”
const configurePushNotifications = () => {
  PushNotification.configure({
    // FCM ํ† ํฐ ๋ฐœ๊ธ‰ ์‹œ ํ˜ธ์ถœ
    onRegister: function (token) {
      console.log('TOKEN:', token);
      // ์—ฌ๊ธฐ์„œ ํ† ํฐ์„ ์„œ๋ฒ„์— ์ €์žฅ
    },

    // ์•Œ๋ฆผ ์ˆ˜์‹  ์‹œ ํ˜ธ์ถœ (ํฌ๊ทธ๋ผ์šด๋“œ ์ƒํƒœ)
    onNotification: function (notification) {
      console.log('NOTIFICATION:', notification);
      
      // ํ•„์š”ํ•œ ๊ฒฝ์šฐ ์•Œ๋ฆผ ์ฒ˜๋ฆฌ (์˜ˆ: ํŠน์ • ํ™”๋ฉด์œผ๋กœ ์ด๋™)
      
      // iOS์—์„œ๋Š” ์ด ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•ด์•ผ ํ•จ
      notification.finish('backgroundFetchResultNoData');
    },

    // ๋“ฑ๋ก ์˜ค๋ฅ˜ ๋ฐœ์ƒ ์‹œ ํ˜ธ์ถœ
    onRegistrationError: function(err) {
      console.error(err.message, err);
    },

    // Android์—์„œ๋งŒ ์‚ฌ์šฉ๋˜๋Š” ์˜ต์…˜
    permissions: {
      alert: true,
      badge: true,
      sound: true,
    },

    // iOS์—์„œ ์•Œ๋ฆผ์ด ํฌ๊ทธ๋ผ์šด๋“œ์— ํ‘œ์‹œ๋˜๋„๋ก ์„ค์ •
    requestPermissions: true,
    
    // FCM ํ”„๋กœ์ ํŠธ ๋ฒˆํ˜ธ (Android๋งŒ ํ•ด๋‹น)
    senderID: 'YOUR_FCM_SENDER_ID',
    
    // ์•ฑ์ด ํฌ๊ทธ๋ผ์šด๋“œ์— ์žˆ์„ ๋•Œ๋„ ์•Œ๋ฆผ ํ‘œ์‹œ
    popInitialNotification: true,
    
    // ์•ฑ ์‹œ์ž‘ ์‹œ ์ดˆ๊ธฐ ์•Œ๋ฆผ ํ™•์ธ
    requestPermissions: Platform.OS === 'ios'
  });
  
  // Android ์ฑ„๋„ ์ƒ์„ฑ
  PushNotification.createChannel(
    {
      channelId: 'default-channel-id',
      channelName: '๊ธฐ๋ณธ ์ฑ„๋„',
      channelDescription: '๊ธฐ๋ณธ ์•Œ๋ฆผ ์ฑ„๋„',
      soundName: 'default',
      importance: 4, // ์ค‘์š”๋„ (1-5)
      vibrate: true,
    },
    (created) => console.log(`์ฑ„๋„ ์ƒ์„ฑ ${created ? '์„ฑ๊ณต' : '์‹คํŒจ'}`)
  );
};

function App() {
  useEffect(() => {
    configurePushNotifications();
  }, []);

  // ๋กœ์ปฌ ์•Œ๋ฆผ ๋ณด๋‚ด๊ธฐ ์˜ˆ์ œ
  const sendLocalNotification = () => {
    PushNotification.localNotification({
      channelId: 'default-channel-id', // Android์šฉ
      title: '๋กœ์ปฌ ์•Œ๋ฆผ ์ œ๋ชฉ',
      message: '์ด๊ฒƒ์€ ๋กœ์ปฌ ํ‘ธ์‹œ ์•Œ๋ฆผ์ž…๋‹ˆ๋‹ค!',
      playSound: true,
      soundName: 'default',
      importance: 'high', // Android์šฉ
      priority: 'high', // Android์šฉ
    });
  };

  // ์˜ˆ์•ฝ๋œ ๋กœ์ปฌ ์•Œ๋ฆผ ๋ณด๋‚ด๊ธฐ ์˜ˆ์ œ
  const scheduleNotification = () => {
    PushNotification.localNotificationSchedule({
      channelId: 'default-channel-id', // Android์šฉ
      title: '์˜ˆ์•ฝ๋œ ์•Œ๋ฆผ',
      message: '์ด ์•Œ๋ฆผ์€ 10์ดˆ ํ›„์— ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค!',
      date: new Date(Date.now() + 10 * 1000), // 10์ดˆ ํ›„
      allowWhileIdle: true, // Android์šฉ: ์ ˆ์ „ ๋ชจ๋“œ์—์„œ๋„ ์•Œ๋ฆผ ํ‘œ์‹œ
    });
  };

  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <Text>ํ‘ธ์‹œ ์•Œ๋ฆผ ํ…Œ์ŠคํŠธ</Text>
      <Button title="๋กœ์ปฌ ์•Œ๋ฆผ ๋ณด๋‚ด๊ธฐ" onPress={sendLocalNotification} />
      <Button title="10์ดˆ ํ›„ ์•Œ๋ฆผ ์˜ˆ์•ฝ" onPress={scheduleNotification} />
    </View>
  );
}

export default App;

๊ณ ๊ธ‰ ๊ธฐ๋Šฅ ํ™œ์šฉํ•˜๊ธฐ

react-native-push-notification ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋Š” ๋‹ค์–‘ํ•œ ๊ณ ๊ธ‰ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•ด:

  1. ์•Œ๋ฆผ ๋ฐฐ์ง€ ๊ด€๋ฆฌ
    // ๋ฐฐ์ง€ ์„ค์ •
    PushNotification.setApplicationIconBadgeNumber(5);
    
    // ๋ฐฐ์ง€ ๊ฐ€์ ธ์˜ค๊ธฐ
    PushNotification.getApplicationIconBadgeNumber(number => {
      console.log('ํ˜„์žฌ ๋ฐฐ์ง€ ์ˆ˜:', number);
    });
    
    // ๋ฐฐ์ง€ ์ดˆ๊ธฐํ™”
    PushNotification.setApplicationIconBadgeNumber(0);
  2. ์•Œ๋ฆผ ์ทจ์†Œํ•˜๊ธฐ
    // ํŠน์ • ID์˜ ์•Œ๋ฆผ ์ทจ์†Œ
    PushNotification.cancelLocalNotification('notificationId');
    
    // ๋ชจ๋“  ์•Œ๋ฆผ ์ทจ์†Œ
    PushNotification.cancelAllLocalNotifications();
  3. ์•Œ๋ฆผ ๊ทธ๋ฃนํ™”
    // Android์—์„œ ์•Œ๋ฆผ ๊ทธ๋ฃนํ™”
    PushNotification.localNotification({
      channelId: 'default-channel-id',
      title: '์ƒˆ ๋ฉ”์‹œ์ง€',
      message: '์ƒˆ๋กœ์šด ๋ฉ”์‹œ์ง€๊ฐ€ 5๊ฐœ ์žˆ์Šต๋‹ˆ๋‹ค',
      groupSummary: true,
      group: 'messages',
    });
  4. ์•Œ๋ฆผ ์•ก์…˜ ๋ฒ„ํŠผ
    // Android์—์„œ ์•Œ๋ฆผ์— ์•ก์…˜ ๋ฒ„ํŠผ ์ถ”๊ฐ€
    PushNotification.localNotification({
      channelId: 'default-channel-id',
      title: '์ƒˆ ๋ฉ”์‹œ์ง€',
      message: '์žฌ๋Šฅ๋„ท์—์„œ ์ƒˆ ๋ฉ”์‹œ์ง€๊ฐ€ ๋„์ฐฉํ–ˆ์Šต๋‹ˆ๋‹ค',
      actions: ['๋‹ต์žฅ', '๋‚˜์ค‘์—'],
    });

react-native-push-notification ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋Š” ํŠนํžˆ ๋กœ์ปฌ ์•Œ๋ฆผ์„ ์ž์ฃผ ์‚ฌ์šฉํ•˜๋Š” ์•ฑ์— ์œ ์šฉํ•ด. ์˜ˆ๋ฅผ ๋“ค์–ด, ์žฌ๋Šฅ๋„ท์—์„œ ์‚ฌ์šฉ์ž๊ฐ€ ์„ค์ •ํ•œ ๋งˆ๊ฐ์ผ์ด ๋‹ค๊ฐ€์˜ค๋ฉด ๋กœ์ปฌ ์•Œ๋ฆผ์œผ๋กœ ์ƒ๊ธฐ์‹œ์ผœ์ฃผ๊ฑฐ๋‚˜, ํŠน์ • ์‹œ๊ฐ„์— ์•ฑ ์‚ฌ์šฉ์„ ์ƒ๊ธฐ์‹œํ‚ค๋Š” ๊ธฐ๋Šฅ์„ ์‰ฝ๊ฒŒ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ์–ด. ์ด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด iOS์™€ Android ๋ชจ๋‘์—์„œ ์ผ๊ด€๋œ ๋ฐฉ์‹์œผ๋กœ ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ์–ด์„œ ๊ฐœ๋ฐœ ์‹œ๊ฐ„์„ ํฌ๊ฒŒ ๋‹จ์ถ•ํ•  ์ˆ˜ ์žˆ์–ด! ๐Ÿš€

7. ํ‘ธ์‹œ ์•Œ๋ฆผ ๋””์ž์ธ๊ณผ ์‚ฌ์šฉ์ž ๊ฒฝํ—˜ ์ตœ์ ํ™” ๐ŸŽจ

ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ๊ธฐ์ˆ ์ ์œผ๋กœ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒƒ๋„ ์ค‘์š”ํ•˜์ง€๋งŒ, ์‚ฌ์šฉ์ž๊ฐ€ ์‹ค์ œ๋กœ ์•Œ๋ฆผ์„ ํด๋ฆญํ•˜๊ณ  ์•ฑ์œผ๋กœ ๋Œ์•„์˜ค๊ฒŒ ๋งŒ๋“œ๋Š” ๊ฒƒ์ด ๋” ์ค‘์š”ํ•ด. ์•„๋ฌด๋ฆฌ ๊ธฐ์ˆ ์ ์œผ๋กœ ์™„๋ฒฝํ•œ ํ‘ธ์‹œ ์•Œ๋ฆผ์ด๋ผ๋„ ๋‚ด์šฉ์ด ๋งค๋ ฅ์ ์ด์ง€ ์•Š๊ฑฐ๋‚˜ ์‹œ๊ธฐ๊ฐ€ ๋ถ€์ ์ ˆํ•˜๋ฉด ์‚ฌ์šฉ์ž๋Š” ๊ทธ๋ƒฅ ๋ฌด์‹œํ•˜๊ฑฐ๋‚˜ ์‹ฌ์ง€์–ด ์•Œ๋ฆผ์„ ๊บผ๋ฒ„๋ฆด ์ˆ˜๋„ ์žˆ์–ด. ๋งˆ์น˜ ๋ง›์žˆ๋Š” ์Œ์‹์„ ์˜ˆ์˜๊ฒŒ ํ”Œ๋ ˆ์ดํŒ…ํ•˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ, ํ‘ธ์‹œ ์•Œ๋ฆผ๋„ ๋””์ž์ธ๊ณผ ํƒ€์ด๋ฐ์ด ์ค‘์š”ํ•˜์ง€! ๐Ÿฝ๏ธ

ํšจ๊ณผ์ ์ธ ํ‘ธ์‹œ ์•Œ๋ฆผ ๋””์ž์ธ ์›์น™

  1. ๊ฐ„๊ฒฐํ•˜๊ณ  ๋ช…ํ™•ํ•œ ๋ฉ”์‹œ์ง€

    ํ‘ธ์‹œ ์•Œ๋ฆผ์€ ๊ณต๊ฐ„์ด ์ œํ•œ์ ์ด๋ฏ€๋กœ ํ•ต์‹ฌ ๋ฉ”์‹œ์ง€๋ฅผ ๊ฐ„๊ฒฐํ•˜๊ฒŒ ์ „๋‹ฌํ•ด์•ผ ํ•ด. ๋ถˆํ•„์š”ํ•œ ๋‹จ์–ด๋Š” ๊ณผ๊ฐํžˆ ์ƒ๋žตํ•˜๊ณ  ํ•ต์‹ฌ๋งŒ ๋‹ด์•„๋‚ด์ž.

    โŒ ๋‚˜์œ ์˜ˆ: "์•ˆ๋…•ํ•˜์„ธ์š”, ๊ณ ๊ฐ๋‹˜. ์ €ํฌ ์•ฑ์—์„œ ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์ด ์—…๋ฐ์ดํŠธ๋˜์—ˆ์œผ๋‹ˆ ํ™•์ธํ•ด๋ณด์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค."

    โœ… ์ข‹์€ ์˜ˆ: "์ƒˆ ๊ธฐ๋Šฅ ์ถœ์‹œ: ์‹ค์‹œ๊ฐ„ ์ฑ„ํŒ… ์ง€์›์ด ์ถ”๊ฐ€๋์–ด์š”!"

  2. ๊ฐœ์ธํ™”๋œ ์ฝ˜ํ…์ธ 

    ์‚ฌ์šฉ์ž์˜ ์ด๋ฆ„์ด๋‚˜ ๊ด€์‹ฌ์‚ฌ๋ฅผ ํฌํ•จํ•œ ๊ฐœ์ธํ™”๋œ ๋ฉ”์‹œ์ง€๋Š” ํด๋ฆญ๋ฅ ์„ ํฌ๊ฒŒ ๋†’์ผ ์ˆ˜ ์žˆ์–ด.

    โŒ ๋‚˜์œ ์˜ˆ: "ํ• ์ธ ์ด๋ฒคํŠธ ์ค‘์ž…๋‹ˆ๋‹ค."

    โœ… ์ข‹์€ ์˜ˆ: "๋ฏผ์ง€๋‹˜, ๊ด€์‹ฌ ์žˆ์œผ์…จ๋˜ ๋””์ž์ธ ๊ฐ•์˜๊ฐ€ 20% ํ• ์ธ ์ค‘์ด์—์š”!"

  3. ํ–‰๋™ ์œ ๋„ ๋ฌธ๊ตฌ(CTA) ํฌํ•จ

    ์‚ฌ์šฉ์ž๊ฐ€ ์•Œ๋ฆผ์„ ๋ฐ›๊ณ  ์–ด๋–ค ํ–‰๋™์„ ์ทจํ•ด์•ผ ํ• ์ง€ ๋ช…ํ™•ํ•˜๊ฒŒ ์•ˆ๋‚ดํ•ด์•ผ ํ•ด.

    โŒ ๋‚˜์œ ์˜ˆ: "์ƒˆ ๋ฉ”์‹œ์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค."

    โœ… ์ข‹์€ ์˜ˆ: "์ƒˆ ๋ฉ”์‹œ์ง€ ๋„์ฐฉ: ์ง€๊ธˆ ๋‹ต์žฅํ•˜๊ธฐ"

  4. ์ ์ ˆํ•œ ํƒ€์ด๋ฐ

    ์‚ฌ์šฉ์ž์˜ ์‹œ๊ฐ„๋Œ€์™€ ํ™œ๋™ ํŒจํ„ด์„ ๊ณ ๋ คํ•ด ์•Œ๋ฆผ์„ ๋ณด๋‚ด๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•ด. ์ƒˆ๋ฒฝ์— ๋งˆ์ผ€ํŒ… ์•Œ๋ฆผ์„ ๋ณด๋‚ด๋ฉด ์‚ฌ์šฉ์ž๊ฐ€ ๋ถˆ์พŒํ•ดํ•  ์ˆ˜ ์žˆ์–ด.

    โŒ ๋‚˜์œ ์˜ˆ: ์ƒˆ๋ฒฝ 3์‹œ์— ํ”„๋กœ๋ชจ์…˜ ์•Œ๋ฆผ ๋ฐœ์†ก

    โœ… ์ข‹์€ ์˜ˆ: ์‚ฌ์šฉ์ž๊ฐ€ ์•ฑ์„ ์ž์ฃผ ์‚ฌ์šฉํ•˜๋Š” ์‹œ๊ฐ„๋Œ€(์˜ˆ: ์ €๋… 7-9์‹œ)์— ์•Œ๋ฆผ ๋ฐœ์†ก

  5. ์ด๋ฏธ์ง€์™€ ์ด๋ชจ์ง€ ํ™œ์šฉ

    ์‹œ๊ฐ์  ์š”์†Œ๋Š” ์•Œ๋ฆผ์„ ๋” ๋ˆˆ์— ๋„๊ฒŒ ๋งŒ๋“ค๊ณ  ๋ฉ”์‹œ์ง€ ์ „๋‹ฌ๋ ฅ์„ ๋†’์—ฌ์ค˜.

    โŒ ๋‚˜์œ ์˜ˆ: "์ƒˆ๋กœ์šด ํ• ์ธ ์ฟ ํฐ์ด ๋ฐœ๊ธ‰๋˜์—ˆ์Šต๋‹ˆ๋‹ค."

    โœ… ์ข‹์€ ์˜ˆ: "๐ŸŽ ํŠน๋ณ„ ์„ ๋ฌผ์ด ๋„์ฐฉํ–ˆ์–ด์š”! 50% ํ• ์ธ ์ฟ ํฐ์„ ํ™•์ธํ•˜์„ธ์š” โœจ"

ํšจ๊ณผ์ ์ธ ํ‘ธ์‹œ ์•Œ๋ฆผ ๋””์ž์ธ ๋‚˜์œ ์˜ˆ์‹œ โŒ ์•ฑ ์ด๋ฆ„
์•ˆ๋…•ํ•˜์„ธ์š”, ๊ณ ๊ฐ๋‹˜. ์ €ํฌ ์•ฑ์—์„œ ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์ด ์—…๋ฐ์ดํŠธ๋˜์—ˆ์œผ๋‹ˆ ํ™•์ธํ•ด๋ณด์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.
์•ฑ ์ด๋ฆ„ ํ• ์ธ ์ด๋ฒคํŠธ ์ค‘์ž…๋‹ˆ๋‹ค. ์•ฑ ์ด๋ฆ„ ์ƒˆ ๋ฉ”์‹œ์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์ข‹์€ ์˜ˆ์‹œ โœ… ์žฌ๋Šฅ๋„ท โœจ ์ƒˆ ๊ธฐ๋Šฅ ์ถœ์‹œ: ์‹ค์‹œ๊ฐ„ ์ฑ„ํŒ… ์ง€์›์ด ์ถ”๊ฐ€๋์–ด์š”! ์žฌ๋Šฅ๋„ท
๋ฏผ์ง€๋‹˜, ๊ด€์‹ฌ ์žˆ์œผ์…จ๋˜ ๋””์ž์ธ ๊ฐ•์˜๊ฐ€ 20% ํ• ์ธ ์ค‘์ด์—์š”! ๐Ÿ‘ฉโ€๐ŸŽจ
์žฌ๋Šฅ๋„ท ๐Ÿ”” ์ƒˆ ๋ฉ”์‹œ์ง€ ๋„์ฐฉ: ์ง€๊ธˆ ๋‹ต์žฅํ•˜๊ธฐ ๊ฐœ์ธํ™”, ๊ฐ„๊ฒฐํ•จ, ์‹œ๊ฐ์  ์š”์†Œ๊ฐ€ ํ‘ธ์‹œ ์•Œ๋ฆผ์˜ ํšจ๊ณผ๋ฅผ ํฌ๊ฒŒ ๋†’์ž…๋‹ˆ๋‹ค ์‚ฌ์šฉ์ž์˜ ๊ด€์‹ฌ์„ ๋Œ๊ณ  ์•ฑ ์ฐธ์—ฌ๋„๋ฅผ ๋†’์ด๋Š” ์•Œ๋ฆผ ๋””์ž์ธ์ด ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค

์‚ฌ์šฉ์ž ๊ฒฝํ—˜ ์ตœ์ ํ™” ์ „๋žต

  1. ์•Œ๋ฆผ ๋นˆ๋„ ์กฐ์ ˆ

    ๋„ˆ๋ฌด ๋งŽ์€ ์•Œ๋ฆผ์€ ์‚ฌ์šฉ์ž๋ฅผ ์งœ์ฆ๋‚˜๊ฒŒ ๋งŒ๋“ค ์ˆ˜ ์žˆ์–ด. ์ค‘์š”ํ•œ ์•Œ๋ฆผ๋งŒ ์„ ๋ณ„์ ์œผ๋กœ ๋ณด๋‚ด๊ณ , ์‚ฌ์šฉ์ž๊ฐ€ ์•Œ๋ฆผ ์œ ํ˜•๊ณผ ๋นˆ๋„๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•˜์ž.

  2. ๋”ฅ๋งํฌ ํ™œ์šฉ

    ์•Œ๋ฆผ์„ ํด๋ฆญํ–ˆ์„ ๋•Œ ๊ด€๋ จ ํ™”๋ฉด์œผ๋กœ ๋ฐ”๋กœ ์ด๋™ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋”ฅ๋งํฌ๋ฅผ ์„ค์ •ํ•˜๋ฉด ์‚ฌ์šฉ์ž ๊ฒฝํ—˜์ด ํฌ๊ฒŒ ํ–ฅ์ƒ๋ผ.

    // FCM ๋ฉ”์‹œ์ง€์— ๋”ฅ๋งํฌ ๋ฐ์ดํ„ฐ ํฌํ•จ
    {
      "to": "์‚ฌ์šฉ์ž_FCM_ํ† ํฐ",
      "notification": {
        "title": "์ƒˆ ๋ฉ”์‹œ์ง€ ๋„์ฐฉ",
        "body": "ํ™๊ธธ๋™๋‹˜์ด ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋ƒˆ์Šต๋‹ˆ๋‹ค."
      },
      "data": {
        "type": "chat",
        "chatId": "123456",
        "senderId": "user789"
      }
    }
    
    // React Native์—์„œ ๋”ฅ๋งํฌ ์ฒ˜๋ฆฌ
    messaging().onNotificationOpenedApp(remoteMessage => {
      if (remoteMessage.data) {
        const { type, chatId, senderId } = remoteMessage.data;
        
        if (type === 'chat') {
          // ์ฑ„ํŒ… ํ™”๋ฉด์œผ๋กœ ์ด๋™
          navigation.navigate('Chat', { chatId, senderId });
        }
      }
    });
  3. A/B ํ…Œ์ŠคํŠธ ์ˆ˜ํ–‰

    ๋‹ค์–‘ํ•œ ์•Œ๋ฆผ ๋ฌธ๊ตฌ์™€ ๋””์ž์ธ์„ ํ…Œ์ŠคํŠธํ•ด ์–ด๋–ค ๊ฒƒ์ด ๊ฐ€์žฅ ํšจ๊ณผ์ ์ธ์ง€ ๋ฐ์ดํ„ฐ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๊ฒฐ์ •ํ•˜์ž.

  4. ์‚ฌ์šฉ์ž ์„ธ๊ทธ๋จผํŠธ๋ณ„ ์ „๋žต ์ˆ˜๋ฆฝ

    ํ™œ์„ฑ ์‚ฌ์šฉ์ž, ๋น„ํ™œ์„ฑ ์‚ฌ์šฉ์ž, ์‹ ๊ทœ ์‚ฌ์šฉ์ž ๋“ฑ ์„ธ๊ทธ๋จผํŠธ๋ณ„๋กœ ๋‹ค๋ฅธ ์•Œ๋ฆผ ์ „๋žต์„ ์‚ฌ์šฉํ•˜๋ฉด ํšจ๊ณผ์ ์ด์•ผ.

  5. ์•Œ๋ฆผ ์„ค์ • ํ™”๋ฉด ์ตœ์ ํ™”

    ์‚ฌ์šฉ์ž๊ฐ€ ์‰ฝ๊ฒŒ ์•Œ๋ฆผ์„ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š” ์ง๊ด€์ ์ธ ์„ค์ • ํ™”๋ฉด์„ ์ œ๊ณตํ•˜์ž.

์•Œ๋ฆผ ์„ค์ • ํ™”๋ฉด ์˜ˆ์‹œ ์ฝ”๋“œ

import React, { useState, useEffect } from 'react';
import { View, Text, Switch, StyleSheet, ScrollView } from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage';

const NotificationSettings = () => {
  const [settings, setSettings] = useState({
    chatNotifications: true,
    dealUpdates: true,
    promotions: false,
    systemUpdates: true,
    soundEnabled: true,
    vibrationEnabled: true,
    quietHours: false,
  });

  // ์„ค์ • ๋ถˆ๋Ÿฌ์˜ค๊ธฐ
  useEffect(() => {
    const loadSettings = async () => {
      try {
        const savedSettings = await AsyncStorage.getItem('notificationSettings');
        if (savedSettings) {
          setSettings(JSON.parse(savedSettings));
        }
      } catch (error) {
        console.error('์„ค์ •์„ ๋ถˆ๋Ÿฌ์˜ค๋Š” ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ:', error);
      }
    };
    
    loadSettings();
  }, []);

  // ์„ค์ • ๋ณ€๊ฒฝ ์‹œ ์ €์žฅ
  const updateSetting = (key, value) => {
    const newSettings = { ...settings, [key]: value };
    setSettings(newSettings);
    
    // AsyncStorage์— ์ €์žฅ
    AsyncStorage.setItem('notificationSettings', JSON.stringify(newSettings))
      .catch(error => console.error('์„ค์ • ์ €์žฅ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ:', error));
      
    // ์—ฌ๊ธฐ์„œ ํ•„์š”์— ๋”ฐ๋ผ ์„œ๋ฒ„์— ์‚ฌ์šฉ์ž ์„ค์ • ์—…๋ฐ์ดํŠธ API ํ˜ธ์ถœ
  };

  return (
    <ScrollView style={styles.container}>
      <Text style={styles.title}>์•Œ๋ฆผ ์„ค์ •</Text>
      
      <View style={styles.section}>
        <Text style={styles.sectionTitle}>์•Œ๋ฆผ ์œ ํ˜•</Text>
        
        <View style={styles.settingItem}>
          <Text style={styles.settingLabel}>์ฑ„ํŒ… ๋ฉ”์‹œ์ง€</Text>
          <Switch
            value={settings.chatNotifications}
            onValueChange={(value) => updateSetting('chatNotifications', value)}
            trackColor={{ false: '#767577', true: '#81b0ff' }}
            thumbColor={settings.chatNotifications ? '#1e88e5' : '#f4f3f4'}
          />
        </View>
        
        <View style={styles.settingItem}>
          <Text style={styles.settingLabel}>๊ฑฐ๋ž˜ ์—…๋ฐ์ดํŠธ</Text>
          <Switch
            value={settings.dealUpdates}
            onValueChange={(value) => updateSetting('dealUpdates', value)}
            trackColor={{ false: '#767577', true: '#81b0ff' }}
            thumbColor={settings.dealUpdates ? '#1e88e5' : '#f4f3f4'}
          />
        </View>
        
        <View style={styles.settingItem}>
          <Text style={styles.settingLabel}>ํ”„๋กœ๋ชจ์…˜ ๋ฐ ๋งˆ์ผ€ํŒ…</Text>
          <Switch
            value={settings.promotions}
            onValueChange={(value) => updateSetting('promotions', value)}
            trackColor={{ false: '#767577', true: '#81b0ff' }}
            thumbColor={settings.promotions ? '#1e88e5' : '#f4f3f4'}
          />
        </View>
        
        <View style={styles.settingItem}>
          <Text style={styles.settingLabel}>์‹œ์Šคํ…œ ์—…๋ฐ์ดํŠธ</Text>
          <Switch
            value={settings.systemUpdates}
            onValueChange={(value) => updateSetting('systemUpdates', value)}
            trackColor={{ false: '#767577', true: '#81b0ff' }}
            thumbColor={settings.systemUpdates ? '#1e88e5' : '#f4f3f4'}
          />
        </View>
      </View>
      
      <View style={styles.section}>
        <Text style={styles.sectionTitle}>์•Œ๋ฆผ ๋ฐฉ์‹</Text>
        
        <View style={styles.settingItem}>
          <Text style={styles.settingLabel}>์†Œ๋ฆฌ</Text>
          <Switch
            value={settings.soundEnabled}
            onValueChange={(value) => updateSetting('soundEnabled', value)}
            trackColor={{ false: '#767577', true: '#81b0ff' }}
            thumbColor={settings.soundEnabled ? '#1e88e5' : '#f4f3f4'}
          />
        </View>
        
        <View style={styles.settingItem}>
          <Text style={styles.settingLabel}>์ง„๋™</Text>
          <Switch
            value={settings.vibrationEnabled}
            onValueChange={(value) => updateSetting('vibrationEnabled', value)}
            trackColor={{ false: '#767577', true: '#81b0ff' }}
            thumbColor={settings.vibrationEnabled ? '#1e88e5' : '#f4f3f4'}
          />
        </View>
        
        <View style={styles.settingItem}>
          <Text style={styles.settingLabel}>๋ฐฉํ•ด ๊ธˆ์ง€ ์‹œ๊ฐ„ ์„ค์ •</Text>
          <Switch
            value={settings.quietHours}
            onValueChange={(value) => updateSetting('quietHours', value)}
            trackColor={{ false: '#767577', true: '#81b0ff' }}
            thumbColor={settings.quietHours ? '#1e88e5' : '#f4f3f4'}
          />
        </View>
      </View>
      
      <Text style={styles.footer}>
        ์•Œ๋ฆผ ์„ค์ •์„ ๋ณ€๊ฒฝํ•˜๋ฉด ์ž๋™์œผ๋กœ ์ €์žฅ๋ฉ๋‹ˆ๋‹ค.
      </Text>
    </ScrollView>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 16,
    backgroundColor: '#fff',
  },
  title: {
    fontSize: 24,
    fontWeight: 'bold',
    marginBottom: 20,
    color: '#333',
  },
  section: {
    marginBottom: 24,
    backgroundColor: '#f9f9f9',
    borderRadius: 8,
    padding: 16,
  },
  sectionTitle: {
    fontSize: 18,
    fontWeight: '600',
    marginBottom: 16,
    color: '#333',
  },
  settingItem: {
    flexDirection: 'row',
    justifyContent: 'space-between',
    alignItems: 'center',
    paddingVertical: 12,
    borderBottomWidth: 1,
    borderBottomColor: '#eee',
  },
  settingLabel: {
    fontSize: 16,
    color: '#444',
  },
  footer: {
    marginTop: 16,
    marginBottom: 32,
    textAlign: 'center',
    color: '#666',
    fontSize: 14,
  },
});

export default NotificationSettings;

ํ‘ธ์‹œ ์•Œ๋ฆผ ๋””์ž์ธ๊ณผ ์‚ฌ์šฉ์ž ๊ฒฝํ—˜์€ ์•ฑ์˜ ์„ฑ๊ณต์— ์ง์ ‘์ ์ธ ์˜ํ–ฅ์„ ๋ฏธ์ณ. ํŠนํžˆ ์žฌ๋Šฅ๋„ท ๊ฐ™์€ ์„œ๋น„์Šค์—์„œ๋Š” ์‚ฌ์šฉ์ž ๊ฐ„์˜ ์†Œํ†ต์ด ์ค‘์š”ํ•˜๊ธฐ ๋•Œ๋ฌธ์—, ์ ์ ˆํ•œ ํƒ€์ด๋ฐ์— ๊ฐœ์ธํ™”๋œ ์•Œ๋ฆผ์„ ๋ณด๋‚ด๋Š” ๊ฒƒ์ด ์‚ฌ์šฉ์ž ์ฐธ์—ฌ๋„์™€ ๋งŒ์กฑ๋„๋ฅผ ํฌ๊ฒŒ ๋†’์ผ ์ˆ˜ ์žˆ์–ด. ํ•˜์ง€๋งŒ ํ•ญ์ƒ ๊ธฐ์–ตํ•ด์•ผ ํ•  ๊ฒƒ์€ "๋œ ๋ณด๋‚ด๋Š” ๊ฒƒ์ด ๋” ํšจ๊ณผ์ ์ผ ์ˆ˜ ์žˆ๋‹ค"๋Š” ์ ์ด์•ผ. ์ •๋ง ์ค‘์š”ํ•œ ์•Œ๋ฆผ๋งŒ ์„ ๋ณ„์ ์œผ๋กœ ๋ณด๋‚ด์„œ ์‚ฌ์šฉ์ž์˜ ์‹ ๋ขฐ๋ฅผ ์–ป๋Š” ๊ฒƒ์ด ์žฅ๊ธฐ์ ์œผ๋กœ ๋” ํฐ ์„ฑ๊ณต์„ ๊ฐ€์ ธ์˜ฌ ๊ฑฐ์•ผ! ๐ŸŒŸ

8. ํ‘ธ์‹œ ์•Œ๋ฆผ ํ…Œ์ŠคํŠธ ๋ฐ ๋””๋ฒ„๊น… ๋ฐฉ๋ฒ• ๐Ÿ”

ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ๊ตฌํ˜„ํ–ˆ๋‹ค๋ฉด ์ด์ œ ์ œ๋Œ€๋กœ ์ž‘๋™ํ•˜๋Š”์ง€ ํ…Œ์ŠคํŠธํ•˜๊ณ  ๋ฌธ์ œ๊ฐ€ ์žˆ์œผ๋ฉด ๋””๋ฒ„๊น…ํ•ด์•ผ ํ•ด. ํ‘ธ์‹œ ์•Œ๋ฆผ์€ ์—ฌ๋Ÿฌ ์‹œ์Šคํ…œ(์•ฑ, FCM, APNs ๋“ฑ)์„ ๊ฑฐ์ณ ์ „๋‹ฌ๋˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š” ์ง€์ ์ด ๋งŽ์•„. ๋งˆ์น˜ ๋ฐฐ๋‹ฌ ์Œ์‹์ด ์ฃผ๋ฐฉ์—์„œ ์ถœ๋ฐœํ•ด ๋ฐฐ๋‹ฌ์›์„ ๊ฑฐ์ณ ์ง‘๊นŒ์ง€ ์˜ค๋Š” ๊ณผ์ •์—์„œ ์—ฌ๋Ÿฌ ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธธ ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ๋ง์ด์•ผ. ๊ทธ๋Ÿผ ํšจ๊ณผ์ ์ธ ํ…Œ์ŠคํŠธ์™€ ๋””๋ฒ„๊น… ๋ฐฉ๋ฒ•์„ ์•Œ์•„๋ณด์ž! ๐Ÿ•ต๏ธโ€โ™€๏ธ

ํ‘ธ์‹œ ์•Œ๋ฆผ ํ…Œ์ŠคํŠธ ๋ฐฉ๋ฒ•

  1. Firebase ์ฝ˜์†” ์‚ฌ์šฉํ•˜๊ธฐ

    ๊ฐ€์žฅ ๊ฐ„๋‹จํ•œ ๋ฐฉ๋ฒ•์€ Firebase ์ฝ˜์†”์˜ Cloud Messaging ์„น์…˜์—์„œ ํ…Œ์ŠคํŠธ ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ด๋Š” ๊ฑฐ์•ผ.

    1. Firebase ์ฝ˜์†”์— ๋กœ๊ทธ์ธํ•ด.
    2. ํ”„๋กœ์ ํŠธ๋ฅผ ์„ ํƒํ•˜๊ณ  ์™ผ์ชฝ ๋ฉ”๋‰ด์—์„œ "Messaging"์„ ํด๋ฆญํ•ด.
    3. "์ฒซ ๋ฒˆ์งธ ์บ ํŽ˜์ธ ๋งŒ๋“ค๊ธฐ" ๋˜๋Š” "์ƒˆ ์•Œ๋ฆผ ๋ณด๋‚ด๊ธฐ"๋ฅผ ํด๋ฆญํ•ด.
    4. ์•Œ๋ฆผ ์ œ๋ชฉ, ํ…์ŠคํŠธ, ์ด๋ฏธ์ง€ ๋“ฑ์„ ์ž…๋ ฅํ•ด.
    5. ํƒ€๊ฒŸํŒ… ์„น์…˜์—์„œ "์•ฑ"์„ ์„ ํƒํ•˜๊ณ  ํ…Œ์ŠคํŠธํ•  ์•ฑ์„ ์ง€์ •ํ•ด.
    6. ํ…Œ์ŠคํŠธ ๊ธฐ๊ธฐ์˜ FCM ํ† ํฐ์„ ์ž…๋ ฅํ•˜๊ฑฐ๋‚˜ ํ…Œ์ŠคํŠธ ๊ทธ๋ฃน์„ ๋งŒ๋“ค์–ด ์ง€์ •ํ•ด.
    7. "๊ฒ€ํ† " ๋ฒ„ํŠผ์„ ํด๋ฆญํ•œ ํ›„ "๊ฒŒ์‹œ"๋ฅผ ํด๋ฆญํ•ด.
  2. Postman์ด๋‚˜ cURL ์‚ฌ์šฉํ•˜๊ธฐ

    API ์š”์ฒญ์„ ์ง์ ‘ ๋ณด๋‚ด์„œ ๋” ์„ธ๋ฐ€ํ•œ ํ…Œ์ŠคํŠธ๋ฅผ ํ•  ์ˆ˜ ์žˆ์–ด:

    curl -X POST -H "Authorization: key=YOUR_SERVER_KEY" -H "Content-Type: application/json" \
      -d '{
        "to": "DEVICE_FCM_TOKEN",
        "notification": {
          "title": "ํ…Œ์ŠคํŠธ ์•Œ๋ฆผ",
          "body": "์ด๊ฒƒ์€ ํ…Œ์ŠคํŠธ ํ‘ธ์‹œ ์•Œ๋ฆผ์ž…๋‹ˆ๋‹ค!"
        },
        "data": {
          "type": "test",
          "id": "123"
        }
      }' \
      https://fcm.googleapis.com/fcm/send
  3. ๋กœ์ปฌ ์•Œ๋ฆผ์œผ๋กœ ํ…Œ์ŠคํŠธํ•˜๊ธฐ

    ์›๊ฒฉ ์„œ๋ฒ„ ์—†์ด๋„ ๋กœ์ปฌ ์•Œ๋ฆผ์„ ์‚ฌ์šฉํ•ด ์•Œ๋ฆผ ํ‘œ์‹œ ๋ฐฉ์‹์„ ํ…Œ์ŠคํŠธํ•  ์ˆ˜ ์žˆ์–ด:

    // react-native-push-notification ์‚ฌ์šฉ
    PushNotification.localNotification({
      channelId: 'default-channel-id',  // Android์šฉ
      title: 'ํ…Œ์ŠคํŠธ ์•Œ๋ฆผ',
      message: '์ด๊ฒƒ์€ ๋กœ์ปฌ ํ…Œ์ŠคํŠธ ์•Œ๋ฆผ์ž…๋‹ˆ๋‹ค!',
      playSound: true,
      soundName: 'default',
    });
  4. ์ž๋™ํ™”๋œ ํ…Œ์ŠคํŠธ ์Šคํฌ๋ฆฝํŠธ ์ž‘์„ฑํ•˜๊ธฐ

    ์—ฌ๋Ÿฌ ์œ ํ˜•์˜ ์•Œ๋ฆผ์„ ์ž๋™์œผ๋กœ ํ…Œ์ŠคํŠธํ•˜๋Š” ์Šคํฌ๋ฆฝํŠธ๋ฅผ ๋งŒ๋“ค๋ฉด ํšจ์œจ์ ์ด์•ผ:

    // test-notifications.js
    const axios = require('axios');
    
    const FCM_SERVER_KEY = 'YOUR_SERVER_KEY';
    const TEST_DEVICE_TOKEN = 'TEST_DEVICE_FCM_TOKEN';
    
    const testCases = [
      {
        title: '๊ธฐ๋ณธ ์•Œ๋ฆผ ํ…Œ์ŠคํŠธ',
        body: '๊ธฐ๋ณธ ํ…์ŠคํŠธ๋งŒ ์žˆ๋Š” ์•Œ๋ฆผ์ž…๋‹ˆ๋‹ค.',
        data: {}
      },
      {
        title: '๋”ฅ๋งํฌ ํ…Œ์ŠคํŠธ',
        body: '์ด ์•Œ๋ฆผ์€ ํŠน์ • ํ™”๋ฉด์œผ๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค.',
        data: {
          type: 'navigation',
          screen: 'Profile',
          id: '12345'
        }
      },
      {
        title: '์ด๋ฏธ์ง€ ์•Œ๋ฆผ ํ…Œ์ŠคํŠธ',
        body: '์ด๋ฏธ์ง€๊ฐ€ ํฌํ•จ๋œ ์•Œ๋ฆผ์ž…๋‹ˆ๋‹ค.',
        image: 'https://example.com/test-image.jpg',
        data: {}
      }
    ];
    
    async function runTests() {
      for (const test of testCases) {
        console.log(`ํ…Œ์ŠคํŠธ ์‹คํ–‰: ${test.title}`);
        
        try {
          const response = await axios.post('https://fcm.googleapis.com/fcm/send', {
            to: TEST_DEVICE_TOKEN,
            notification: {
              title: test.title,
              body: test.body,
              image: test.image
            },
            data: test.data
          }, {
            headers: {
              'Authorization': `key=${FCM_SERVER_KEY}`,
              'Content-Type': 'application/json'
            }
          });
          
          console.log('์‘๋‹ต:', response.data);
        } catch (error) {
          console.error('์˜ค๋ฅ˜:', error.response ? error.response.data : error.message);
        }
        
        // ํ…Œ์ŠคํŠธ ๊ฐ„ ๊ฐ„๊ฒฉ ๋‘๊ธฐ
        await new Promise(resolve => setTimeout(resolve, 5000));
      }
    }
    
    runTests();
ํ‘ธ์‹œ ์•Œ๋ฆผ ๋””๋ฒ„๊น… ํ”„๋กœ์„ธ์Šค 1. ๋ฌธ์ œ ์‹๋ณ„ ์•Œ๋ฆผ์ด ๋„์ฐฉํ•˜์ง€ ์•Š์Œ / ์•Œ๋ฆผ ํด๋ฆญ ์‹œ ์•ฑ์ด ์—ด๋ฆฌ์ง€ ์•Š์Œ / ์•Œ๋ฆผ ์Šคํƒ€์ผ ๋ฌธ์ œ ๋“ฑ 2. ๋กœ๊ทธ ํ™•์ธ FCM ์ฝ˜์†” ๋กœ๊ทธ / ์•ฑ ๋กœ๊ทธ / ์„œ๋ฒ„ ๋กœ๊ทธ ํ™•์ธ

ํ‘ธ์‹œ ์•Œ๋ฆผ ๋””๋ฒ„๊น… ๋‹จ๊ณ„

  1. FCM ํ† ํฐ ํ™•์ธ

    ๊ฐ€์žฅ ๋จผ์ € ํ™•์ธํ•  ๊ฒƒ์€ FCM ํ† ํฐ์ด ์ œ๋Œ€๋กœ ์ƒ์„ฑ๋˜๊ณ  ์„œ๋ฒ„์— ์ €์žฅ๋˜์—ˆ๋Š”์ง€์•ผ:

    // ํ† ํฐ ๋กœ๊น…
    messaging()
      .getToken()
      .then(token => {
        console.log('FCM ํ† ํฐ:', token);
        // ์—ฌ๊ธฐ์„œ ํ† ํฐ์ด ์ œ๋Œ€๋กœ ์ƒ์„ฑ๋˜์—ˆ๋Š”์ง€ ํ™•์ธ
      });
  2. ์•Œ๋ฆผ ๊ถŒํ•œ ํ™•์ธ

    ์‚ฌ์šฉ์ž๊ฐ€ ์•Œ๋ฆผ ๊ถŒํ•œ์„ ํ—ˆ์šฉํ–ˆ๋Š”์ง€ ํ™•์ธํ•ด:

    // iOS์—์„œ ๊ถŒํ•œ ์ƒํƒœ ํ™•์ธ
    import { Platform } from 'react-native';
    import messaging from '@react-native-firebase/messaging';
    
    async function checkNotificationPermission() {
      if (Platform.OS === 'ios') {
        const authStatus = await messaging().hasPermission();
        console.log('์•Œ๋ฆผ ๊ถŒํ•œ ์ƒํƒœ:', authStatus);
        
        if (authStatus === messaging.AuthorizationStatus.NOT_DETERMINED) {
          console.log('์‚ฌ์šฉ์ž๊ฐ€ ์•„์ง ๊ถŒํ•œ์„ ๊ฒฐ์ •ํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.');
        } else if (authStatus === messaging.AuthorizationStatus.DENIED) {
          console.log('์‚ฌ์šฉ์ž๊ฐ€ ์•Œ๋ฆผ ๊ถŒํ•œ์„ ๊ฑฐ๋ถ€ํ–ˆ์Šต๋‹ˆ๋‹ค.');
        } else {
          console.log('์‚ฌ์šฉ์ž๊ฐ€ ์•Œ๋ฆผ ๊ถŒํ•œ์„ ํ—ˆ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค.');
        }
      }
    }
  3. Firebase ์ฝ˜์†”์—์„œ ์ „์†ก ์ƒํƒœ ํ™•์ธ

    Firebase ์ฝ˜์†”์˜ Cloud Messaging > ๋Œ€์‹œ๋ณด๋“œ์—์„œ ๋ฉ”์‹œ์ง€ ์ „์†ก ์ƒํƒœ์™€ ์˜ค๋ฅ˜๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด.

  4. ๋„คํŠธ์›Œํฌ ์š”์ฒญ ๋ชจ๋‹ˆํ„ฐ๋ง

    Charles Proxy๋‚˜ Wireshark ๊ฐ™์€ ๋„๊ตฌ๋กœ ๋„คํŠธ์›Œํฌ ์š”์ฒญ์„ ๋ชจ๋‹ˆํ„ฐ๋งํ•ด FCM ์„œ๋ฒ„์™€์˜ ํ†ต์‹  ๋ฌธ์ œ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด.

  5. ํ”Œ๋žซํผ๋ณ„ ๋กœ๊ทธ ํ™•์ธ

    iOS์™€ Android์—์„œ ๊ฐ๊ฐ ๋กœ๊ทธ๋ฅผ ํ™•์ธํ•˜๋Š” ๋ฐฉ๋ฒ•:

    • - iOS: Xcode์˜ ์ฝ˜์†” ๋กœ๊ทธ์—์„œ "notification"์ด๋‚˜ "apns" ํ‚ค์›Œ๋“œ๋กœ ๊ฒ€์ƒ‰
    • - Android: Logcat์—์„œ "FCM" ๋˜๋Š” "FirebaseMessaging" ํƒœ๊ทธ๋กœ ํ•„ํ„ฐ๋ง
  6. ๋‹จ๊ณ„๋ณ„ ํ…Œ์ŠคํŠธ

    ๋ฌธ์ œ๋ฅผ ๋ถ„๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ๋‹จ๊ณ„๋ณ„๋กœ ํ…Œ์ŠคํŠธํ•ด:

    1. ๋กœ์ปฌ ์•Œ๋ฆผ์ด ์ž‘๋™ํ•˜๋Š”์ง€ ํ™•์ธ (์•ฑ ๋‚ด๋ถ€์—์„œ ์ƒ์„ฑ)
    2. Firebase ์ฝ˜์†”์—์„œ ์ง์ ‘ ํ…Œ์ŠคํŠธ ๋ฉ”์‹œ์ง€ ์ „์†ก
    3. ์„œ๋ฒ„์—์„œ FCM API๋กœ ๋ฉ”์‹œ์ง€ ์ „์†ก

์ž์ฃผ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ์™€ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

  1. ์•Œ๋ฆผ์ด ์ „ํ˜€ ๋„์ฐฉํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ
    • - FCM ํ† ํฐ์ด ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์„œ๋ฒ„์— ๋“ฑ๋ก๋˜์—ˆ๋Š”์ง€ ํ™•์ธ
    • - iOS์—์„œ ํ‘ธ์‹œ ์•Œ๋ฆผ ์ธ์ฆ์„œ๊ฐ€ ์œ ํšจํ•œ์ง€ ํ™•์ธ
    • - Android์—์„œ google-services.json ํŒŒ์ผ์ด ์˜ฌ๋ฐ”๋ฅธ ์œ„์น˜์— ์žˆ๋Š”์ง€ ํ™•์ธ
    • - ์‚ฌ์šฉ์ž๊ฐ€ ์•Œ๋ฆผ ๊ถŒํ•œ์„ ํ—ˆ์šฉํ–ˆ๋Š”์ง€ ํ™•์ธ
    • - ๊ธฐ๊ธฐ๊ฐ€ ์ธํ„ฐ๋„ท์— ์—ฐ๊ฒฐ๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธ
  2. ์•Œ๋ฆผ์€ ๋„์ฐฉํ•˜์ง€๋งŒ ํด๋ฆญํ•ด๋„ ์•ฑ์ด ์—ด๋ฆฌ์ง€ ์•Š๋Š” ๊ฒฝ์šฐ
    • - Android์—์„œ Intent ํ•„ํ„ฐ๊ฐ€ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์„ค์ •๋˜์—ˆ๋Š”์ง€ ํ™•์ธ
    • - ์•Œ๋ฆผ ์ฒ˜๋ฆฌ ์ฝ”๋“œ์—์„œ ์˜ค๋ฅ˜๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธ
    • - ๋”ฅ๋งํฌ ์ฒ˜๋ฆฌ ๋กœ์ง์ด ์˜ฌ๋ฐ”๋ฅธ์ง€ ํ™•์ธ
  3. iOS์—์„œ๋งŒ ์•Œ๋ฆผ์ด ์ž‘๋™ํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ
    • - APNs ์ธ์ฆ์„œ๊ฐ€ ์œ ํšจํ•œ์ง€ ํ™•์ธ
    • - Capabilities์— Push Notifications๊ฐ€ ํ™œ์„ฑํ™”๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธ
    • - ์•ฑ์ด ํ”„๋กœ๋•์…˜/๊ฐœ๋ฐœ ํ™˜๊ฒฝ์— ๋งž๋Š” ์ธ์ฆ์„œ๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š”์ง€ ํ™•์ธ
  4. Android์—์„œ๋งŒ ์•Œ๋ฆผ์ด ์ž‘๋™ํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ
    • - AndroidManifest.xml์— ํ•„์š”ํ•œ ๊ถŒํ•œ๊ณผ ์„œ๋น„์Šค๊ฐ€ ๋“ฑ๋ก๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธ
    • - ์•Œ๋ฆผ ์ฑ„๋„์ด ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ƒ์„ฑ๋˜์—ˆ๋Š”์ง€ ํ™•์ธ (Android 8.0 ์ด์ƒ)
    • - ๊ธฐ๊ธฐ์˜ ๋ฐฐํ„ฐ๋ฆฌ ์ตœ์ ํ™” ์„ค์ •์—์„œ ์•ฑ์ด ์ œ์™ธ๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธ
  5. ์•Œ๋ฆผ ์Šคํƒ€์ผ์ด๋‚˜ ์†Œ๋ฆฌ๊ฐ€ ์˜ˆ์ƒ๊ณผ ๋‹ค๋ฅธ ๊ฒฝ์šฐ
    • - Android์—์„œ ์•Œ๋ฆผ ์ฑ„๋„ ์„ค์ • ํ™•์ธ
    • - ์•Œ๋ฆผ ํŽ˜์ด๋กœ๋“œ์— ์Šคํƒ€์ผ ๊ด€๋ จ ์†์„ฑ์ด ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์„ค์ •๋˜์—ˆ๋Š”์ง€ ํ™•์ธ
    • - ๊ธฐ๊ธฐ์˜ ์†Œ๋ฆฌ/์ง„๋™ ์„ค์ • ํ™•์ธ

์œ ์šฉํ•œ ๋””๋ฒ„๊น… ๋„๊ตฌ

  1. Firebase ๋””๋ฒ„๊ทธ ๋ทฐ

    Firebase ์ฝ˜์†”์˜ Cloud Messaging > ๋Œ€์‹œ๋ณด๋“œ์—์„œ ๋ฉ”์‹œ์ง€ ์ „์†ก ์ƒํƒœ์™€ ์˜ค๋ฅ˜๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด.

  2. FCM ํ…Œ์ŠคํŠธ ํด๋ผ์ด์–ธํŠธ

    Google์—์„œ ์ œ๊ณตํ•˜๋Š” FCM ํ…Œ์ŠคํŠธ ํด๋ผ์ด์–ธํŠธ๋ฅผ ์‚ฌ์šฉํ•ด ์•Œ๋ฆผ ์ˆ˜์‹ ์„ ํ…Œ์ŠคํŠธํ•  ์ˆ˜ ์žˆ์–ด.

  3. Flipper

    React Native ๋””๋ฒ„๊น… ๋„๊ตฌ์ธ Flipper๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋„คํŠธ์›Œํฌ ์š”์ฒญ๊ณผ ์•ฑ ๋กœ๊ทธ๋ฅผ ์‰ฝ๊ฒŒ ๋ชจ๋‹ˆํ„ฐ๋งํ•  ์ˆ˜ ์žˆ์–ด.

  4. React Native Debugger

    React Native Debugger๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์•ฑ ์ƒํƒœ์™€ ๋„คํŠธ์›Œํฌ ์š”์ฒญ์„ ํ•œ ๊ณณ์—์„œ ๋””๋ฒ„๊น…ํ•  ์ˆ˜ ์žˆ์–ด.

ํ‘ธ์‹œ ์•Œ๋ฆผ ํ…Œ์ŠคํŠธ์™€ ๋””๋ฒ„๊น…์€ ์ธ๋‚ด์‹ฌ๊ณผ ์ฒด๊ณ„์ ์ธ ์ ‘๊ทผ์ด ํ•„์š”ํ•ด. ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ์„ ๋•Œ ๋‹นํ™ฉํ•˜์ง€ ๋ง๊ณ  ์œ„์—์„œ ์„ค๋ช…ํ•œ ๋‹จ๊ณ„๋ฅผ ์ฐจ๊ทผ์ฐจ๊ทผ ๋”ฐ๋ผ๊ฐ€๋ฉด ๋Œ€๋ถ€๋ถ„์˜ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์„ ๊ฑฐ์•ผ. ์žฌ๋Šฅ๋„ท ๊ฐ™์€ ํ”Œ๋žซํผ์—์„œ๋Š” ํ‘ธ์‹œ ์•Œ๋ฆผ์ด ์‚ฌ์šฉ์ž ์ฐธ์—ฌ์— ์ค‘์š”ํ•œ ์—ญํ• ์„ ํ•˜๊ธฐ ๋•Œ๋ฌธ์—, ์ฒ ์ €ํ•œ ํ…Œ์ŠคํŠธ๋ฅผ ํ†ตํ•ด ๋ชจ๋“  ์‚ฌ์šฉ์ž์—๊ฒŒ ์•Œ๋ฆผ์ด ์ œ๋Œ€๋กœ ์ „๋‹ฌ๋˜๋Š”์ง€ ํ™•์ธํ•˜๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•ด! ๐Ÿ”ง

9. ์‹ค์ „ ํ™œ์šฉ ์‚ฌ๋ก€์™€ ๋ฒ ์ŠคํŠธ ํ”„๋ž™ํ‹ฐ์Šค ๐ŸŒŸ

์ด์ œ ํ‘ธ์‹œ ์•Œ๋ฆผ์˜ ๊ธฐ์ˆ ์ ์ธ ๊ตฌํ˜„ ๋ฐฉ๋ฒ•์„ ๋ชจ๋‘ ์•Œ์•˜์œผ๋‹ˆ, ์‹ค์ œ๋กœ ์–ด๋–ป๊ฒŒ ํ™œ์šฉํ•˜๋ฉด ์ข‹์„์ง€ ์‚ดํŽด๋ณด์ž! ํ‘ธ์‹œ ์•Œ๋ฆผ์€ ๋‹จ์ˆœํžˆ ์‚ฌ์šฉ์ž์—๊ฒŒ ์ •๋ณด๋ฅผ ์ „๋‹ฌํ•˜๋Š” ๊ฒƒ์„ ๋„˜์–ด, ์•ฑ์˜ ์‚ฌ์šฉ์ž ๊ฒฝํ—˜์„ ํ–ฅ์ƒ์‹œํ‚ค๊ณ  ๋น„์ฆˆ๋‹ˆ์Šค ๋ชฉํ‘œ๋ฅผ ๋‹ฌ์„ฑํ•˜๋Š” ๊ฐ•๋ ฅํ•œ ๋„๊ตฌ๊ฐ€ ๋  ์ˆ˜ ์žˆ์–ด. ๋งˆ์น˜ ์š”๋ฆฌ์‚ฌ๊ฐ€ ๋‹ค์–‘ํ•œ ์žฌ๋ฃŒ๋กœ ๋ง›์žˆ๋Š” ์š”๋ฆฌ๋ฅผ ๋งŒ๋“œ๋Š” ๊ฒƒ์ฒ˜๋Ÿผ, ํ‘ธ์‹œ ์•Œ๋ฆผ๋„ ๋‹ค์–‘ํ•œ ๋ฐฉ์‹์œผ๋กœ ํ™œ์šฉํ•  ์ˆ˜ ์žˆ์ง€! ๐Ÿ‘จโ€๐Ÿณ

๋‹ค์–‘ํ•œ ํ™œ์šฉ ์‚ฌ๋ก€

  1. ์‹ค์‹œ๊ฐ„ ๋ฉ”์‹œ์ง•

    ์žฌ๋Šฅ๋„ท๊ณผ ๊ฐ™์€ ํ”Œ๋žซํผ์—์„œ ์‚ฌ์šฉ์ž ๊ฐ„ ๋ฉ”์‹œ์ง€๊ฐ€ ๋„์ฐฉํ–ˆ์„ ๋•Œ ์ฆ‰์‹œ ์•Œ๋ฆผ์„ ๋ณด๋‚ด ์†Œํ†ต์„ ์ด‰์ง„ํ•  ์ˆ˜ ์žˆ์–ด.

    // ๋ฉ”์‹œ์ง€ ์•Œ๋ฆผ ์˜ˆ์‹œ (์„œ๋ฒ„ ์ฝ”๋“œ)
    async function sendMessageNotification(recipientToken, senderName, messagePreview) {
      const message = {
        token: recipientToken,
        notification: {
          title: `${senderName}๋‹˜์˜ ์ƒˆ ๋ฉ”์‹œ์ง€`,
          body: messagePreview.length > 50 ? messagePreview.substring(0, 47) + '...' : messagePreview
        },
        data: {
          type: 'chat',
          senderId: sender.id,
          timestamp: Date.now().toString()
        },
        android: {
          priority: 'high',
          notification: {
            channel_id: 'chat',
            click_action: 'OPEN_CHAT_ACTIVITY'
          }
        },
        apns: {
          payload: {
            aps: {
              category: 'NEW_MESSAGE',
              sound: 'default'
            }
          }
        }
      };
      
      try {
        const response = await admin.messaging().send(message);
        console.log('๋ฉ”์‹œ์ง€ ์•Œ๋ฆผ ์ „์†ก ์„ฑ๊ณต:', response);
        return response;
      } catch (error) {
        console.error('๋ฉ”์‹œ์ง€ ์•Œ๋ฆผ ์ „์†ก ์‹คํŒจ:', error);
        throw error;
      }
    }
  2. ๊ฑฐ๋ž˜ ๋ฐ ์ฃผ๋ฌธ ์ƒํƒœ ์—…๋ฐ์ดํŠธ

    ์žฌ๋Šฅ ๊ฑฐ๋ž˜๊ฐ€ ์„ฑ์‚ฌ๋˜๊ฑฐ๋‚˜ ์ƒํƒœ๊ฐ€ ๋ณ€๊ฒฝ๋  ๋•Œ ์•Œ๋ฆผ์„ ๋ณด๋‚ด ์‚ฌ์šฉ์ž๊ฐ€ ์ตœ์‹  ์ •๋ณด๋ฅผ ๋†“์น˜์ง€ ์•Š๊ฒŒ ํ•  ์ˆ˜ ์žˆ์–ด.

    // ๊ฑฐ๋ž˜ ์ƒํƒœ ์•Œ๋ฆผ ์˜ˆ์‹œ (์„œ๋ฒ„ ์ฝ”๋“œ)
    function sendTransactionStatusNotification(userToken, transactionId, newStatus) {
      let title, body;
      
      switch (newStatus) {
        case 'accepted':
          title = '๊ฑฐ๋ž˜๊ฐ€ ์ˆ˜๋ฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค';
          body = 'ํŒ๋งค์ž๊ฐ€ ๊ท€ํ•˜์˜ ๊ฑฐ๋ž˜ ์š”์ฒญ์„ ์ˆ˜๋ฝํ–ˆ์Šต๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์„ ํ™•์ธํ•˜์„ธ์š”.';
          break;
        case 'completed':
          title = '๊ฑฐ๋ž˜๊ฐ€ ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค';
          body = '๊ฑฐ๋ž˜๊ฐ€ ์„ฑ๊ณต์ ์œผ๋กœ ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋ฆฌ๋ทฐ๋ฅผ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”!';
          break;
        case 'cancelled':
          title = '๊ฑฐ๋ž˜๊ฐ€ ์ทจ์†Œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค';
          body = '๊ฑฐ๋ž˜๊ฐ€ ์ทจ์†Œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๊ฑฐ๋ž˜ ๋‚ด์—ญ์„ ํ™•์ธํ•˜์„ธ์š”.';
          break;
        default:
          title = '๊ฑฐ๋ž˜ ์ƒํƒœ ์—…๋ฐ์ดํŠธ';
          body = '๊ฑฐ๋ž˜ ์ƒํƒœ๊ฐ€ ์—…๋ฐ์ดํŠธ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ํ™•์ธํ•ด๋ณด์„ธ์š”.';
      }
      
      const message = {
        token: userToken,
        notification: { title, body },
        data: {
          type: 'transaction',
          transactionId: transactionId,
          status: newStatus
        }
      };
      
      return admin.messaging().send(message);
    }
  3. ๊ฐœ์ธํ™”๋œ ์ถ”์ฒœ

    ์‚ฌ์šฉ์ž์˜ ๊ด€์‹ฌ์‚ฌ๋‚˜ ์ด์ „ ํ™œ๋™์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๋งž์ถคํ˜• ์žฌ๋Šฅ์ด๋‚˜ ์„œ๋น„์Šค๋ฅผ ์ถ”์ฒœํ•˜๋Š” ์•Œ๋ฆผ์„ ๋ณด๋‚ผ ์ˆ˜ ์žˆ์–ด.

    // ๋งž์ถคํ˜• ์ถ”์ฒœ ์•Œ๋ฆผ ์˜ˆ์‹œ (์„œ๋ฒ„ ์ฝ”๋“œ)
    async function sendPersonalizedRecommendation(user) {
      // ์‚ฌ์šฉ์ž์˜ ๊ด€์‹ฌ์‚ฌ์™€ ์ด์ „ ํ™œ๋™ ๊ธฐ๋ฐ˜์œผ๋กœ ์ถ”์ฒœ ํ•ญ๋ชฉ ์ฐพ๊ธฐ
      const recommendations = await getRecommendationsForUser(user.id);
      
      if (recommendations.length === 0) return;
      
      // ๊ฐ€์žฅ ๊ด€๋ จ์„ฑ ๋†’์€ ์ถ”์ฒœ ์„ ํƒ
      const topRecommendation = recommendations[0];
      
      const message = {
        token: user.fcmToken,
        notification: {
          title: `${user.firstName}๋‹˜์„ ์œ„ํ•œ ๋งž์ถค ์ถ”์ฒœ`,
          body: `"${topRecommendation.title}" ์žฌ๋Šฅ์ด ํšŒ์›๋‹˜์˜ ๊ด€์‹ฌ์‚ฌ์™€ ์ผ์น˜ํ•ฉ๋‹ˆ๋‹ค!`
        },
        data: {
          type: 'recommendation',
          itemId: topRecommendation.id,
          category: topRecommendation.category
        }
      };
      
      return admin.messaging().send(message);
    }
  4. ๋ฆฌ๋งˆ์ธ๋” ๋ฐ ์•Œ๋ฆผ

    ์˜ˆ์•ฝ๋œ ๋ฏธํŒ…, ๋งˆ๊ฐ์ผ, ์ด๋ฒคํŠธ ๋“ฑ์„ ์ƒ๊ธฐ์‹œ์ผœ์ฃผ๋Š” ์•Œ๋ฆผ์„ ๋ณด๋‚ผ ์ˆ˜ ์žˆ์–ด.

    // ๋ฆฌ๋งˆ์ธ๋” ์•Œ๋ฆผ ์˜ˆ์‹œ (์„œ๋ฒ„ ์ฝ”๋“œ)
    function scheduleReminderNotification(userToken, eventId, eventTitle, eventTime) {
      // ์ด๋ฒคํŠธ 1์‹œ๊ฐ„ ์ „์— ์•Œ๋ฆผ ์˜ˆ์•ฝ
      const reminderTime = new Date(eventTime);
      reminderTime.setHours(reminderTime.getHours() - 1);
      
      const message = {
        token: userToken,
        notification: {
          title: '๊ณง ์˜ˆ์ •๋œ ์ผ์ •์ด ์žˆ์Šต๋‹ˆ๋‹ค',
          body: `1์‹œ๊ฐ„ ํ›„ "${eventTitle}" ์ผ์ •์ด ์žˆ์Šต๋‹ˆ๋‹ค. ์ค€๋น„ํ•˜์„ธ์š”!`
        },
        data: {
          type: 'reminder',
          eventId: eventId
        },
        android: {
          priority: 'high',
          ttl: 3600 * 1000 // 1์‹œ๊ฐ„
        },
        apns: {
          payload: {
            aps: {
              sound: 'default'
            }
          }
        }
      };
      
      // ์˜ˆ์•ฝ๋œ ์‹œ๊ฐ„์— ๋ฉ”์‹œ์ง€ ์ „์†ก
      return admin.messaging().sendToDevice(userToken, message, {
        timeToLive: Math.floor((reminderTime.getTime() - Date.now()) / 1000)
      });
    }
  5. ์‚ฌ์šฉ์ž ์žฌ์ฐธ์—ฌ ์œ ๋„

    ์˜ค๋žซ๋™์•ˆ ์•ฑ์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š์€ ์‚ฌ์šฉ์ž์—๊ฒŒ ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์ด๋‚˜ ์ฝ˜ํ…์ธ ๋ฅผ ์†Œ๊ฐœํ•˜๋Š” ์•Œ๋ฆผ์„ ๋ณด๋‚ด ์žฌ์ฐธ์—ฌ๋ฅผ ์œ ๋„ํ•  ์ˆ˜ ์žˆ์–ด.

    // ์žฌ์ฐธ์—ฌ ์•Œ๋ฆผ ์˜ˆ์‹œ (์„œ๋ฒ„ ์ฝ”๋“œ)
    async function sendReengagementNotification(inactiveUsers) {
      const batch = [];
      
      for (const user of inactiveUsers) {
        // ๋งˆ์ง€๋ง‰ ํ™œ๋™ ๊ธฐ๋ฐ˜์œผ๋กœ ๋งž์ถคํ˜• ๋ฉ”์‹œ์ง€ ์ƒ์„ฑ
        let title, body;
        const daysSinceLastActivity = getDaysSince(user.lastActiveAt);
        
        if (daysSinceLastActivity > 30) {
          title = '์˜ค๋žœ๋งŒ์ด์—์š”!';
          body = '์žฌ๋Šฅ๋„ท์— ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์ด ๋งŽ์ด ์ถ”๊ฐ€๋์–ด์š”. ์ง€๊ธˆ ํ™•์ธํ•ด๋ณด์„ธ์š”!';
        } else {
          title = '๋Œ์•„์˜ค์„ธ์š”!';
          body = 'ํšŒ์›๋‹˜์„ ์œ„ํ•œ ์ƒˆ๋กœ์šด ์žฌ๋Šฅ๋“ค์ด ๊ธฐ๋‹ค๋ฆฌ๊ณ  ์žˆ์–ด์š”.';
        }
        
        batch.push({
          token: user.fcmToken,
          notification: { title, body },
          data: {
            type: 'reengagement',
            lastSeen: user.lastActiveAt
          }
        });
      }
      
      // ๋ฐฐ์น˜๋กœ ์•Œ๋ฆผ ์ „์†ก
      return admin.messaging().sendAll(batch);
    }
ํ‘ธ์‹œ ์•Œ๋ฆผ ํ™œ์šฉ ์‚ฌ๋ก€ ์žฌ๋Šฅ๋„ท ์‹ค์‹œ๊ฐ„ ๋ฉ”์‹œ์ง• ๊ฑฐ๋ž˜ ์ƒํƒœ ์—…๋ฐ์ดํŠธ ๋งž์ถคํ˜• ์ถ”์ฒœ ์‚ฌ์šฉ์ž ์žฌ์ฐธ์—ฌ ์ด๋ฒคํŠธ ์•Œ๋ฆผ ๋ฆฌ๋งˆ์ธ๋”

ํ‘ธ์‹œ ์•Œ๋ฆผ ๋ฒ ์ŠคํŠธ ํ”„๋ž™ํ‹ฐ์Šค

  1. ์ ์ ˆํ•œ ๋นˆ๋„ ์œ ์ง€ํ•˜๊ธฐ

    ๋„ˆ๋ฌด ๋งŽ์€ ์•Œ๋ฆผ์€ ์‚ฌ์šฉ์ž๋ฅผ ์งœ์ฆ๋‚˜๊ฒŒ ๋งŒ๋“ค ์ˆ˜ ์žˆ์–ด. ํ•˜๋ฃจ์— ๋ณด๋‚ด๋Š” ์•Œ๋ฆผ ์ˆ˜๋ฅผ ์ œํ•œํ•˜๊ณ , ์ •๋ง ์ค‘์š”ํ•œ ์ •๋ณด๋งŒ ์•Œ๋ฆผ์œผ๋กœ ๋ณด๋‚ด์ž.

  2. ๊ฐœ์ธํ™”๋œ ์ฝ˜ํ…์ธ  ์ œ๊ณตํ•˜๊ธฐ

    ์‚ฌ์šฉ์ž์˜ ์ด๋ฆ„, ๊ด€์‹ฌ์‚ฌ, ํ–‰๋™ ํŒจํ„ด ๋“ฑ์„ ํ™œ์šฉํ•ด ๊ฐœ์ธํ™”๋œ ์•Œ๋ฆผ์„ ๋ณด๋‚ด๋ฉด ์ฐธ์—ฌ์œจ์ด ํฌ๊ฒŒ ๋†’์•„์ ธ.

  3. ์ ์ ˆํ•œ ํƒ€์ด๋ฐ ์„ ํƒํ•˜๊ธฐ

    ์‚ฌ์šฉ์ž์˜ ์‹œ๊ฐ„๋Œ€์™€ ํ™œ๋™ ํŒจํ„ด์„ ๊ณ ๋ คํ•ด ์•Œ๋ฆผ์„ ๋ณด๋‚ด๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•ด. ์˜ˆ๋ฅผ ๋“ค์–ด, ์•„์นจ์—๋Š” ๊ฐ€๋ฒผ์šด ์ •๋ณด, ์ €๋…์—๋Š” ์—ฌ๊ฐ€ ๊ด€๋ จ ์ฝ˜ํ…์ธ ๋ฅผ ์ถ”์ฒœํ•˜๋Š” ์‹์œผ๋กœ ๋ง์ด์•ผ.

  4. ์„ธ๊ทธ๋จผํŠธ๋ณ„ ์ „๋žต ์ˆ˜๋ฆฝํ•˜๊ธฐ

    ์‚ฌ์šฉ์ž๋ฅผ ํ™œ์„ฑ ์‚ฌ์šฉ์ž, ๋น„ํ™œ์„ฑ ์‚ฌ์šฉ์ž, ์‹ ๊ทœ ์‚ฌ์šฉ์ž ๋“ฑ์œผ๋กœ ๋‚˜๋ˆ„์–ด ๊ฐ ๊ทธ๋ฃน์— ๋งž๋Š” ์•Œ๋ฆผ ์ „๋žต์„ ์ˆ˜๋ฆฝํ•˜์ž.

  5. A/B ํ…Œ์ŠคํŠธ ์‹ค์‹œํ•˜๊ธฐ

    ๋‹ค์–‘ํ•œ ์•Œ๋ฆผ ๋ฌธ๊ตฌ, ๋””์ž์ธ, ํƒ€์ด๋ฐ์„ ํ…Œ์ŠคํŠธํ•ด ์–ด๋–ค ๋ฐฉ์‹์ด ๊ฐ€์žฅ ํšจ๊ณผ์ ์ธ์ง€ ๋ฐ์ดํ„ฐ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๊ฒฐ์ •ํ•˜์ž.

  6. ๋”ฅ๋งํฌ ํ™œ์šฉํ•˜๊ธฐ

    ์•Œ๋ฆผ์„ ํด๋ฆญํ–ˆ์„ ๋•Œ ๊ด€๋ จ ํ™”๋ฉด์œผ๋กœ ๋ฐ”๋กœ ์ด๋™ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋”ฅ๋งํฌ๋ฅผ ์„ค์ •ํ•˜๋ฉด ์‚ฌ์šฉ์ž ๊ฒฝํ—˜์ด ํฌ๊ฒŒ ํ–ฅ์ƒ๋ผ.

  7. ์‚ฌ์šฉ์ž ์ œ์–ด๊ถŒ ์ œ๊ณตํ•˜๊ธฐ

    ์‚ฌ์šฉ์ž๊ฐ€ ์•Œ๋ฆผ ์œ ํ˜•๊ณผ ๋นˆ๋„๋ฅผ ์‰ฝ๊ฒŒ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š” ์„ค์ • ํ™”๋ฉด์„ ์ œ๊ณตํ•˜์ž. ์ด๋Š” ์•Œ๋ฆผ ์ฐจ๋‹จ์„ ๋ฐฉ์ง€ํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋ผ.

  8. ์„ฑ๊ณผ ์ธก์ •ํ•˜๊ธฐ

    ์•Œ๋ฆผ ์˜คํ”ˆ์œจ, ํด๋ฆญ๋ฅ , ์ „ํ™˜์œจ ๋“ฑ์„ ์ธก์ •ํ•ด ์•Œ๋ฆผ ์ „๋žต์˜ ํšจ๊ณผ๋ฅผ ์ง€์†์ ์œผ๋กœ ํ‰๊ฐ€ํ•˜๊ณ  ๊ฐœ์„ ํ•˜์ž.

ํ‘ธ์‹œ ์•Œ๋ฆผ ์„ฑ๊ณผ ์ธก์ • ๊ตฌํ˜„

ํ‘ธ์‹œ ์•Œ๋ฆผ์˜ ํšจ๊ณผ๋ฅผ ์ธก์ •ํ•˜๊ธฐ ์œ„ํ•œ ์ฝ”๋“œ ์˜ˆ์‹œ:

// React Native์—์„œ ์•Œ๋ฆผ ๋ถ„์„ ๊ตฌํ˜„ ์˜ˆ์‹œ
import analytics from '@react-native-firebase/analytics';
import messaging from '@react-native-firebase/messaging';

// ์•Œ๋ฆผ ์ˆ˜์‹  ์‹œ ์ด๋ฒคํŠธ ๊ธฐ๋ก
messaging().onMessage(async remoteMessage => {
  // ์•Œ๋ฆผ ์ˆ˜์‹  ์ด๋ฒคํŠธ ๊ธฐ๋ก
  await analytics().logEvent('notification_received', {
    notification_id: remoteMessage.messageId,
    notification_type: remoteMessage.data?.type || 'unknown',
    timestamp: Date.now()
  });
  
  // ์•Œ๋ฆผ ํ‘œ์‹œ ๋กœ์ง...
});

// ์•Œ๋ฆผ ํด๋ฆญ ์‹œ ์ด๋ฒคํŠธ ๊ธฐ๋ก
messaging().onNotificationOpenedApp(remoteMessage => {
  // ์•Œ๋ฆผ ํด๋ฆญ ์ด๋ฒคํŠธ ๊ธฐ๋ก
  analytics().logEvent('notification_opened', {
    notification_id: remoteMessage.messageId,
    notification_type: remoteMessage.data?.type || 'unknown',
    timestamp: Date.now()
  });
  
  // ๋”ฅ๋งํฌ ์ฒ˜๋ฆฌ ๋กœ์ง...
});

// ํŠน์ • ํ™”๋ฉด์—์„œ ์ „ํ™˜ ์™„๋ฃŒ ์‹œ ์ด๋ฒคํŠธ ๊ธฐ๋ก
function logNotificationConversion(notificationId, conversionType) {
  analytics().logEvent('notification_conversion', {
    notification_id: notificationId,
    conversion_type: conversionType,
    timestamp: Date.now()
  });
}

ํ‘ธ์‹œ ์•Œ๋ฆผ์€ ์‚ฌ์šฉ์ž์™€ ์•ฑ์„ ์—ฐ๊ฒฐํ•˜๋Š” ๊ฐ•๋ ฅํ•œ ๋‹ค๋ฆฌ ์—ญํ• ์„ ํ•ด. ํŠนํžˆ ์žฌ๋Šฅ๋„ท๊ณผ ๊ฐ™์€ ํ”Œ๋žซํผ์—์„œ๋Š” ์‚ฌ์šฉ์ž ๊ฐ„์˜ ์†Œํ†ต๊ณผ ๊ฑฐ๋ž˜๋ฅผ ์ด‰์ง„ํ•˜๋Š” ์ค‘์š”ํ•œ ๋„๊ตฌ๊ฐ€ ๋  ์ˆ˜ ์žˆ์–ด. ํ•˜์ง€๋งŒ ํ•ญ์ƒ ๊ธฐ์–ตํ•ด์•ผ ํ•  ๊ฒƒ์€ "๋œ ๋ณด๋‚ด๋Š” ๊ฒƒ์ด ๋” ํšจ๊ณผ์ ์ผ ์ˆ˜ ์žˆ๋‹ค"๋Š” ์ ์ด์•ผ. ์ •๋ง ์ค‘์š”ํ•˜๊ณ  ๊ด€๋ จ์„ฑ ๋†’์€ ์•Œ๋ฆผ๋งŒ ์„ ๋ณ„์ ์œผ๋กœ ๋ณด๋‚ด์„œ ์‚ฌ์šฉ์ž์˜ ์‹ ๋ขฐ๋ฅผ ์–ป๋Š” ๊ฒƒ์ด ์žฅ๊ธฐ์ ์œผ๋กœ ๋” ํฐ ์„ฑ๊ณต์„ ๊ฐ€์ ธ์˜ฌ ๊ฑฐ์•ผ! ๐Ÿš€

10. ์ž์ฃผ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ์™€ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ• ๐Ÿ”ง

ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ๊ตฌํ˜„ํ•˜๋‹ค ๋ณด๋ฉด ๋‹ค์–‘ํ•œ ๋ฌธ์ œ์— ๋ถ€๋”ชํž ์ˆ˜ ์žˆ์–ด. ์—ฌ๋Ÿฌ ์‹œ์Šคํ…œ๊ณผ ํ”Œ๋žซํผ์ด ๊ด€๋ จ๋˜์–ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๋ฌธ์ œ ํ•ด๊ฒฐ์ด ๋ณต์žกํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, ๋Œ€๋ถ€๋ถ„์˜ ๋ฌธ์ œ๋Š” ๋ช‡ ๊ฐ€์ง€ ์ผ๋ฐ˜์ ์ธ ํŒจํ„ด์— ์†ํ•ด. ๋งˆ์น˜ ์ž๋™์ฐจ ๊ณ ์žฅ์˜ ๋Œ€๋ถ€๋ถ„์ด ๋ช‡ ๊ฐ€์ง€ ์ฃผ์š” ๋ถ€ํ’ˆ์—์„œ ๋ฐœ์ƒํ•˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ๋ง์ด์•ผ. ์ด ์„น์…˜์—์„œ๋Š” ๊ฐ€์žฅ ํ”ํžˆ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ์™€ ๊ทธ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์„ ์•Œ์•„๋ณผ๊ฒŒ! ๐Ÿ› ๏ธ

๋ฌธ์ œ 1: FCM ํ† ํฐ์ด ์ƒ์„ฑ๋˜์ง€ ์•Š๊ฑฐ๋‚˜ ์—…๋ฐ์ดํŠธ๋˜์ง€ ์•Š๋Š” ๋ฌธ์ œ

์ฆ์ƒ: FCM ํ† ํฐ์„ ๊ฐ€์ ธ์˜ค๋ ค๊ณ  ํ•  ๋•Œ null์ด ๋ฐ˜ํ™˜๋˜๊ฑฐ๋‚˜, ํ† ํฐ์ด ์ƒ์„ฑ๋˜์—ˆ์ง€๋งŒ ์„œ๋ฒ„์— ์ œ๋Œ€๋กœ ์ €์žฅ๋˜์ง€ ์•Š๋Š” ๋ฌธ์ œ.

ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•:

  1. Firebase ์„ค์ • ํŒŒ์ผ(google-services.json, GoogleService-Info.plist)์ด ์˜ฌ๋ฐ”๋ฅธ ์œ„์น˜์— ์žˆ๋Š”์ง€ ํ™•์ธ
  2. Firebase ํ”„๋กœ์ ํŠธ ์„ค์ •์ด ์˜ฌ๋ฐ”๋ฅธ์ง€ ํ™•์ธ (์•ฑ ID, ํŒจํ‚ค์ง€ ์ด๋ฆ„ ๋“ฑ)
  3. ๋„คํŠธ์›Œํฌ ์—ฐ๊ฒฐ ์ƒํƒœ ํ™•์ธ
  4. ํ† ํฐ ์ƒ์„ฑ ๋กœ์ง์— ์˜ค๋ฅ˜๊ฐ€ ์—†๋Š”์ง€ ํ™•์ธ
// FCM ํ† ํฐ ์ƒ์„ฑ ๋ฐ ์ €์žฅ ๋กœ์ง ๊ฐœ์„ 
import messaging from '@react-native-firebase/messaging';
import AsyncStorage from '@react-native-async-storage/async-storage';

async function getFCMToken() {
  try {
    // ์ €์žฅ๋œ ํ† ํฐ์ด ์žˆ๋Š”์ง€ ํ™•์ธ
    const savedToken = await AsyncStorage.getItem('fcmToken');
    
    // ์ƒˆ ํ† ํฐ ๊ฐ€์ ธ์˜ค๊ธฐ
    const fcmToken = await messaging().getToken();
    
    if (!fcmToken) {
      throw new Error('FCM ํ† ํฐ์„ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.');
    }
    
    // ํ† ํฐ์ด ๋ณ€๊ฒฝ๋˜์—ˆ๊ฑฐ๋‚˜ ์ €์žฅ๋œ ํ† ํฐ์ด ์—†๋Š” ๊ฒฝ์šฐ์—๋งŒ ์„œ๋ฒ„์— ์—…๋ฐ์ดํŠธ
    if (!savedToken || savedToken !== fcmToken) {
      console.log('FCM ํ† ํฐ ์—…๋ฐ์ดํŠธ:', fcmToken);
      
      // ํ† ํฐ์„ ๋กœ์ปฌ์— ์ €์žฅ
      await AsyncStorage.setItem('fcmToken', fcmToken);
      
      // ์„œ๋ฒ„์— ํ† ํฐ ์—…๋ฐ์ดํŠธ
      const response = await fetch('https://your-api.com/update-token', {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
        },
        body: JSON.stringify({
          userId: 'current-user-id',
          token: fcmToken,
          platform: Platform.OS
        }),
      });
      
      if (!response.ok) {
        throw new Error('์„œ๋ฒ„์— ํ† ํฐ์„ ์—…๋ฐ์ดํŠธํ•˜์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค.');
      }
    }
    
    return fcmToken;
  } catch (error) {
    console.error('FCM ํ† ํฐ ์ฒ˜๋ฆฌ ์ค‘ ์˜ค๋ฅ˜:', error);
    // ์˜ค๋ฅ˜ ๋กœ๊น… ๋˜๋Š” ๋ถ„์„ ์„œ๋น„์Šค์— ๋ณด๊ณ 
    return null;
  }
}

๋ฌธ์ œ 2: iOS์—์„œ ํ‘ธ์‹œ ์•Œ๋ฆผ์ด ์ˆ˜์‹ ๋˜์ง€ ์•Š๋Š” ๋ฌธ์ œ

์ฆ์ƒ: Android์—์„œ๋Š” ์•Œ๋ฆผ์ด ์ž˜ ์ž‘๋™ํ•˜์ง€๋งŒ iOS์—์„œ๋Š” ์•Œ๋ฆผ์ด ์ „ํ˜€ ์ˆ˜์‹ ๋˜์ง€ ์•Š๋Š” ๋ฌธ์ œ.

ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•:

  1. APNs ์ธ์ฆ์„œ๊ฐ€ ์œ ํšจํ•œ์ง€ ํ™•์ธ (๋งŒ๋ฃŒ๋˜์—ˆ์„ ์ˆ˜ ์žˆ์Œ)
  2. Xcode์—์„œ Push Notifications Capability๊ฐ€ ํ™œ์„ฑํ™”๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธ
  3. ์‚ฌ์šฉ์ž๊ฐ€ ์•Œ๋ฆผ ๊ถŒํ•œ์„ ํ—ˆ์šฉํ–ˆ๋Š”์ง€ ํ™•์ธ
  4. ๊ฐœ๋ฐœ/ํ”„๋กœ๋•์…˜ ํ™˜๊ฒฝ์— ๋งž๋Š” APNs ์„ค์ •์„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š”์ง€ ํ™•์ธ
  5. AppDelegate.m์— ํ•„์š”ํ•œ ์ฝ”๋“œ๊ฐ€ ๋ชจ๋‘ ๊ตฌํ˜„๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธ
// iOS ์•Œ๋ฆผ ๊ถŒํ•œ ์š”์ฒญ ๋ฐ ํ™•์ธ ๋กœ์ง
import { Platform, Alert } from 'react-native';
import messaging from '@react-native-firebase/messaging';
import { openSettings } from 'react-native-permissions';

async function checkAndRequestNotificationPermission() {
  if (Platform.OS !== 'ios') return true;
  
  try {
    const authStatus = await messaging().hasPermission();
    
    if (authStatus === messaging.AuthorizationStatus.NOT_DETERMINED) {
      // ๊ถŒํ•œ ์š”์ฒญ
      const newStatus = await messaging().requestPermission();
      return newStatus === messaging.AuthorizationStatus.AUTHORIZED || 
             newStatus === messaging.AuthorizationStatus.PROVISIONAL;
    }
    
    if (authStatus === messaging.AuthorizationStatus.DENIED) {
      // ์‚ฌ์šฉ์ž์—๊ฒŒ ์„ค์ •์œผ๋กœ ์ด๋™ํ•˜์—ฌ ๊ถŒํ•œ์„ ํ™œ์„ฑํ™”ํ•˜๋„๋ก ์•ˆ๋‚ด
      Alert.alert(
        '์•Œ๋ฆผ ๊ถŒํ•œ ํ•„์š”',
        '์•ฑ์˜ ์ค‘์š”ํ•œ ์•Œ๋ฆผ์„ ๋ฐ›์œผ๋ ค๋ฉด ์•Œ๋ฆผ ๊ถŒํ•œ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ์„ค์ •์—์„œ ์•Œ๋ฆผ์„ ํ™œ์„ฑํ™”ํ•ด์ฃผ์„ธ์š”.',
        [
          { text: '๋‚˜์ค‘์—', style: 'cancel' },
          { text: '์„ค์ •์œผ๋กœ ์ด๋™', onPress: () => openSettings() }
        ]
      );
      return false;
    }
    
    return authStatus === messaging.AuthorizationStatus.AUTHORIZED || 
           authStatus === messaging.AuthorizationStatus.PROVISIONAL;
  } catch (error) {
    console.error('์•Œ๋ฆผ ๊ถŒํ•œ ํ™•์ธ ์ค‘ ์˜ค๋ฅ˜:', error);
    return false;
  }
}
ํ‘ธ์‹œ ์•Œ๋ฆผ ๋ฌธ์ œ ํ•ด๊ฒฐ ๊ฐ€์ด๋“œ ํ‘ธ์‹œ ์•Œ๋ฆผ์ด ์ž‘๋™ํ•˜์ง€ ์•Š์Œ 1. ์„ค์ • ํ™•์ธ โ€ข Firebase ์„ค์ • ํŒŒ์ผ โ€ข ์ธ์ฆ์„œ ๋ฐ ํ‚ค โ€ข ์•ฑ ID ๋ฐ ๋ฒˆ๋“ค ID 2. ๊ถŒํ•œ ํ™•์ธ โ€ข ์•Œ๋ฆผ ๊ถŒํ•œ ์ƒํƒœ โ€ข ๋ฐฐํ„ฐ๋ฆฌ ์ตœ์ ํ™” ์„ค์ • โ€ข ๋ฐฑ๊ทธ๋ผ์šด๋“œ ์ œํ•œ 3. ์ฝ”๋“œ ๊ฒ€์ฆ โ€ข ํ† ํฐ ๋“ฑ๋ก ๋กœ์ง โ€ข ์•Œ๋ฆผ ์ฒ˜๋ฆฌ ํ•ธ๋“ค๋Ÿฌ โ€ข ํ”Œ๋žซํผ๋ณ„ ์„ค์ •

๋ฌธ์ œ 3: ์•Œ๋ฆผ์€ ์ˆ˜์‹ ๋˜์ง€๋งŒ ํด๋ฆญํ•ด๋„ ์•ฑ์ด ์—ด๋ฆฌ์ง€ ์•Š๊ฑฐ๋‚˜ ํŠน์ • ํ™”๋ฉด์œผ๋กœ ์ด๋™ํ•˜์ง€ ์•Š๋Š” ๋ฌธ์ œ

์ฆ์ƒ: ํ‘ธ์‹œ ์•Œ๋ฆผ์€ ์ •์ƒ์ ์œผ๋กœ ์ˆ˜์‹ ๋˜์ง€๋งŒ, ์•Œ๋ฆผ์„ ํด๋ฆญํ•ด๋„ ์•ฑ์ด ์—ด๋ฆฌ์ง€ ์•Š๊ฑฐ๋‚˜ ํŠน์ • ํ™”๋ฉด์œผ๋กœ ์ด๋™ํ•˜์ง€ ์•Š๋Š” ๋ฌธ์ œ.

ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•:

  1. Android์—์„œ Intent ํ•„ํ„ฐ๊ฐ€ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์„ค์ •๋˜์—ˆ๋Š”์ง€ ํ™•์ธ
  2. ์•Œ๋ฆผ ํด๋ฆญ ํ•ธ๋“ค๋Ÿฌ๊ฐ€ ์ œ๋Œ€๋กœ ๊ตฌํ˜„๋˜์—ˆ๋Š”์ง€ ํ™•์ธ
  3. ๋”ฅ๋งํฌ ์ฒ˜๋ฆฌ ๋กœ์ง์— ์˜ค๋ฅ˜๊ฐ€ ์—†๋Š”์ง€ ํ™•์ธ
  4. ์•Œ๋ฆผ ํŽ˜์ด๋กœ๋“œ์— ํ•„์š”ํ•œ ๋ฐ์ดํ„ฐ๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธ
// ์•Œ๋ฆผ ํด๋ฆญ ์ฒ˜๋ฆฌ ๋ฐ ๋”ฅ๋งํฌ ๊ตฌํ˜„ ๊ฐœ์„ 
import React, { useEffect } from 'react';
import { Platform } from 'react-native';
import messaging from '@react-native-firebase/messaging';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';

const Stack = createStackNavigator();
const navigationRef = React.createRef();

// ๋”ฅ๋งํฌ ๋„ค๋น„๊ฒŒ์ด์…˜ ํ•จ์ˆ˜
function navigate(name, params) {
  if (navigationRef.current) {
    navigationRef.current.navigate(name, params);
  } else {
    // ๋„ค๋น„๊ฒŒ์ด์…˜์ด ์ค€๋น„๋˜์ง€ ์•Š์€ ๊ฒฝ์šฐ๋ฅผ ์œ„ํ•œ ๋Œ€๊ธฐ ๋กœ์ง
    setTimeout(() => {
      navigate(name, params);
    }, 500);
  }
}

// ์•Œ๋ฆผ ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ ํ•จ์ˆ˜
function handleNotificationData(data) {
  if (!data) return;
  
  console.log('์•Œ๋ฆผ ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ:', data);
  
  try {
    switch (data.type) {
      case 'chat':
        navigate('ChatScreen', { chatId: data.chatId, userId: data.senderId });
        break;
      case 'transaction':
        navigate('TransactionDetails', { transactionId: data.transactionId });
        break;
      case 'profile':
        navigate('UserProfile', { userId: data.userId });
        break;
      default:
        // ๊ธฐ๋ณธ์ ์œผ๋กœ ํ™ˆ ํ™”๋ฉด์œผ๋กœ ์ด๋™
        navigate('Home');
    }
  } catch (error) {
    console.error('์•Œ๋ฆผ ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ ์ค‘ ์˜ค๋ฅ˜:', error);
  }
}

function App() {
  useEffect(() => {
    // ์•ฑ์ด ์ข…๋ฃŒ๋œ ์ƒํƒœ์—์„œ ์•Œ๋ฆผ์œผ๋กœ ์—ด๋ ธ์„ ๋•Œ
    messaging()
      .getInitialNotification()
      .then(remoteMessage => {
        if (remoteMessage) {
          console.log('์ข…๋ฃŒ ์ƒํƒœ์—์„œ ์•Œ๋ฆผ์œผ๋กœ ์•ฑ ์‹คํ–‰:', remoteMessage);
          // ์•ฝ๊ฐ„์˜ ์ง€์—ฐ์„ ๋‘์–ด ๋„ค๋น„๊ฒŒ์ด์…˜์ด ์ค€๋น„๋˜๋„๋ก ํ•จ
          setTimeout(() => {
            handleNotificationData(remoteMessage.data);
          }, 1000);
        }
      })
      .catch(error => {
        console.error('์ดˆ๊ธฐ ์•Œ๋ฆผ ์ฒ˜๋ฆฌ ์ค‘ ์˜ค๋ฅ˜:', error);
      });

    // ๋ฐฑ๊ทธ๋ผ์šด๋“œ์—์„œ ์•Œ๋ฆผ ํด๋ฆญ์œผ๋กœ ์•ฑ์ด ์—ด๋ ธ์„ ๋•Œ
    const unsubscribe = messaging().onNotificationOpenedApp(remoteMessage => {
      console.log('๋ฐฑ๊ทธ๋ผ์šด๋“œ์—์„œ ์•Œ๋ฆผ ํด๋ฆญ:', remoteMessage);
      handleNotificationData(remoteMessage.data);
    });

    return unsubscribe;
  }, []);

  return (
    <NavigationContainer ref={navigationRef}>
      <Stack.Navigator>
        {/* ํ™”๋ฉด ์ •์˜ */}
        <Stack.Screen name="Home" component={HomeScreen} />
        <Stack.Screen name="ChatScreen" component={ChatScreen} />
        <Stack.Screen name="TransactionDetails" component={TransactionDetails} />
        <Stack.Screen name="UserProfile" component={UserProfile} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}

๋ฌธ์ œ 4: ํŠน์ • ๊ธฐ๊ธฐ์—์„œ๋งŒ ์•Œ๋ฆผ์ด ์ž‘๋™ํ•˜์ง€ ์•Š๋Š” ๋ฌธ์ œ

์ฆ์ƒ: ์ผ๋ถ€ ๊ธฐ๊ธฐ์—์„œ๋Š” ์•Œ๋ฆผ์ด ์ •์ƒ์ ์œผ๋กœ ์ž‘๋™ํ•˜์ง€๋งŒ, ํŠน์ • ๊ธฐ๊ธฐ์—์„œ๋งŒ ์•Œ๋ฆผ์ด ์ˆ˜์‹ ๋˜์ง€ ์•Š๋Š” ๋ฌธ์ œ.

ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•:

  1. ๊ธฐ๊ธฐ๋ณ„ ๋ฐฐํ„ฐ๋ฆฌ ์ตœ์ ํ™” ์„ค์ • ํ™•์ธ (ํŠนํžˆ ์ค‘๊ตญ ์ œ์กฐ์‚ฌ ๊ธฐ๊ธฐ)
  2. ๊ธฐ๊ธฐ์˜ OS ๋ฒ„์ „์— ๋”ฐ๋ฅธ ํ˜ธํ™˜์„ฑ ๋ฌธ์ œ ํ™•์ธ
  3. ํ•ด๋‹น ๊ธฐ๊ธฐ์˜ FCM ํ† ํฐ์ด ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ๋“ฑ๋ก๋˜์—ˆ๋Š”์ง€ ํ™•์ธ
  4. ๊ธฐ๊ธฐ๋ณ„ ํŠน์ˆ˜ ๊ถŒํ•œ ์„ค์ • ํ™•์ธ (์˜ˆ: MIUI์˜ ์ž๋™ ์‹œ์ž‘ ๊ถŒํ•œ)
// ๊ธฐ๊ธฐ๋ณ„ ์ตœ์ ํ™” ์„ค์ • ์•ˆ๋‚ด ๊ตฌํ˜„
import { Platform, Alert, Linking } from 'react-native';
import DeviceInfo from 'react-native-device-info';

async function checkDeviceOptimizationSettings() {
  if (Platform.OS !== 'android') return;
  
  try {
    const manufacturer = await DeviceInfo.getManufacturer();
    const model = await DeviceInfo.getModel();
    
    // ํŠน์ • ์ œ์กฐ์‚ฌ ๊ธฐ๊ธฐ์— ๋Œ€ํ•œ ํŠน๋ณ„ ์ฒ˜๋ฆฌ
    if (manufacturer.toLowerCase().includes('xiaomi') || 
        manufacturer.toLowerCase().includes('redmi') || 
        manufacturer.toLowerCase().includes('poco')) {
      
      Alert.alert(
        '์•Œ๋ฆผ ์„ค์ • ํ™•์ธ',
        '์ƒค์˜ค๋ฏธ ๊ธฐ๊ธฐ์—์„œ๋Š” ์•Œ๋ฆผ์„ ๋ฐ›๊ธฐ ์œ„ํ•ด ์ถ”๊ฐ€ ์„ค์ •์ด ํ•„์š”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฐฐํ„ฐ๋ฆฌ ์„ค์ •์—์„œ ์•ฑ์˜ ์ž๋™ ์‹œ์ž‘ ๊ถŒํ•œ๊ณผ ๋ฐฐํ„ฐ๋ฆฌ ์ œํ•œ์„ ํ•ด์ œํ•ด์ฃผ์„ธ์š”.',
        [
          { text: '๋‚˜์ค‘์—', style: 'cancel' },
          { 
            text: '์„ค์ •์œผ๋กœ ์ด๋™', 
            onPress: () => Linking.openSettings() 
          }
        ]
      );
    } else if (manufacturer.toLowerCase().includes('huawei') || 
               manufacturer.toLowerCase().includes('honor')) {
      
      Alert.alert(
        '์•Œ๋ฆผ ์„ค์ • ํ™•์ธ',
        'ํ™”์›จ์ด ๊ธฐ๊ธฐ์—์„œ๋Š” ์•Œ๋ฆผ์„ ๋ฐ›๊ธฐ ์œ„ํ•ด ์ถ”๊ฐ€ ์„ค์ •์ด ํ•„์š”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฐฐํ„ฐ๋ฆฌ ์„ค์ •์—์„œ ์•ฑ์„ "๋ณดํ˜ธ๋œ ์•ฑ"์œผ๋กœ ์„ค์ •ํ•˜๊ณ , ์•ฑ ์‹œ์ž‘ ๊ด€๋ฆฌ์—์„œ ์ž๋™ ์‹œ์ž‘์„ ํ—ˆ์šฉํ•ด์ฃผ์„ธ์š”.',
        [
          { text: '๋‚˜์ค‘์—', style: 'cancel' },
          { 
            text: '์„ค์ •์œผ๋กœ ์ด๋™', 
            onPress: () => Linking.openSettings() 
          }
        ]
      );
    } else if (manufacturer.toLowerCase().includes('oppo') || 
               manufacturer.toLowerCase().includes('oneplus') || 
               manufacturer.toLowerCase().includes('realme') || 
               manufacturer.toLowerCase().includes('vivo')) {
      
      Alert.alert(
        '์•Œ๋ฆผ ์„ค์ • ํ™•์ธ',
        '์ด ๊ธฐ๊ธฐ์—์„œ๋Š” ์•Œ๋ฆผ์„ ๋ฐ›๊ธฐ ์œ„ํ•ด ์ถ”๊ฐ€ ์„ค์ •์ด ํ•„์š”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฐฐํ„ฐ๋ฆฌ ์„ค์ •์—์„œ ์•ฑ์˜ ๋ฐฑ๊ทธ๋ผ์šด๋“œ ์‹คํ–‰ ๊ถŒํ•œ์„ ํ—ˆ์šฉํ•ด์ฃผ์„ธ์š”.',
        [
          { text: '๋‚˜์ค‘์—', style: 'cancel' },
          { 
            text: '์„ค์ •์œผ๋กœ ์ด๋™', 
            onPress: () => Linking.openSettings() 
          }
        ]
      );
    }
    
    // ๋กœ๊น…์„ ์œ„ํ•ด ๊ธฐ๊ธฐ ์ •๋ณด ๊ธฐ๋ก
    console.log('๊ธฐ๊ธฐ ์ •๋ณด:', { manufacturer, model });
    
  } catch (error) {
    console.error('๊ธฐ๊ธฐ ์ •๋ณด ํ™•์ธ ์ค‘ ์˜ค๋ฅ˜:', error);
  }
}

๋ฌธ์ œ 5: ์•Œ๋ฆผ ์Šคํƒ€์ผ์ด๋‚˜ ์†Œ๋ฆฌ๊ฐ€ ์˜ˆ์ƒ๊ณผ ๋‹ค๋ฅธ ๋ฌธ์ œ

์ฆ์ƒ: ์•Œ๋ฆผ์€ ์ˆ˜์‹ ๋˜์ง€๋งŒ ์Šคํƒ€์ผ, ์†Œ๋ฆฌ, ์ง„๋™ ๋“ฑ์ด ์˜ˆ์ƒ๊ณผ ๋‹ค๋ฅด๊ฒŒ ํ‘œ์‹œ๋˜๋Š” ๋ฌธ์ œ.

ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•:

  1. Android์—์„œ ์•Œ๋ฆผ ์ฑ„๋„ ์„ค์ • ํ™•์ธ
  2. ์•Œ๋ฆผ ํŽ˜์ด๋กœ๋“œ์— ์Šคํƒ€์ผ ๊ด€๋ จ ์†์„ฑ์ด ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์„ค์ •๋˜์—ˆ๋Š”์ง€ ํ™•์ธ
  3. ๊ธฐ๊ธฐ์˜ ์†Œ๋ฆฌ/์ง„๋™ ์„ค์ • ํ™•์ธ
  4. OS ๋ฒ„์ „์— ๋”ฐ๋ฅธ ์•Œ๋ฆผ ์Šคํƒ€์ผ ์ฐจ์ด ๊ณ ๋ ค
// ์•Œ๋ฆผ ์ฑ„๋„ ์„ค์ • ๊ฐœ์„ 
import { Platform } from 'react-native';
import notifee, { AndroidImportance, AndroidVisibility } from '@notifee/react-native';

async function setupNotificationChannels() {
  if (Platform.OS !== 'android') return;
  
  try {
    // ์ค‘์š” ์•Œ๋ฆผ ์ฑ„๋„
    await notifee.createChannel({
      id: 'important',
      name: '์ค‘์š” ์•Œ๋ฆผ',
      description: '์ค‘์š”ํ•œ ๋ฉ”์‹œ์ง€์™€ ์—…๋ฐ์ดํŠธ๋ฅผ ์œ„ํ•œ ์ฑ„๋„',
      importance: AndroidImportance.HIGH,
      sound: 'notification_sound',  // res/raw/notification_sound.mp3
      vibration: true,
      vibrationPattern: [300, 500, 300, 500],
      lights: true,
      lightColor: '#FF0000',
      visibility: AndroidVisibility.PUBLIC,
    });
    
    // ์ฑ„ํŒ… ์•Œ๋ฆผ ์ฑ„๋„
    await notifee.createChannel({
      id: 'chat',
      name: '์ฑ„ํŒ… ๋ฉ”์‹œ์ง€',
      description: '์ฑ„ํŒ… ๋ฉ”์‹œ์ง€๋ฅผ ์œ„ํ•œ ์ฑ„๋„',
      importance: AndroidImportance.HIGH,
      sound: 'chat_sound',  // res/raw/chat_sound.mp3
      vibration: true,
      vibrationPattern: [100, 200, 100, 200],
      lights: true,
      lightColor: '#00FF00',
      visibility: AndroidVisibility.PRIVATE,
    });
    
    // ์ผ๋ฐ˜ ์•Œ๋ฆผ ์ฑ„๋„
    await notifee.createChannel({
      id: 'default',
      name: '์ผ๋ฐ˜ ์•Œ๋ฆผ',
      description: '์ผ๋ฐ˜์ ์ธ ์ •๋ณด ์•Œ๋ฆผ์„ ์œ„ํ•œ ์ฑ„๋„',
      importance: AndroidImportance.DEFAULT,
      sound: 'default',
      vibration: true,
      visibility: AndroidVisibility.PRIVATE,
    });
    
    // ๋งˆ์ผ€ํŒ… ์•Œ๋ฆผ ์ฑ„๋„
    await notifee.createChannel({
      id: 'marketing',
      name: '๋งˆ์ผ€ํŒ… ์•Œ๋ฆผ',
      description: 'ํ”„๋กœ๋ชจ์…˜๊ณผ ๋งˆ์ผ€ํŒ… ๋ฉ”์‹œ์ง€๋ฅผ ์œ„ํ•œ ์ฑ„๋„',
      importance: AndroidImportance.LOW,
      sound: false,
      vibration: false,
      visibility: AndroidVisibility.PRIVATE,
    });
    
    console.log('์•Œ๋ฆผ ์ฑ„๋„ ์„ค์ • ์™„๋ฃŒ');
  } catch (error) {
    console.error('์•Œ๋ฆผ ์ฑ„๋„ ์„ค์ • ์ค‘ ์˜ค๋ฅ˜:', error);
  }
}

// ์•Œ๋ฆผ ํ‘œ์‹œ ํ•จ์ˆ˜
async function displayNotification(channelId, title, body, data = {}) {
  try {
    // ์ฑ„๋„ ID์— ๋”ฐ๋ผ ๋‹ค๋ฅธ ์Šคํƒ€์ผ ์ ์šฉ
    let androidConfig = {
      channelId,
      pressAction: {
        id: 'default',
      },
    };
    
    // ์ฑ„ํŒ… ์•Œ๋ฆผ์ธ ๊ฒฝ์šฐ ํŠน๋ณ„ํ•œ ์Šคํƒ€์ผ ์ ์šฉ
    if (channelId === 'chat') {
      androidConfig = {
        ...androidConfig,
        style: {
          type: 1, // BigText style
          text: body,
        },
        actions: [
          {
            title: '๋‹ต์žฅ',
            pressAction: {
              id: 'reply',
            },
          },
          {
            title: '์ฝ์Œ',
            pressAction: {
              id: 'mark_as_read',
            },
          },
        ],
      };
    }
    
    await notifee.displayNotification({
      title,
      body,
      data,
      android: androidConfig,
      ios: {
        sound: channelId === 'marketing' ? null : 'default',
        categoryId: channelId === 'chat' ? 'chat' : 'default',
      },
    });
  } catch (error) {
    console.error('์•Œ๋ฆผ ํ‘œ์‹œ ์ค‘ ์˜ค๋ฅ˜:', error);
  }
}

ํ‘ธ์‹œ ์•Œ๋ฆผ ๊ตฌํ˜„ ๊ณผ์ •์—์„œ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜๋Š” ๊ฒƒ์€ ์ž์—ฐ์Šค๋Ÿฌ์šด ์ผ์ด์•ผ. ์—ฌ๋Ÿฌ ์‹œ์Šคํ…œ๊ณผ ํ”Œ๋žซํผ์ด ๊ด€๋ จ๋˜์–ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๋””๋ฒ„๊น…์ด ๋ณต์žกํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, ์œ„์—์„œ ์„ค๋ช…ํ•œ ์ผ๋ฐ˜์ ์ธ ๋ฌธ์ œ์™€ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์„ ์ฐธ๊ณ ํ•˜๋ฉด ๋Œ€๋ถ€๋ถ„์˜ ์ด์Šˆ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์„ ๊ฑฐ์•ผ. ํŠนํžˆ ์žฌ๋Šฅ๋„ท๊ณผ ๊ฐ™์€ ์„œ๋น„์Šค์—์„œ๋Š” ํ‘ธ์‹œ ์•Œ๋ฆผ์ด ์‚ฌ์šฉ์ž ์ฐธ์—ฌ์— ์ค‘์š”ํ•œ ์—ญํ• ์„ ํ•˜๊ธฐ ๋•Œ๋ฌธ์—, ๋ชจ๋“  ์‚ฌ์šฉ์ž๊ฐ€ ์•Œ๋ฆผ์„ ์ œ๋Œ€๋กœ ๋ฐ›์„ ์ˆ˜ ์žˆ๋„๋ก ์ฒ ์ €ํžˆ ํ…Œ์ŠคํŠธํ•˜๊ณ  ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•ด! ๐Ÿ”

๊ฒฐ๋ก : ํ‘ธ์‹œ ์•Œ๋ฆผ์œผ๋กœ ์•ฑ์˜ ๊ฐ€์น˜๋ฅผ ๋†’์ด์ž ๐Ÿš€

์ง€๊ธˆ๊นŒ์ง€ React Native์—์„œ ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ๊ตฌํ˜„ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ดค์–ด. ํ‘ธ์‹œ ์•Œ๋ฆผ์€ ๋‹จ์ˆœํ•œ ๊ธฐ๋Šฅ์ด ์•„๋‹ˆ๋ผ ์‚ฌ์šฉ์ž์™€ ์•ฑ์„ ์—ฐ๊ฒฐํ•˜๋Š” ๊ฐ•๋ ฅํ•œ ์†Œํ†ต ์ฑ„๋„์ด์•ผ. ํŠนํžˆ ์žฌ๋Šฅ๋„ท๊ณผ ๊ฐ™์€ ํ”Œ๋žซํผ์—์„œ๋Š” ์‚ฌ์šฉ์ž ๊ฐ„์˜ ์†Œํ†ต๊ณผ ๊ฑฐ๋ž˜๋ฅผ ์ด‰์ง„ํ•˜๋Š” ํ•ต์‹ฌ ์š”์†Œ๊ฐ€ ๋  ์ˆ˜ ์žˆ์ง€.

ํ•ต์‹ฌ ์š”์•ฝ

  1. ํ‘ธ์‹œ ์•Œ๋ฆผ์€ ์•ฑ ์ฐธ์—ฌ๋„์™€ ์‚ฌ์šฉ์ž ์œ ์ง€์œจ์„ ๋†’์ด๋Š” ํšจ๊ณผ์ ์ธ ๋„๊ตฌ
  2. Firebase Cloud Messaging(FCM)์„ ํ†ตํ•ด iOS์™€ Android ๋ชจ๋‘ ์ง€์› ๊ฐ€๋Šฅ
  3. react-native-push-notification ๋˜๋Š” @react-native-firebase/messaging ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋กœ ๊ตฌํ˜„ ๊ฐ€๋Šฅ
  4. ๊ฐœ์ธํ™”๋œ ์ฝ˜ํ…์ธ ์™€ ์ ์ ˆํ•œ ํƒ€์ด๋ฐ์ด ํ‘ธ์‹œ ์•Œ๋ฆผ์˜ ์„ฑ๊ณต ์—ด์‡ 
  5. ์‚ฌ์šฉ์ž์—๊ฒŒ ์•Œ๋ฆผ ์„ค์ • ์ œ์–ด๊ถŒ์„ ์ œ๊ณตํ•˜๋Š” ๊ฒƒ์ด ์ค‘์š”
  6. ์ฒด๊ณ„์ ์ธ ํ…Œ์ŠคํŠธ์™€ ๋””๋ฒ„๊น…์œผ๋กœ ๋ชจ๋“  ์‚ฌ์šฉ์ž์—๊ฒŒ ์•Œ๋ฆผ์ด ์ œ๋Œ€๋กœ ์ „๋‹ฌ๋˜๋„๋ก ํ•ด์•ผ ํ•จ

ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ๊ตฌํ˜„ํ•  ๋•Œ๋Š” ๊ธฐ์ˆ ์ ์ธ ์ธก๋ฉด๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ์‚ฌ์šฉ์ž ๊ฒฝํ—˜๊ณผ ๋น„์ฆˆ๋‹ˆ์Šค ๋ชฉํ‘œ๋„ ํ•จ๊ป˜ ๊ณ ๋ คํ•ด์•ผ ํ•ด. ๋„ˆ๋ฌด ๋งŽ์€ ์•Œ๋ฆผ์€ ์‚ฌ์šฉ์ž๋ฅผ ์งœ์ฆ๋‚˜๊ฒŒ ๋งŒ๋“ค ์ˆ˜ ์žˆ์ง€๋งŒ, ์ ์ ˆํ•œ ์ˆœ๊ฐ„์— ๊ฐ€์น˜ ์žˆ๋Š” ์ •๋ณด๋ฅผ ์ „๋‹ฌํ•˜๋Š” ์•Œ๋ฆผ์€ ์‚ฌ์šฉ์ž ์ถฉ์„ฑ๋„๋ฅผ ๋†’์ด๊ณ  ์•ฑ์˜ ์„ฑ๊ณต์— ๊ธฐ์—ฌํ•  ์ˆ˜ ์žˆ์–ด.

์žฌ๋Šฅ๋„ท์—์„œ๋Š” ์ƒˆ๋กœ์šด ๋ฉ”์‹œ์ง€ ์•Œ๋ฆผ, ๊ฑฐ๋ž˜ ์ƒํƒœ ์—…๋ฐ์ดํŠธ, ๋งž์ถคํ˜• ์žฌ๋Šฅ ์ถ”์ฒœ ๋“ฑ ๋‹ค์–‘ํ•œ ๋ฐฉ์‹์œผ๋กœ ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ํ™œ์šฉํ•  ์ˆ˜ ์žˆ์„ ๊ฑฐ์•ผ. ์ด๋ฅผ ํ†ตํ•ด ์‚ฌ์šฉ์ž๋“ค์ด ํ”Œ๋žซํผ์— ๋” ์ž์ฃผ ๋ฐฉ๋ฌธํ•˜๊ณ , ๋” ๋งŽ์€ ๊ฑฐ๋ž˜๊ฐ€ ์ด๋ฃจ์–ด์ง€๋„๋ก ์œ ๋„ํ•  ์ˆ˜ ์žˆ์–ด.

๋งˆ์ง€๋ง‰์œผ๋กœ, ํ‘ธ์‹œ ์•Œ๋ฆผ ๊ตฌํ˜„์€ ํ•œ ๋ฒˆ์— ๋๋‚˜๋Š” ์ž‘์—…์ด ์•„๋‹ˆ๋ผ ์ง€์†์ ์ธ ๊ฐœ์„ ๊ณผ ์ตœ์ ํ™”๊ฐ€ ํ•„์š”ํ•œ ๊ณผ์ •์ด๋ผ๋Š” ์ ์„ ๊ธฐ์–ตํ•˜์ž. ์‚ฌ์šฉ์ž ํ”ผ๋“œ๋ฐฑ์„ ์ˆ˜์ง‘ํ•˜๊ณ , ์•Œ๋ฆผ ์„ฑ๊ณผ๋ฅผ ์ธก์ •ํ•˜๋ฉฐ, ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ๊ณผ ํ”Œ๋žซํผ ๋ณ€ํ™”์— ๋งž์ถฐ ๊ณ„์† ๋ฐœ์ „์‹œ์ผœ ๋‚˜๊ฐ€๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•ด.

์ด ๊ธ€์ด React Native์—์„œ ํ‘ธ์‹œ ์•Œ๋ฆผ์„ ๊ตฌํ˜„ํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋˜์—ˆ๊ธธ ๋ฐ”๋ผ! ๋” ๋งŽ์€ ๊ฐœ๋ฐœ ์ •๋ณด์™€ ํŒ์€ ์žฌ๋Šฅ๋„ท์˜ ์ง€์‹์ธ์˜ ์ˆฒ์—์„œ ์ฐพ์•„๋ณผ ์ˆ˜ ์žˆ์–ด. ํ•จ๊ป˜ ๋” ๋‚˜์€ ์•ฑ์„ ๋งŒ๋“ค์–ด ๋‚˜๊ฐ€์ž! ๐ŸŒŸ

๋Œ“๊ธ€ ์ž‘์„ฑ

์ด ๊ธ€์— ๋Œ€ํ•œ ์—ฌ๋Ÿฌ๋ถ„์˜ ์ƒ๊ฐ์„ ๋“ค๋ ค์ฃผ์„ธ์š”

๋Œ“๊ธ€ 0
๋Œ“๊ธ€์„ ๋ถˆ๋Ÿฌ์˜ค๋Š” ์ค‘์ž…๋‹ˆ๋‹ค.

์•„์ง ๋Œ“๊ธ€์ด ์—†์Šต๋‹ˆ๋‹ค.