<aside> 💡

</aside>

FCM 설정

다음 문서를 통해 FCM을 설정하세요. 기존에 이미 FCM을 사용하는 경우 다음 단계로 이동하세요. https://rnfirebase.io/messaging/usage

BuzzBooster Dashboard 연동

1. Firebase console의 프로젝트 설정으로 이동하세요.

Untitled

2. 클라우드 메시징으로 이동해 서비스 계정 관리를 클릭하세요.

image-20230801-023011.png

3. firebase로 시작하는 이메일을 클릭하세요.

image-20230801-023041.png

4. 키 - 키 추가 - 새 키 만들기를 클릭하세요.

Untitled

5. JSON 형식으로 만들기를 눌러, 파일을 다운로드 받아주세요.

Untitled

<aside> 🚨 한 번만 다운 받을 수 있으니, 안전히 보관해주세요.

</aside>

6. BuzzBooster 대시보드 - Integration - Push에서 업로드 해주세요.

Untitled

Untitled

React Native

BuzzBooster의 Push Notification을 처리하려면 다음과 같이 작업하세요.

1. 권한 요청

Push Notification을 수신하기 위해선 Android 13 이상과 iOS에서 유저의 권한이 필요합니다.

react-native-permissions 등의 라이브러리를 활용하여 각 플랫폼에 맞는 권한을 요청하세요.

2. Token 전송

import messaging from '@react-native-firebase/messaging';
import { BuzzBooster } from 'react-native-buzz-booster';

const token = await messaging().getToken();
BuzzBooster.setPushToken(token)

3. Push Notification 처리

import messaging from '@react-native-firebase/messaging';
import { BuzzBooster } from 'react-native-buzz-booster';

/**
 * 앱이 실행 중인 상태에서 Notification 처리
 */
messaging().onMessage(async remoteMessage => {
    const data = remoteMessage.data
    if (BuzzBooster.isBuzzBoosterNotification(data)) {
        BuzzBooster.handleForegroundNotification(data)
    }
});

/**
 * 앱이 종료된 상태에서 Notification 클릭으로 시작될 때 발생.
 */
messaging().getInitialNotification().then(async remoteMessage => {
    if (remoteMessage == null)
        return
    const data = remoteMessage.data
    if (BuzzBooster.isBuzzBoosterNotification(data)) {
        BuzzBooster.handleInitialNotification(data)
    }
})

/**
 * 앱이 Background인 상태에서 Notification 클릭으로 시작될 때 발생
 */
messaging().onNotificationOpenedApp(async remoteMessage => {
    console.log("onNotificationOpenedApp")
    const data = remoteMessage.data
    if (BuzzBooster.isBuzzBoosterNotification(data)) {
        BuzzBooster.onNotificationOpenedApp(data)
    }
})