Skip to content

fix: 안드로이드 소셜 로그인 실패 수정 (Firebase 연결 + Apple 버튼 미노출) - #328

Merged
iOdiO89 merged 7 commits into
devfrom
fix/327-android-login
Jul 15, 2026
Merged

fix: 안드로이드 소셜 로그인 실패 수정 (Firebase 연결 + Apple 버튼 미노출)#328
iOdiO89 merged 7 commits into
devfrom
fix/327-android-login

Conversation

@ychany

@ychany ychany commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

작업 요약

  • 안드로이드에서 소셜 로그인이 전부 실패하던 문제를 수정합니다 (Firebase Android 미설정 + SHA 지문 미등록 + Apple 버튼 노출)
  • google-services.json 을 EAS file 환경변수로 관리하고 빌드 시 자동 주입되도록 연결합니다
  • Apple 로그인 버튼을 안드로이드 웹뷰에서 미노출 처리합니다 (iOS 전용 네이티브 모듈)

작업 세부 내용

배경 — 원인 3가지

원인 증상
Firebase 에 Android 앱 미등록 + google-services.json 부재 FCM 푸시·Firebase Analytics 미동작
앱 서명 키 SHA-1 지문 미등록 → Android OAuth 클라이언트 없음 구글 로그인 DEVELOPER_ERROR 즉시 실패
Apple 버튼이 안드로이드에 노출 (iOS 전용 모듈인데 Platform 분기 없음) 선택 시 항상 에러

카카오는 개발자 콘솔에 Android 플랫폼(패키지명 + 키 해시) 등록으로 처리 — 담당자 진행 중.

1. Firebase / Google 콘솔 등록 (완료)

  • Firebase 에 Android 앱 (day.no30s.piki) 등록 + EAS 업로드 키 SHA-1/SHA-256 지문 등록
  • GCP 에 Android OAuth 클라이언트 생성 (패키지명 + SHA-1)
  • 발급된 google-services.json 검증 완료 — 패키지명 일치 / Android client (certificate_hash) 포함 / Web client 가 기존 EXPO_PUBLIC_GOOGLE_WEB_CLIENT_ID 와 일치

2. 빌드 연결 — EAS file 환경변수 방식

Google 설정 파일 2종은 gitignore 를 유지하고 (레포에 커밋 X), EAS file 환경변수로 관리합니다.

  • expo.dev 환경변수: GOOGLE_SERVICES_JSON, GOOGLE_SERVICE_INFO_PLIST (file 타입, production)
  • package.jsoneas-build-pre-install 훅이 빌드 시 파일을 프로젝트 경로로 복사
  • app.jsonandroid.googleServicesFile / ios.googleServicesFile 명시 참조
  • eas.json production 프로필에 "environment": "production" 명시 (env 변수 매칭 보장)
  • 로컬 빌드는 영향 없음 — env 변수 없으면 훅이 통과하고 로컬 파일 사용

3. Apple 로그인 안드로이드 미노출

  • login/page.tsx (RSC) 에서 User-Agent 로 Android 웹뷰 판별showAppleLogin prop 전달 (서버 판별이라 깜빡임/hydration mismatch 없음)
  • LoginButtons 는 Android 웹뷰에서만 Apple 버튼 미노출 — 일반 Android 브라우저는 웹 OAuth 라 정상 동작하므로 유지
  • 네이티브 useSocialLogin 에도 방어 가드 추가 — Android 에서 apple 요청이 와도 iOS 전용 모듈 호출 전에 안내 에러 반환

검증

  • google-services.json 구조 검증 (패키지명 / cert_hash ↔ EAS 업로드 키 SHA-1 일치)
  • expo prebuild -p android 로 gradle plugin + json 반영 확인
  • web check-types · lint, app tsc 통과
  • (QA) EAS 빌드 후 구글 로그인 성공
  • (QA) 카카오 콘솔 등록 후 카카오 로그인 성공
  • (QA) 안드로이드 웹뷰에서 Apple 버튼 미노출 (웹 배포 후)

