-
Notifications
You must be signed in to change notification settings - Fork 0
fix : fcm token refetch #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a 400 response error during sign-in by implementing proper FCM token refetch logic. The issue occurred when the cached FCM token was blank or invalid, causing the sign-in API call to fail.
Key Changes
- Added automatic FCM token retrieval with fallback to Firebase if the cached token is blank
- Implemented early return logic to abort sign-in when FCM token is unavailable
- Added proper coroutine-based Firebase token fetching with cancellation support
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private suspend fun fetchFcmToken(): String = suspendCancellableCoroutine { cont -> | ||
| FirebaseMessaging.getInstance().token | ||
| .addOnCompleteListener { task -> | ||
| if (!cont.isActive) return@addOnCompleteListener | ||
| if (task.isSuccessful) { | ||
| cont.resume(task.result.orEmpty()) | ||
| } else { | ||
| cont.resumeWithException( | ||
| task.exception ?: IllegalStateException("FCM token fetch failed") | ||
| ) | ||
| } | ||
| } | ||
| } |
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The addOnCompleteListener callback may execute on the main thread, but there's no guarantee which thread it will run on. This could cause the coroutine continuation to resume on an unexpected thread. Consider using addOnCompleteListener with an explicit executor or adding .addOnCompleteListener(Dispatchers.Main.asExecutor()) to ensure consistent threading behavior, or alternatively use Tasks.await() from the kotlinx-coroutines-play-services library which handles this more idiomatically.
* feat: 로그인 api 연동(진짜최종) * feat - 푸시알림 등록 (#54) * feat: fcm 토큰 발급 * feat: 로그인 필드에 fcmtoken 추가 * feat: FCM 알림 기능 추가 및 기본 채널 설정 * feat: MainScreen에서 알림 권한 요청 기능 추가 * feat: 버전 업데이트 (1.0.1) * feat - 회원가입, 필수정보입력 필드 업데이트 (#57) * feat: 필수정보입력 실명 필드 추가 * feat: 회원가입 이름 필드 제거 * feat: 버전 업데이트 (1.0.2) * feat: ADID 추가 * feat: FCM 토큰 가져오기 및 저장 로직 추가 (#59) * feat: 구글로그인 응답로그 추가 * feat: 구글로그인 status 필드 대응 * fix: 구글로그인 버튼 위치 변경 --------- Co-authored-by: BYEONGCHAN LEE <[email protected]>
작업내용