인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

jmh33600468's profile image
jmh33600468

asked

Delivery App Clone Coding [with React Native]

Check if you receive a push message!

messaging().setBackgroundMessageHandler 핸들링 미적용

Written on

·

554

0

안녕하세요

강의 잘 듣고 있습니다. 현재 강의를 듣고 FCM을 구현하던 중 백그라운드 상태에서 push 알림을 핸들링 하고자하는데 어려움이 있어 질문 남겨요.

messaging().setBackgroundMessageHandler(async remoteMessage => {
    const channelId =
    Platform.OS === 'ios'
      ? remoteMessage.category
      : remoteMessage.notification?.android?.channelId;

    console.log('FCM Channel ID:', channelId);

    if (channelId === 'example-sample') {
        // 해당 채널 ID가 'example-sample'인 경우 Push 알림 노출하지 않고 종료합니다.
        return;
    }
  
  });

 

목표 ( 채널을 통한 알림 수신 거부 처리 )

  • 1. 앱서버에서 메시지 전송시 channel id값을 담아 발송.

  • 2. 앱이 background or quick 일때 특정 channel id시에는 push 알림 비 노출

해당 메소드를 정상적으로 타긴 하지만 이미 디바이스에서는 알림이 오고 있습니다.

 

백그라운드 또는 종료 상태일경우 FCM 메시지를 컨트롤 할 수 없는 것일까요?

 

 

react-nativefcm

Answer 1

0

zerocho님의 프로필 이미지
zerocho
Instructor

이게 notification 속성이 들어있는 경우에는 무조건 알림이 뜨게 되어있다고 해서 이 동작을 취소할 수 있는지는 좀 더 알아봐야 할 것 같습니다

jmh33600468's profile image
jmh33600468

asked

Ask a question