특정 사용자 집합에 똑같은 알림을 보낼 때는 Topic을 사용해줄 수 있음
FCM 알림을 비동기 방식으로 구현해야 함
구현 순서
특정 기기에만 전송
// This registration token comes from the client FCM SDKs.
String registrationToken = "YOUR_REGISTRATION_TOKEN";
// See documentation on defining a message payload.
Message message = Message.builder()
.setNotification(Notification.builder()
.setTitle("title")
.setBody("body")
.build())
.putData("score", "850")
.putData("time", "2:45")
.setToken(registrationToken)
.build();
// Send a message to the device corresponding to the provided
// registration token.
String response = FirebaseMessaging.getInstance().send(message);
// Response is a message ID string.
System.out.println("Successfully sent message: " + response);