Skip to content

Commit

Permalink
#2 feat: add KakaoBtn Tap Action
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryVoid committed Oct 27, 2024
1 parent 9977344 commit 4eb6cb1
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Climeet-iOS/Climeet-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "Swift.Climeet.Climeet-iOS";
PRODUCT_BUNDLE_IDENTIFIER = com.climeet.climeet;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down Expand Up @@ -632,7 +632,7 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "Swift.Climeet.Climeet-iOS";
PRODUCT_BUNDLE_IDENTIFIER = com.climeet.climeet;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
14 changes: 12 additions & 2 deletions Climeet-iOS/Climeet-iOS/App/Climeet_iOSApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,17 @@ struct ClimeetiOSApp: App {

var body: some Scene {
WindowGroup {
MainTabView()
AuthView(store: .init(initialState: .init(), reducer: { AuthReducer() }))
.onOpenURL { url in
if AuthApi.isKakaoTalkLoginUrl(url) {
_ = AuthController.handleOpenUrl(url: url)
}

NaverThirdPartyLoginConnection
.getSharedInstance()
.receiveAccessToken(url)
}
// MainTabView()
}
}

Expand All @@ -46,7 +56,7 @@ struct ClimeetiOSApp: App {
instance?.setOnlyPortraitSupportInIphone(true)

// NaverThirdPartyConstantsForApp.h에 선언한 상수 등록
instance?.serviceUrlScheme = "Swift.Climeet.Climeet-iOS"
instance?.serviceUrlScheme = "com.climeet.climeet"
instance?.consumerKey = Env.NAVER_CLIENT_ID
instance?.consumerSecret = Env.NAVER_CLIENT_SECRET
instance?.appName = "Climeet"
Expand Down
2 changes: 1 addition & 1 deletion Climeet-iOS/Climeet-iOS/Data/Client/KakaoClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import KakaoSDKAuth
import KakaoSDKCommon

struct KakaoClient {
var login: @Sendable () async -> Result<String, AppError>
var login: @MainActor @Sendable () async -> Result<String, AppError>
var me: @Sendable () async -> Result<KakaoDTO.Response, AppError>
}

Expand Down
25 changes: 23 additions & 2 deletions Climeet-iOS/Climeet-iOS/Presentation/Auth/AuthReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ import ComposableArchitecture

@Reducer
struct AuthReducer {
@Dependency(\.kakaoClient) var kakaoClient

@ObservableState
struct State: Equatable {

var token: String? = nil
}

enum Action: Equatable {
case kakaoBtnDidTap
case naverBtnDidTap
case kakaoLoginResponse(Result<String, AppError>)
case kakaoProfileResponse(Result<KakaoDTO.Response, AppError>)
}

init() {}
Expand All @@ -26,9 +30,26 @@ struct AuthReducer {
Reduce { state, action in
switch action {
case .kakaoBtnDidTap:
return .none
return .run { send in
let login = await kakaoClient.login()
await send(.kakaoLoginResponse(login))
}
case .naverBtnDidTap:
return .none
case .kakaoLoginResponse(.success(let oAuthToken)):
Log.debug("KakaoLogin API Success\n Token:", oAuthToken)
state.token = oAuthToken
return .run { send in
let profile = await kakaoClient.me()
await send(.kakaoProfileResponse(profile))
}
case .kakaoProfileResponse(.success(let userData)):
Log.debug("KakaoProfile API Success\n userData:", userData)
return .none
case .kakaoLoginResponse(.failure(let error)),
.kakaoProfileResponse(.failure(let error)):
Log.debug("API fail", error)
return .none
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Climeet-iOS/Climeet-iOS/Presentation/Auth/AuthView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extension AuthView {
@ViewBuilder
private func kakaoBtn() -> some View {
Button {

self.store.send(.kakaoBtnDidTap)
} label: {
HStack {
Image(.kakaoLogo)
Expand All @@ -69,7 +69,7 @@ extension AuthView {
@ViewBuilder
private func naverBtn() -> some View {
Button {

self.store.send(.naverBtnDidTap)
} label: {
HStack {
Image(.naverLogo)
Expand Down
16 changes: 8 additions & 8 deletions Climeet-iOS/Climeet-iOS/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>MASTER_TOKEN</key>
<string>$(MASTER_TOKEN)</string>
<key>BASE_URL</key>
<string>${BASE_URL}</string>
<key>CLIMBER_TOKEN</key>
<string>$(CLIMBER_TOKEN)</string>
<key>NAVER_CLIENT_SECRET</key>
<string>$(NAVER_CLIENT_SECRET)</string>
<key>NAVER_CLIENT_ID</key>
<string>$(NAVER_CLIENT_ID)\</string>
<key>KAKAO_APP_KEY</key>
<string>$(KAKAO_APP_KEY)</string>
<key>BASE_URL</key>
<string>${BASE_URL}</string>
<key>MASTER_TOKEN</key>
<string>$(MASTER_TOKEN)</string>
<key>NAVER_CLIENT_ID</key>
<string>$(NAVER_CLIENT_ID)\</string>
<key>NAVER_CLIENT_SECRET</key>
<string>$(NAVER_CLIENT_SECRET)</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
Expand Down

0 comments on commit 4eb6cb1

Please sign in to comment.