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: 온보딩 이후 권한여부 묻기 및 다음으로 이동 정상작동 #247

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions 14th-team5-iOS/App/Sources/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ extension AppDelegate {
Messaging.messaging().isAutoInitEnabled = true
UNUserNotificationCenter.current().delegate = self

let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: { _,_ in }
)

application.registerForRemoteNotifications()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public final class OnBoardingReactor: Reactor {
}

public enum Mutation {
case setPermissionStatus(Bool)
case permissionTapped
}

public struct State {
var isPermissionGranted: Bool = false
var permissionTappedFinish: Bool = false
}

init(accountRepository: AccountRepository) {
Expand All @@ -40,14 +40,13 @@ extension OnBoardingReactor {
switch action {
case .permissionTapped:
return Observable.create { observer in
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound]) {
if let error = $1 {
observer.onError(error)
} else {
observer.onNext(.setPermissionStatus($0))
UNUserNotificationCenter.current().requestAuthorization(
options: [.alert, .badge, .sound],
completionHandler: { granted, error in
observer.onNext(Mutation.permissionTapped)
observer.onCompleted()
}
}
)
return Disposables.create()
}
}
Expand All @@ -56,8 +55,8 @@ extension OnBoardingReactor {
public func reduce(state: State, mutation: Mutation) -> State {
var newState = state
switch mutation {
case .setPermissionStatus(let isPermissionGranted):
newState.isPermissionGranted = isPermissionGranted
case .permissionTapped:
newState.permissionTappedFinish = true
}
return newState
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ final public class OnBoardingViewController: BaseViewController<OnBoardingReacto
.bind(to: reactor.action)
.disposed(by: disposeBag)

reactor.state.map { $0.isPermissionGranted }
reactor.state.map { $0.permissionTappedFinish }
.distinctUntilChanged()
.observe(on: Schedulers.main)
.withUnretained(self)
Expand Down