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

fix: fcm 분기처리 수정 #115

Merged
merged 3 commits into from
Sep 8, 2024
Merged

fix: fcm 분기처리 수정 #115

merged 3 commits into from
Sep 8, 2024

Conversation

stealmh
Copy link
Member

@stealmh stealmh commented Sep 8, 2024

#️⃣연관된 이슈

#111

📝작업 내용

�푸시알람을 통해 앱을 진입하는 경우의 분기처리를 추가했습니다.

  • 앱을 사용중일 때 푸시알람이 오는경우
  • 앱을 미사용중일 때 푸시알람이 오는경우

분기처리는 MainTabFeature에서 담당하게 됩니다.

@Shared(.inMemory("PushTapped")) var isPushTapped: Bool = false

TCA의 Shared를 통해 이를 쉽게 관리 할 수 있습니다. 해당 프로퍼티는 총 2가지의 파일에서 추적합니다.
:: AppDelegateFeature, MainTabFeature

case let .userNotifications(.didReceiveResponse(_, completionHandler)):
    state.isPushTapped = true
    return .run { @MainActor _ in completionHandler() }

푸시를 누르면 isPushTapped의 값을 true로 바꿉니다.
Shared의 option을 inMemory로 설정했기 때문에 앱이 실행되는 순간에만 값이 남아있습니다.
당연하게도 PushTapped라는 키값을 두 가지 파일에서 같이 사용하고 있기 때문에 flag가 바뀐 것을 MainTabFeature도 알아차릴 수 있습니다.

case .onAppear:
    if state.isPushTapped {
        return .send(.pushAlertTapped(true))
    }
    return .merge(
        .run { send in
            // ...
        },
        .publisher {
            state.$isPushTapped.publisher
                .map(Action.pushAlertTapped)
        }
    )

publisher를 통해 바뀐 값을 감지할 수 있습니다. 하지만 이는 앱 실행중에 알아차릴 수 있는 것 뿐이고, 푸시를 통해 앱을 실행하는 경우에는 알아차릴 수 없습니다. 따라서 상단 if문을 추가해 AppDelegateFeature로부터 바뀐 값을 통해 알림함으로 이동되게 만들었습니다.

case .delegate(.알림함이동):
    state.isPushTapped = false
    state.path.append(.알림함(PokitAlertBoxFeature.State()))
return .none

이후 알림함으로 이동 될 때 flag를 꺼주시면 됩니다.

스크린샷 (선택)

앱 사용중일 때 앱 실행할 때
앱 사용중일 때 앱 실행할 때

💬리뷰 요구사항(선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요?

@stealmh stealmh added the Bug 🔫 현재 발견된 버그를 수정하기 위함 label Sep 8, 2024
@stealmh stealmh self-assigned this Sep 8, 2024
@stealmh stealmh changed the title [fix] #83 fcm 분기처리 수정 fix: fcm 분기처리 수정 Sep 8, 2024
Copy link
Contributor

@ShapeKim98 ShapeKim98 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다!
자꾸 조용히 알림 받기로만 설정되서 알아본 결과, requestAuthorization() 실행 옵션이 provisional로만 실행된다는 것을 발견하였고, 해당 부분을 [.alert, .sound]로 바꿨더니 알림 허용 알림창이 뜨는 모습과 함께, 배너와 사운드가 잘 되는 모습을 볼 수 있었습니다.(어플 삭제 후 재설치 해야함)
이것만 잘 고쳐주시면 될 것 같습니다!!
스크린샷 2024-09-08 16 56 31

await send(.inner(.linkCopySuccess(url)), animation: .pokitSpring)
}
},
.publisher {
Copy link
Contributor

Choose a reason for hiding this comment

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

publisher가 있었군요, 뭔가 앞으로도 유용할것 같네여

Copy link
Member Author

@stealmh stealmh left a comment

Choose a reason for hiding this comment

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

수정했습니다

@ShapeKim98
Copy link
Contributor

수정했습니다

수고하셨습니다!! 1.0.0이라 테플에 안올라가는거 같아서 1.0.1로 바꾸고 머지 하겠습니닷!

@ShapeKim98 ShapeKim98 merged commit 82a8b2e into develop Sep 8, 2024
1 check passed
@stealmh stealmh deleted the fix/#111-fcm branch September 9, 2024 01:06
@stealmh stealmh linked an issue Oct 29, 2024 that may be closed by this pull request
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🔫 현재 발견된 버그를 수정하기 위함
Projects
None yet
Development

Successfully merging this pull request may close these issues.

정식 출시 전 발견한 버그
2 participants