참고

  • 앱 변경 포함이라 안드로이드 재빌드 + 재배포 필요 (eas build --platform android)
  • 웹 변경분 (Apple 버튼 숨김) 은 Vercel 배포만으로 기존 설치된 앱에도 즉시 적용
  • 추후 Play Store 프로덕션 전환으로 Play App Signing 키가 생기면, 그 SHA-1 을 Firebase/카카오에 추가 등록 필요

연관 이슈

closes #327

Summary by CodeRabbit

  • 새로운 기능

    • Android 웹뷰 환경에서는 Apple 로그인 버튼이 표시되지 않습니다.
    • 지원되지 않는 환경에서 Apple 로그인 시도 시 오류 안내 후 로그인 절차가 중단됩니다.
  • 버그 수정

    • 네이티브 로그인 성공·실패 메시지를 안정적으로 처리하고, 결과에 따라 적절한 화면으로 이동합니다.
    • 로그인 실패 시 오류 토스트가 표시됩니다.
    • 다양한 플랫폼에서 로그인 메시지 수신 및 정리가 정상적으로 동작합니다.

@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
depromeet Ready Ready Preview, Comment Jul 15, 2026 12:21am

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

Discord 스레드 연동용 메타데이터입니다. discord-pr-bot 워크플로가 자동 생성하며, 수정·삭제하면 PR 과 Discord 알림 연동이 끊깁니다.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 52902657-57b7-48b4-8199-860adb6195b5

📥 Commits

Reviewing files that changed from the base of the PR and between c7d363d and da26fdc.

📒 Files selected for processing (2)
  • apps/web/src/app/login/_components/LoginButtons.tsx
  • apps/web/src/hooks/useNativeLoginResult.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/src/app/login/_components/LoginButtons.tsx

📝 Walkthrough

Walkthrough

Apple 로그인의 비-iOS 방어 로직을 추가하고, Android 웹뷰에서 Apple 버튼을 숨기며, 네이티브 로그인 결과 메시지를 window와 document 양쪽에서 처리하도록 변경했습니다.

Changes

소셜 로그인 플랫폼 대응

Layer / File(s) Summary
Apple 로그인 플랫폼 가드
apps/app/hooks/useSocialLogin.ts
비-iOS에서 Apple 로그인 요청 시 SOCIAL_LOGIN_ERROR를 전송하고 인증 모듈 호출을 중단합니다.
Android 웹뷰 Apple 버튼 제어
apps/web/src/app/login/_components/LoginButtons.tsx, apps/web/src/app/login/page.tsx
Android 웹뷰의 user-agent를 판별해 showAppleLogin을 전달하고 Apple 버튼을 조건부 렌더링합니다.
네이티브 로그인 메시지 수신 처리
apps/web/src/hooks/useWebBridgeMessage.ts, apps/web/src/hooks/useNativeLoginResult.ts
message 이벤트를 window와 document에 등록하고, 공통 훅을 통해 로그인 성공·실패 결과를 처리합니다.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant LoginPage
  participant LoginButtons
  participant useSocialLogin
  participant WebBridge
  participant useNativeLoginResult

  LoginPage->>LoginButtons: showAppleLogin 전달
  LoginButtons->>useSocialLogin: 소셜 로그인 요청
  useSocialLogin->>WebBridge: 비-iOS Apple 오류 메시지 전송
  WebBridge->>useNativeLoginResult: 로그인 결과 메시지 전달
  useNativeLoginResult->>useNativeLoginResult: 성공 또는 실패 처리
Loading

Possibly related issues

  • 이슈 327: Android 웹뷰의 Apple 버튼 노출 및 비-iOS Apple 인증 호출 방어와 직접 연결됩니다.

Possibly related PRs

  • TeamPiKi/client#324: 동일한 LoginButtons.tsx에서 Apple 로그인 버튼 노출 및 처리 흐름을 수정합니다.

