Skip to content

Commit

Permalink
Merge pull request #115 from YAPP-Github/fix/#111-fcm
Browse files Browse the repository at this point in the history
fix: fcm ๋ถ„๊ธฐ์ฒ˜๋ฆฌ ์ˆ˜์ •
  • Loading branch information
ShapeKim98 authored Sep 8, 2024
2 parents d278a0b + 15c092f commit 82a8b2e
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Projects/App/Resources/Pokit-info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<string>1.0.1</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand Down
7 changes: 3 additions & 4 deletions Projects/App/Sources/AppDelegate/AppDelegateFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public struct AppDelegateFeature {
@ObservableState
public struct State {
public var root = RootFeature.State()
@Shared(.inMemory("PushTapped")) var isPushTapped: Bool = false

public init() {}
}
Expand Down Expand Up @@ -58,12 +59,9 @@ public struct AppDelegateFeature {
group.addTask {
let setting = await self.userNotifications.getNotificationSettings()
switch setting.authorizationStatus {
case .authorized:
case .authorized, .notDetermined:
guard try await self.userNotifications.requestAuthorization([.alert, .sound])
else { return }
case .notDetermined, .provisional:
guard try await self.userNotifications.requestAuthorization(.provisional)
else { return }
default: return
}
await self.registerForRemoteNotifications()
Expand All @@ -80,6 +78,7 @@ public struct AppDelegateFeature {
return .run { _ in completionHandler(.banner) }

case let .userNotifications(.didReceiveResponse(_, completionHandler)):
state.isPushTapped = true
return .run { @MainActor _ in completionHandler() }
case .userNotifications:
return .none
Expand Down
3 changes: 0 additions & 3 deletions Projects/App/Sources/Intro/IntroFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ private extension IntroFeature {

case .delegate(.loginNeeded):
return .run { send in
/// ์•Œ๋žŒ์„ ํ†ตํ•ด ์•ฑ์„ ๋“ค์–ด์™”์œผ๋‚˜ ์ž๋™ ๋กœ๊ทธ์ธ์„ ์‹คํŒจํ–ˆ๋‹ค๋ฉด ๋ฐฐ๋„ˆ๋กœ ์ด๋™ํ•˜์ง€ ๋ชปํ•˜๊ฒŒ flag ์‚ญ์ œ
await userDefaults.removeBool(.fromBanner)
/// Todo: ์›ํ•˜๋Š” ์• ๋‹ˆ๋ฉ”์ด์…˜ ๋„ฃ์–ด์ค˜~
await send(._sceneChange(.login()), animation: .smooth)
}

Expand Down
57 changes: 34 additions & 23 deletions Projects/App/Sources/MainTab/MainTabFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,24 @@ public struct MainTabFeature {
var isLinkSheetPresented: Bool = false
var isErrorSheetPresented: Bool = false
var link: String?

var error: BaseError?

var path: StackState<MainTabPath.State> = .init()
var pokit: PokitRootFeature.State
var remind: RemindFeature.State = .init()
@Presents var contentDetail: ContentDetailFeature.State?
@Shared(.inMemory("SelectCategory")) var selectedPokit: BaseCategoryItem?

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

public init() {
self.pokit = .init()
}
}
/// - Action
public enum Action: FeatureAction, BindableAction, ViewAction {
case binding(BindingAction<State>)
case pushAlertTapped(Bool)
case view(View)
case inner(InnerAction)
case async(AsyncAction)
Expand Down Expand Up @@ -93,6 +95,12 @@ public struct MainTabFeature {
switch action {
case .binding:
return .none
case let .pushAlertTapped(isTapped):
if isTapped {
return .send(.delegate(.์•Œ๋ฆผํ•จ์ด๋™))
} else {
return .none
}
/// - View
case .view(let viewAction):
return handleViewAction(viewAction, state: &state)
Expand All @@ -108,7 +116,7 @@ public struct MainTabFeature {
/// - Delegate
case .delegate(let delegateAction):
return handleDelegateAction(delegateAction, state: &state)

case .path:
return .none
case .pokit:
Expand All @@ -123,7 +131,7 @@ public struct MainTabFeature {
public var body: some ReducerOf<Self> {
Scope(state: \.pokit, action: \.pokit) { PokitRootFeature() }
Scope(state: \.remind, action: \.remind) { RemindFeature() }

BindingReducer()
navigationReducer
Reduce(self.core)
Expand All @@ -140,42 +148,45 @@ private extension MainTabFeature {
case .addButtonTapped:
state.isBottomSheetPresented.toggle()
return .none

case .addSheetTypeSelected(let type):
state.isBottomSheetPresented = false
switch type {
case .๋งํฌ์ถ”๊ฐ€: return .send(.delegate(.๋งํฌ์ถ”๊ฐ€ํ•˜๊ธฐ))
case .ํฌํ‚ท์ถ”๊ฐ€: return .send(.delegate(.ํฌํ‚ท์ถ”๊ฐ€ํ•˜๊ธฐ))
}

case .linkCopyButtonTapped:
state.isLinkSheetPresented = false
return .run { send in await send(.delegate(.๋งํฌ์ถ”๊ฐ€ํ•˜๊ธฐ)) }

case .onAppear:
return .run { send in
let fromBanner = userDefaults.boolKey(.fromBanner)
if fromBanner {
await userDefaults.removeBool(.fromBanner)
await send(.delegate(.์•Œ๋ฆผํ•จ์ด๋™))
}

for await _ in self.pasteBoard.changes() {
let url = try await pasteBoard.probableWebURL()
await send(.inner(.linkCopySuccess(url)), animation: .pokitSpring)
}
if state.isPushTapped {
return .send(.pushAlertTapped(true))
}
return .merge(
.run { send in
for await _ in self.pasteBoard.changes() {
let url = try await pasteBoard.probableWebURL()
await send(.inner(.linkCopySuccess(url)), animation: .pokitSpring)
}
},
.publisher {
state.$isPushTapped.publisher
.map(Action.pushAlertTapped)
}
)
case .onOpenURL(url: let url):
guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false) else {
return .none
}

let queryItems = components.queryItems ?? []
guard let categoryIdString = queryItems.first(where: { $0.name == "categoryId" })?.value,
let categoryId = Int(categoryIdString) else {
return .none
}

return .send(.async(.๊ณต์œ ๋ฐ›์€_์นดํ…Œ๊ณ ๋ฆฌ_์กฐํšŒ(categoryId: categoryId)))
case .๊ฒฝ๊ณ _ํ™•์ธ๋ฒ„ํŠผ_ํด๋ฆญ:
state.error = nil
Expand All @@ -190,15 +201,15 @@ private extension MainTabFeature {
state.isLinkSheetPresented = true
state.link = url.absoluteString
return .none

case let .๊ฒฝ๊ณ _๋„์›€(error):
state.error = error
return .run { send in await send(.inner(.errorSheetPresented(true))) }

case let .errorSheetPresented(isPresented):
state.isErrorSheetPresented = isPresented
return .none

default: return .none
}
}
Expand Down
1 change: 1 addition & 0 deletions Projects/App/Sources/MainTab/MainTabPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public extension MainTabFeature {
case .pokit(.delegate(.alertButtonTapped)),
.remind(.delegate(.alertButtonTapped)),
.delegate(.์•Œ๋ฆผํ•จ์ด๋™):
state.isPushTapped = false
state.path.append(.์•Œ๋ฆผํ•จ(PokitAlertBoxFeature.State()))
return .none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import Foundation
public enum UserDefaultsKey {
public enum BoolKey: String {
case autoSaveSearch
/// - ๋ฐฐ๋„ˆ๋ฅผ ํด๋ฆญํ•ด์„œ ๋“ค์–ด์™”์„ ๋•Œ
case fromBanner
}
public enum StringKey: String {
/// `๊ตฌ๊ธ€` or `์• ํ”Œ`
Expand Down

0 comments on commit 82a8b2e

Please sign in to comment.