-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: 서랍장 서비스 등록 페이지 네이티브 웹뷰 연결 #216
Conversation
@@ -40,6 +57,22 @@ export const Register = () => { | |||
} | |||
}; | |||
|
|||
useEffect(() => { | |||
const getAccessTokenFromNative = () => { |
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.
앞으로 해당 객체들을 사용할 때 마다 if문으로 undefined 체크를 해야 할 것 같습니다.
initialize 할 수 있는 기능을 추가해야 할 것 같은데 아래처럼 클래스 두고 인스턴스 생성해서 쓰는건 별로일까요?
class NativeAPI {
constructor(iosHandler, androidHandler, api) {
this.initialize(iosHandler, androidHandler);
}
initialize(iosHandler, androidHandler) {
if (!iosHandler || !androidHandler) {
throw new Error("No valid handler found for Native API.");
}
this.handler = iosHandler;
this.handler = androidHandler;
}
// awesome logics..
}
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.
어썸 로직이네요................................
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.
고민을 해봤는데 해당 코드는 웹뷰로 접속하는 페이지가 많을 때 유용할 것 같은데 숨쉴때는 서랍장 서비스 등록 페이지만 웹뷰로 접속하는 상황이라 현재 상황에서는 지금 코드를 유지해도 될 것 같아요
웹뷰로 접속하는 페이지가 많아지고 반복되는 로직을 제거해야할 필요성을 느낄 때 제안해주신 코드를 도입하면 좋지 않을까 싶네요..!
어썸 코드 감사합니다
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.
일단 어푸룹해두겠습니다!!
혹시 관련 코드 작성하실 때 참고하신 문서같은게 있으신가요?! 웹뷰 연결 처음 봐서.. 궁금해서 여쭤봅니당
window.Android랑 window.webkit 접근하실 때 엠제이 말처럼 실제로 존재하는지 여부를 확인하는 코드가 있으면 좋을 것 같아용
수고하셨습니다👍🏻👍🏻👍🏻
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.
쭌 혹시 여기서 mutate 끝나고 페이지 이동하는 코드 추가해줄 수 있나요 ㅠㅠ!?!
등록 성공해도 등록 페이지에 머물러 있어서 안된 것처럼 보여가지고용
웹뷰 연결이랑은 무관한데 등록이랑 관련 있는 내용이라 혹시 모바일 팀에서 이걸로 문의 들어올까봐 남깁니더~~...
(이 브랜치에 해놔야 모바일팀에 전달한 링크 (184번 브랜치 배포한) 에 바로 반영 될 거 같아서요!)
}; | ||
|
||
window.setAccessToken = (accessToken: string) => { | ||
api.setAccessToken(accessToken, Date.now() + 5 * 60 * 1000); |
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.
모바일 토큰의 브라우저 상 유효시간을 받아온 시각 + 5분
으로 설정한 거는 쭌이 임의로 정한건가요? 혹시 타자가 느려서 웹뷰 접속 후 5분 지나면........ 어쩌지 하는 걱정이 있어가지고
유효 시간은 넉넉하게 해두고 프로덕트 등록 mutate 완료 후에 토큰 삭제하는 건 별로일까요?!?
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.
넉넉히 10분..?
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.
네이티브 쪽에서 accessToken
만 받아오는거라 제가 임의로 5분으로 설정했는데 생각해보니 조금 짧은 감이 있네요..
1시간으로 넉넉히 잡아놓겠습니다 -> 96c3bde
유저가 서비스 등록 후에 바로 다른 서비스를 등록할 수 있으니 토큰은 살려두는게 나을 것 같아요..!
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.
천잰가
맞네요 서비스 등록 성공하면 페이지 이동시키는 코드 추가해놓겠습니다..! -> b5379a5 웹뷰에서는 서비스 등록 성공시 웹뷰 안에서 페이지 이동을 시키는게 어색할 것 같아서 다시 네이티브 쪽으로 성공 여부를 알려줘서 네이티브 쪽에서 처리하는게 자연스러울 것 같네요 -> 이 부분은 안드, ios 팀이랑 얘기해보겠습니다 |
저도 웹뷰 연결이 처음이라 지피티씨 도움 받아서 구현했습니다🤗 |
b5379a5
to
f941fef
Compare
7a174ae
to
8e5e87a
Compare
1️⃣ 어떤 작업을 했나요? (Summary)
기존 코드에 영향을 미치지 않는 변경사항
drawer/pages/Register.tsx
accessToken
을 받아오는 기능을 구현하였습니다.2️⃣ 알아두시면 좋아요!
Android 웹뷰에서 서랍장 서비스 등록 페이지에 접속
accessToken
을 가져와 웹뷰에 정의된 자바스크립트 함수인window.setAccessToken()
을 호출setAccessToken
함수는 네이티브로부터accessToken
을 받아api
싱글톤 객체에 등록 -> 추후 API 요청에 이용ios 웹뷰에서 서랍장 서비스 등록 페이지에 접속
accessToken
을 요청(window.webkit.messageHandlers.ios.postMessage("getAccessToken")
)accessToken
을 가져와 웹뷰에 정의된 자바스크립트 함수인window.setAccessToken()
을 호출setAccessToken
함수는 네이티브로부터accessToken
을 받아api
싱글톤 객체에 등록 -> 추후 API 요청에 이용3️⃣ 추후 작업
4️⃣ 체크리스트 (Checklist)
main
브랜치의 최신 코드를pull
받았나요?