-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Type: FirebaseMessaging 오류 수정 (#104)
[Fix] FCM messaging - async 코드 수정 및 에러 처리 추가
- Loading branch information
Showing
4 changed files
with
67 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/igoMoney/BE/controller/FCMMessageController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package igoMoney.BE.controller; | ||
|
||
import com.google.firebase.messaging.Message; | ||
import com.google.firebase.messaging.Notification; | ||
import igoMoney.BE.service.FCMTokenService; | ||
import igoMoney.BE.service.UserService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
@RequestMapping("fcm") | ||
public class FCMMessageController { | ||
|
||
private final FCMTokenService fcmTokenService; | ||
private final UserService userService; | ||
|
||
@PostMapping("") | ||
public ResponseEntity<Void> sendPushAlarm(@RequestParam(value="fcmToken") String fcmToken, | ||
@RequestParam(value="title") String title, | ||
@RequestParam(value="content") String content){ | ||
|
||
Message message = Message.builder() | ||
.setNotification(Notification.builder() | ||
.setTitle(title) | ||
.setBody(content) | ||
.build()) | ||
.setToken(fcmToken) | ||
.build(); | ||
fcmTokenService.sendMessage(message); | ||
return new ResponseEntity(HttpStatus.OK); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters