Firebase 알림 onMessageReceived는 앱이 백그라운드에있을 때와 동일한 알림을 표시합니다.

콘솔에서 내 앱으로 메시지를 보내고 있으며 앱이 백그라운드에있을 때 원하는대로 반응하도록 관리했습니다. 따라서 기본적으로 SDK에 표시되는 알림이 있으며 사용자가이를 탭하고 앱이 시작되면 대화 메시지를 작성하는 데 사용할 사용자 지정 데이터 필드가 있습니다.

또한 포 그라운드에서 앱이 반응하기를 원하기 때문에 서비스를 추가 했으며 SDK에서 앱이 백그라운드에있을 때 알림을 표시하는 데 사용한다고 가정 하는 반환 메서드 RemoteMessage도 포함되어 있음을 알았습니다 .getNotification()RemoteMessage.Notification

앱이 백그라운드에있을 때처럼 검색된 알림을 사용하고 표시하는 쉬운 방법이 있습니까?

프랭크 반 푸 펠렌

확실히 있습니다. FirebaseMessagingService.onMessageReceivedFirebase 클라우드 메시징 문서에서이 예와 같이 알림 본문을 재정의 하고 가져옵니다.

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    // TODO(developer): Handle FCM messages here.
    // If the application is in the foreground handle both data and notification messages here.
    // Also if you intend on generating your own notifications as a result of a received FCM
    // message, here is where that should be initiated. See sendNotification method below.
    Log.d(TAG, "From: " + remoteMessage.getFrom());
    Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody());
}

Android 에서 다운 스트림 메시지수신 하려면 'Override onMessageReceived' 에서 Firebase 클라우드 메시징 문서를 참조하세요 .

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관