Skip to content
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 : 최초 어플 실행 작업 및 토큰 등록 #217

Merged
merged 21 commits into from
Apr 1, 2024

Conversation

huiwoo-jo
Copy link
Contributor

@huiwoo-jo huiwoo-jo commented Mar 30, 2024

📮 관련 이슈

✍️ 구현 내용

  • 화면 최초 실행 완료 부분을 firstLaunch부를 onboardingKeyword에서 MainActivity로 수정하였습니다.
  • onboardingPermission의 패키지 위치를 permssion에서 setting으로 변경하였습니다.
    해당 페이지가 settingViewmodel을 공유하여 패키지 이동을 결정하였습니다.
  • 온보딩 매과정에서 확인하던 firstLaunch를 제거하였습니다.
  • onboardingPermission의 알림 권한 승인의 버전 확인을 수정하였습니다.
  • MainActivity에 최초 접근 시 토큰, 학과, 키워드(토픽)을 등록하는 api를 연결하였습니다.
  • KeywordList의 영문명 및 순서를 수정하였습니다.

📷 구현 영상

  • 구현 영상을 업로드 해주세요.

✔️ 확인 사항

  • 컨벤션에 맞는 PR 타이틀
  • 관련 이슈 연결
  • PR 관련 정보 연결 (작업자, 라벨, 마일스톤 등)
  • Github Action 통과

Copy link
Collaborator

@m6z1 m6z1 left a comment

Choose a reason for hiding this comment

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

코멘트 확인 부탁드려용 고생많으ㅅ셨습니당

@@ -55,12 +53,14 @@ class OnboardingDepartActivity : BaseActivity<ActivityOnboardingDepartBinding, D
}

binding.etOnboardingDepartSearch.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(charSequence: CharSequence?, i: Int, i1: Int, i2: Int) = Unit
override fun beforeTextChanged(charSequence: CharSequence?, i: Int, i1: Int, i2: Int) =
Unit
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unit 에 줄바꿈을 한 이유는 ?.?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

자동 정렬이 자꾸 Unit을 줄바꿈을 하더라구요🥲
자동 정렬 후 수정하는데 확인을 못하고 올렸나봅니다

Comment on lines 45 to 54
private fun getFcmToken() {
FirebaseMessaging.getInstance().token.addOnCompleteListener(OnCompleteListener { task ->
if (!task.isSuccessful) {
return@OnCompleteListener
}
override fun initDataBinding() = Unit

val token = task.result
Timber.d(token)
//TODO: prefs 선언 중복 제거될 경우 주석 제거
//prefs.edit().putString("fcm_token", token).commit()
})
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

요 코드 필요한데 왜 지우신 거져 ?! 제 피알에 있어서 지우신건가욤

Copy link
Contributor Author

Choose a reason for hiding this comment

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

viewModelissuedToken으로 들어갔습니담

}
}

fun issuedToken() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

issuedToken 네이밍이 애매한 것 같아요! 그리고 이 로직은 MainActivity에 있었는데, 제 피알 보시면 메인 액티비티에서 sharedPreferences에 저장하고 있어서 이 로직은 추가하지 않고 레포지토리에서 prefs 가져오는 메서드로 fcmtoken을 받아오는 게 맞을 것 같습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

MainActivity로 다시 바꾼 뒤에 코드를 수정해보도록 하겠습니다

Comment on lines 56 to 61
val department = mainRepository.getUserDepartment()
_myDepartment.postValue(department)

