-
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.
Merge pull request #116 from IoTeaTime/feature/115-fcm-token-refresh
feat: FCM 토큰 저장 구현
- Loading branch information
Showing
7 changed files
with
55 additions
and
19 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
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
19 changes: 12 additions & 7 deletions
19
src/main/java/org/ioteatime/meonghanyangserver/fcm/service/FcmService.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 |
---|---|---|
@@ -1,22 +1,27 @@ | ||
package org.ioteatime.meonghanyangserver.fcm.service; | ||
|
||
import jakarta.transaction.Transactional; | ||
import org.ioteatime.meonghanyangserver.clients.google.FcmClient; | ||
import org.ioteatime.meonghanyangserver.common.exception.NotFoundException; | ||
import org.ioteatime.meonghanyangserver.common.type.AuthErrorType; | ||
import org.ioteatime.meonghanyangserver.member.repository.MemberRepository; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class FcmService { | ||
private final FcmClient fcmClient; | ||
private final MemberRepository memberRepository; | ||
|
||
public FcmService(FcmClient fcmClient) { | ||
public FcmService(FcmClient fcmClient, MemberRepository memberRepository) { | ||
this.fcmClient = fcmClient; | ||
this.memberRepository = memberRepository; | ||
fcmClient.init(); | ||
} | ||
|
||
public void saveToken(String token) { | ||
// TODO. 토큰을 DB에 저장하기 | ||
// TODO. 로그인 계정 정보 불러오는 방식으로 구현하기 | ||
// 현재는 테스트를 위해 token이 자동으로 hello Topic을 구독하고, 곧바로 hello Topic에 메시지를 보냄 | ||
fcmClient.subTopic(token, "hello"); | ||
fcmClient.sendPush("test-message", "test-content", "hello"); | ||
@Transactional | ||
public void saveToken(Long memberId, String token) { | ||
memberRepository | ||
.updateFcmTokenById(memberId, token) | ||
.orElseThrow(() -> new NotFoundException(AuthErrorType.NOT_FOUND)); | ||
} | ||
} |
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
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