Suggested labels: fix

Suggested reviewers: soyeong0115

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning #327의 핵심인 Apple 로그인 차단은 반영됐지만 Firebase Android 설정, OAuth 클라이언트, Kakao Android 등록은 보이지 않습니다. google-services.json/app.json 및 EAS 설정, Android OAuth/FCM·Analytics 구성, Kakao Android 등록까지 PR에 포함하거나 별도 근거를 제시하세요.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목이 안드로이드 소셜 로그인 장애와 Apple 버튼 미노출 수정을 잘 요약하며, PR의 주요 변경과도 관련됩니다.
Out of Scope Changes check ✅ Passed 변경된 내용은 Android 소셜 로그인 오류 수정 범위에 맞고, 명백한 무관한 변경은 보이지 않습니다.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/327-android-login

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/app/eas.json`:
- Around line 14-17: The development and preview EAS profiles are missing the
environment setting, so they may not receive the required Firebase file
variables and can fail during preinstall/prebuild. Update the app EAS
configuration so the development and preview entries in eas.json explicitly set
the correct environment like the production profile, and make sure the
corresponding file variables are registered for those environments to match the
fallback logic in app.config.ts.

In `@apps/app/package.json`:
- Around line 12-13: The eas-build-pre-install script in package.json swallows
cp failures because both file-copy checks are chained with semicolons, so a
failing cp can still end with exit 0 if the later block succeeds. Update the
script so failures in either GOOGLE_SERVICES_JSON or GOOGLE_SERVICE_INFO_PLIST
copy path immediately fail the whole pre-install step, using the existing
eas-build-pre-install command and its cp/if logic to preserve a nonzero exit
status on any copy error.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: eab49d5c-6d62-485f-882b-c18cedf3ac94

📥 Commits

Reviewing files that changed from the base of the PR and between ef66bef and 1fda643.

📒 Files selected for processing (6)
  • apps/app/app.json
  • apps/app/eas.json
  • apps/app/hooks/useSocialLogin.ts
  • apps/app/package.json
  • apps/web/src/app/login/_components/LoginButtons.tsx
  • apps/web/src/app/login/page.tsx

Comment thread apps/app/eas.json
Comment thread apps/app/package.json Outdated
@ychany ychany changed the title ix: 안드로이드 소셜 로그인 실패 수정 (Firebase 연결 + Apple 버튼 미노출) fix: 안드로이드 소셜 로그인 실패 수정 (Firebase 연결 + Apple 버튼 미노출) Jul 9, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
apps/web/src/hooks/useWebBridgeMessage.ts (1)

47-54: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

window/document 리스너 등록 로직 중복 - 공유 유틸로 추출 권장.

두 훅이 "iOS는 window, Android는 document에 message 이벤트를 dispatch한다"는 동일한 근본 배경으로 거의 동일한 등록/해제/캐스팅 코드를 각각 구현하고 있습니다. 공유 훅(예: useMessageListener 또는 useWebBridgeTarget)으로 추출하면 향후 플랫폼별 dispatch 방식이 바뀔 때 한 곳만 수정하면 됩니다.

  • apps/web/src/hooks/useWebBridgeMessage.ts#L47-L54: window/document 리스너 등록·해제 및 EventListener 캐스팅 로직을 공유 헬퍼로 추출.
  • apps/web/src/hooks/useNativeLoginResult.ts#L45-L51: 동일한 공유 헬퍼를 재사용하도록 변경.
♻️ 공유 헬퍼 예시
// apps/web/src/hooks/useMessageListener.ts
export function useMessageListener(handler: (event: MessageEvent) => void, deps: unknown[]) {
  useEffect(() => {
    /** RN → 웹 메시지는 iOS 에선 window, Android 에선 document 에 dispatch 된다 (react-native-webview 동작) */
    window.addEventListener('message', handler);
    document.addEventListener('message', handler as EventListener);
    return () => {
      window.removeEventListener('message', handler);
      document.removeEventListener('message', handler as EventListener);
    };
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, deps);
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/src/hooks/useWebBridgeMessage.ts` around lines 47 - 54, Extract the
duplicated window/document message listener registration, cleanup, and
EventListener casting into a shared useMessageListener or equivalent helper.
Update apps/web/src/hooks/useWebBridgeMessage.ts lines 47-54 to use the helper,
and update apps/web/src/hooks/useNativeLoginResult.ts lines 45-51 to reuse it;
keep each hook’s existing handler and dependency behavior unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@apps/web/src/hooks/useWebBridgeMessage.ts`:
- Around line 47-54: Extract the duplicated window/document message listener
registration, cleanup, and EventListener casting into a shared
useMessageListener or equivalent helper. Update
apps/web/src/hooks/useWebBridgeMessage.ts lines 47-54 to use the helper, and
update apps/web/src/hooks/useNativeLoginResult.ts lines 45-51 to reuse it; keep
each hook’s existing handler and dependency behavior unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 56ec3593-3ea3-48cb-8098-18786d802973

📥 Commits

Reviewing files that changed from the base of the PR and between 1fda643 and c7d363d.

📒 Files selected for processing (2)
  • apps/web/src/hooks/useNativeLoginResult.ts
  • apps/web/src/hooks/useWebBridgeMessage.ts

@iOdiO89 iOdiO89 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

굿 코멘트 단 거 확인 한번 부탁해

Comment thread apps/app/eas.json Outdated
"production": {
"autoIncrement": true
"autoIncrement": true,
"environment": "production"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오잉 이게 필요한거야?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

디버깅 하다가 커밋에 따라 들어갔네 제거 완~

Comment thread apps/app/package.json Outdated
"web": "expo start --web",
"lint": "expo lint"
"lint": "expo lint",
"eas-build-pre-install": "if [ -n \"$GOOGLE_SERVICES_JSON\" ]; then cp \"$GOOGLE_SERVICES_JSON\" ./google-services.json; fi; if [ -n \"$GOOGLE_SERVICE_INFO_PLIST\" ]; then cp \"$GOOGLE_SERVICE_INFO_PLIST\" ./GoogleService-Info.plist; fi"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eas cloud에서 자동으로 주입될거라 스크립트 필요없다 ~!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인

Comment on lines +45 to +51
/** RN → 웹 메시지는 iOS 에선 window, Android 에선 document 에 dispatch 된다 (react-native-webview 동작) */
window.addEventListener('message', handler);
return () => window.removeEventListener('message', handler);
document.addEventListener('message', handler as EventListener);
return () => {
window.removeEventListener('message', handler);
document.removeEventListener('message', handler as EventListener);
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 여기는 따로 이벤트리스너를 붙이네??? 이거 useWebBridgeMessage 사용하는 쪽으로 통합하면 좋을듯

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 그러넹 반영 완료!

@iOdiO89
iOdiO89 merged commit 35c03a9 into dev Jul 15, 2026
6 checks passed
@iOdiO89
iOdiO89 deleted the fix/327-android-login branch July 15, 2026 00:21
iOdiO89 added a commit that referenced this pull request Jul 19, 2026
* ix: 안드로이드 소셜 로그인 실패 수정 (Firebase 연결 + Apple 버튼 미노출)

* fix: Android 웹뷰에서 RN 메시지 유실 수정 (document 리스너 추가)

* chore: eas.json 중복 environment 설정 제거

* chore: google services 파일 주입 중복 설정 제거 (app.config.ts 로 일원화)

* refactor: useNativeLoginResult 를 useWebBridgeMessage 로 통합

---------

Co-authored-by: Jung Sun A <amber0809@naver.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug/App] 안드로이드 소셜 로그인 실패 — Firebase Android 미설정 + Apple 버튼 노출

2 participants