viewModelScope.launch {
val keyword = mainRepository.getUserTopic()
_myTopics.value = keyword
Copy link
Collaborator

Choose a reason for hiding this comment

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

한 메서드에 여러 가지 내용이 담겨있는 것 같아요, department 를 가져오는 로직과, keyword 를 가져오는 로직은 분리 하는 게 어떨까요 ??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

분리된 상태로 진행을 하니 department, keyword, token 동작하지 않고 중도 종료 되어서 이렇게 수정하였습니다
로직을 다 확인하지 못하여 통신이 되지 않아 어쩔 수 없이 하나의 로직에 넣었습니다
제 생각에는 viewModeScope.launch가 동시에 불려오면서 제대로 적용되지 않는거 같습니다

Copy link
Contributor Author

Choose a reason for hiding this comment

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

postValue 설정을 잘못해서 발생한 이슈였습니다 😢

Comment on lines 57 to 61
_myDepartment.postValue(department)

viewModelScope.launch {
val keyword = mainRepository.getUserTopic()
_myTopics.value = keyword
Copy link
Collaborator

Choose a reason for hiding this comment

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

그리고 _myDepartment.postValue(department)_myDeparment.value = department 는 어떤 차이가 있는 것인지도 궁금해요! 섞어서 쓰셨길래 이유가 있는지 여쭙고 싶습니당

Copy link
Contributor Author

@huiwoo-jo huiwoo-jo Mar 31, 2024

Choose a reason for hiding this comment

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

postValue는 백그라운드 처리입니다! 데이터가 즉시 반영되어야하는 경우 _isFirstLauch일 경우에는 _isFirstLauch = true를 사용하였고 _isLoading같이 데이터가 처리되는 것을 기다리지 않아도 될 경우에는 postValue로 처리하였습니다

Copy link
Contributor Author

Choose a reason for hiding this comment

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

전에 관련된 리뷰를 통해서 공부했던 내용인데.. 제가 잘못 알고 있는 부분이 있을 수 있습니다
관련 코멘트를 남겨놓을테니 참고 부탁드려요! #158 (comment)

Copy link
Collaborator

Choose a reason for hiding this comment

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

그렇다면 department는 데이터가 즉시 반영되지 않아도 되는 것일까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

_myDepartment.value가 백에드에서 처리되면 initToken을 반영하기 전에 데이터가 올라가지 않을 수 있습니다!
그래서 _myDepartment.value = department로 학과가 온전히 저장되어야 하기 때문에 postValue가 아닌 =을 사용하여야합니다!

Copy link
Collaborator

Choose a reason for hiding this comment

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

넹 그런데 코드에선 postValue로 department를 업데이트하길래 물어봤어염
스크린샷 2024-04-01 오후 4 39 56

Copy link
Contributor Author

Choose a reason for hiding this comment

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

오잉 아래 코드처럼 함수 분리까지 적용하여 수정 후 푸쉬까지 했는데 여기서 적용이 안된걸로 보이네요...? github에 적용된걸 확인 후 머지하겠습니다!

    fun setFCMToken(token: String){
        mainRepository.setFCMToken(token)
        _FCMToken.postValue(token)
    }

    private fun getUserDepart(){
        _myDepartment.value = mainRepository.getUserDepartment()
    }

    private fun getUserTopic(){
        viewModelScope.launch {
            _myTopics.value = mainRepository.getUserTopic()
        }
    }

    fun setInitToken() {
        _isLoading.postValue(true)

        viewModelScope.launch {
            when (val result = mainRepository.setUserToken(Token(
                token = FCMToken.value.toString(),
                department = myDepartment.value ?: "",
                topics = myTopics.value ?: emptyList()
            )
            )) {
                is NetworkResult.Success -> {
                    mainRepository.setIsFirstLaunch(false)
                    _isFirstLaunch.postValue(false)
                    _isLoading.postValue(false)
                    _isError.postValue(false)
                }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

리베이스하니 잘 뜨네요!
확인 부탁드려용

@@ -26,6 +26,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() {
override val viewModel: SplashViewModel by viewModel()

private var intentJob: Job? = null
private lateinit var intent: Intent
Copy link
Collaborator

Choose a reason for hiding this comment

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

intent 를 지연초기화로 두신 이유가 있나용 ?
밑에서 val intent = 로 다시 변수를 만드는 것 같아요

Copy link
Contributor Author

Choose a reason for hiding this comment

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

intent 값을 지정하니 아래 코멘트와 같은 문제가 발생하였습니다

} else {
MainActivity.createIntent(this@SplashActivity)
}
intent = OnboardingDepartActivity.createIntent(this@SplashActivity)
Copy link
Collaborator

Choose a reason for hiding this comment

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

아 중복되는 intent라서 그런 것 같네요, 그렇다면 혹시

private val intent = OnboardingDepartActivity.createIntent(this@SplashActivity)

으로 선언해두고 startActivity(intent)로 사용하는 건 어떤지도 궁금해여

Copy link
Contributor Author

Choose a reason for hiding this comment

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

이렇게 진행했었는데 최초 실행 이후에 어플을 실행하면 외인지 어플 실행이 안된더라구요..
다른 코드가 문제였을 수 있으니 다시 수정해서 한 번 확인해보도록 하겠습니다

@huiwoo-jo huiwoo-jo self-assigned this Mar 31, 2024
@huiwoo-jo huiwoo-jo added 🤗 FEATURE Develop this project 🩵희우 labels Mar 31, 2024
@huiwoo-jo huiwoo-jo requested a review from m6z1 March 31, 2024 16:34
Copy link
Collaborator

@m6z1 m6z1 left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -47,7 +47,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() {
if (viewModel.isFirstLaunch.value == true) {
permissionCheck()
} else {
val intent = MainActivity.createIntent(this@SplashActivity)
intent = MainActivity.createIntent(this@SplashActivity)
Copy link
Collaborator

Choose a reason for hiding this comment

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

오 요 부분 성공했나요 ? 저도 몰라서 질문한 거였는데

Copy link
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 57 to 61
_myDepartment.postValue(department)

viewModelScope.launch {
val keyword = mainRepository.getUserTopic()
_myTopics.value = keyword
Copy link
Collaborator

Choose a reason for hiding this comment

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

그렇다면 department는 데이터가 즉시 반영되지 않아도 되는 것일까요?

@huiwoo-jo huiwoo-jo merged commit 927abd6 into develop Apr 1, 2024
1 check passed
@huiwoo-jo huiwoo-jo deleted the feature/init-token branch April 1, 2024 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤗 FEATURE Develop this project 🩵희우
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fcm 최초 token 등록 api 연결
2 participants