출처는 파베 공식문서지만 핵심 요지를 정리해보면,
a.
메세지 유형은 2가지
1) notification 메세지
2) data 메세지
백그라운드 상황에서 fcm sdk가 알림표시를 자동으로 처리하게 하려면 1)
자체 클라이언트 앱 코드로 메세지를 처리하려면 2)
fcm은 선택사항인 데이터 payload를 포함하는 알림 메세지를 보낼 수 있는데,
알림 payload 표시는 fcm에서 처리하고 데이터 payload는 클라이언트 앱에서 처리
b.
플랫폼에 관계없이 모든 앱 인스턴스가 다음 공통 필드를 해석할
message.notification.title
message.notification.body
message.data
c.(중요)
firebase block notification in foreground -> use local notification.
When your application is in the background or terminated, FCM automatically displays the notification messages. If your application is in the foreground, it receives a message object but the system does not automatically display the notification.
chatgpt와 나눈 대화는 fcm 메세지 작동원리를 foreground, background, termination 모두와 ios android를 잘 구분해서 보여준다.
원칙적으로 background, termination 상태에서는 flutter local notification을 쓸 필요는 없으나, request permission을 위해서라도 fln을 사용한다. 물론 다른 방법으로 물어볼수도 있다.
d.
On iOS, if the user swipes away the application from app Switcher, it must be manually reopened again for background messages to start working again.
On Android, if the user force quits the app from device settings, it must be manually reopened again for messages to start working.
e.
On iOS, macOS & web, before FCM payloads can be received on your device, you must first ask the user's permission. Android applications are not required to request permission.
f.
The stream contains a RemoteMessage, detailing various information about the payload, such as where it was from, the unique ID, sent time, whether it contained a notification & more.
e.
Notifications
If your message is a notification one (includes a notification property), the Firebase SDKs will intercept this and display a visible notification to your users (assuming you have requested permission & the user has notifications enabled). Once displayed, the background handler will be executed (if provided).
To learn about how to handle user interaction with a notification, view the Notifications documentation.
f.
The default behavior on all platforms is to display a notification only when the app is in the background or terminated.