-
Notifications
You must be signed in to change notification settings - Fork 0
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
[PI-36] Firebase, Kakao sdk를 추가하고 카톡으로 공유할 수 있도록 합니다. #53
Open
escapeanaemia
wants to merge
16
commits into
main
Choose a base branch
from
feature/PI-36-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
76630b6
Modify package name
escapeanaemia 4f47348
[PI-36] update
escapeanaemia 4814210
[PI-36] update
escapeanaemia 5d007e6
[PI-36] update package
escapeanaemia 43812a8
[PI-36] add app delegate
escapeanaemia f487ca5
[PI-36] update logic and apply Secrets
escapeanaemia bcf3086
[PI-36] add and hide xcconfig for secret
escapeanaemia 8c70103
[PI-36] update gitignore
escapeanaemia af2a944
[PI-36] add secret folder
escapeanaemia 1d645b6
Automatically reformatted for Swift-lint
PlanzEngineering 8882e85
[PI-36-1] add repository
escapeanaemia a3db1fc
Merge remote-tracking branch 'origin/main' into feature/PI-36-1
escapeanaemia c09f989
Automatically reformatted for Swift-lint
PlanzEngineering 7e4567b
[PI-36-1] update package
escapeanaemia a56b4cf
[PI-36-1] update
escapeanaemia dd57432
Automatically reformatted for Swift-lint
PlanzEngineering File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
## xcconfig hide | ||
*.xcconfig | ||
|
||
## Firebase | ||
GoogleService-Info.plist | ||
|
||
## User settings | ||
xcuserdata/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by 한상준 on 2023/04/10. | ||
// | ||
|
||
import FirebaseAuth | ||
import FirebaseCore | ||
import FirebaseDynamicLinks | ||
import FirebaseFirestore | ||
import Foundation | ||
import Planz_iOS_Secrets | ||
public protocol FirebaseRepository { | ||
func getDynamicLink(id: Int?) -> URL? | ||
} | ||
|
||
public class FirebaseRepositoryImpl: FirebaseRepository { | ||
public init() {} | ||
|
||
private func getDeepLink(id: Int?) -> URL? { | ||
if let id { | ||
return URL(string: "\(Secrets.Firebase.domain.value)/?plandId=\(id)") | ||
} else { | ||
return URL(string: Secrets.Firebase.domain.value) | ||
} | ||
} | ||
|
||
public func getDynamicLink(id: Int? = nil) -> URL? { | ||
guard let link = getDeepLink(id: id) else { return nil } | ||
let dynamicLinksDomainURIPrefix = Secrets.Firebase.prefix.value | ||
let linkBuilder = DynamicLinkComponents(link: link, domainURIPrefix: dynamicLinksDomainURIPrefix) | ||
linkBuilder?.iOSParameters = DynamicLinkIOSParameters(bundleID: Secrets.App.iosBundleId.value) | ||
linkBuilder?.androidParameters = DynamicLinkAndroidParameters(packageName: Secrets.App.androidBundleId.value) | ||
return linkBuilder?.url | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by 한상준 on 2023/04/10. | ||
// | ||
|
||
import KakaoSDKShare | ||
import KakaoSDKTemplate | ||
import Planz_iOS_Secrets | ||
|
||
public protocol KakaoRepository { | ||
func getKakaoTalkSharingResult(url: String) async -> Result<SharingResult, Error> | ||
} | ||
|
||
public enum KakaoError: Error { | ||
case kakaoTalkSharingInAvailable | ||
} | ||
|
||
public class KakaoRepositoryImpl: KakaoRepository { | ||
public init() {} | ||
public func getKakaoTalkSharingResult(url _: String) async -> Result<SharingResult, Error> { | ||
if ShareApi.isKakaoTalkSharingAvailable() { | ||
// TODO: 이전 화면에서 전달해주는 id 값에 맞춰서 공유 링크의 파라미터로 추가하도록 수정 필요 | ||
return await withCheckedContinuation { continuation in | ||
ShareApi.shared.shareCustom(templateId: Int64(Secrets.Kakao.templateId.value)!, templateArgs: ["": ""]) { linkResult, error in | ||
if let error = error { | ||
continuation.resume(returning: .failure(error)) | ||
} else { | ||
guard let linkResult = linkResult else { return } | ||
continuation.resume(returning: .success(linkResult)) | ||
} | ||
} | ||
} | ||
} else { | ||
return .failure(KakaoError.kakaoTalkSharingInAvailable) | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// ShareLinkCopyView.swift | ||
// | ||
// | ||
// Created by 한상준 on 2023/02/12. | ||
// | ||
|
||
import ComposableArchitecture | ||
import DesignSystem | ||
import SwiftUI | ||
|
||
struct ShareLinkCopyView: View { | ||
public let store: StoreOf<SharePromiseFeature> | ||
public init(store: StoreOf<SharePromiseFeature>) { | ||
self.store = store | ||
} | ||
|
||
public var body: some View { | ||
WithViewStore(self.store) { viewStore in | ||
HStack { | ||
HStack { | ||
Text(viewStore.linkForShare) | ||
.lineLimit(1) | ||
Spacer() | ||
Button("복사") { | ||
viewStore.send(.copyLinkTapped) | ||
} | ||
.font(.system(size: 14)) | ||
.foregroundColor(PDS.COLOR.purple9.scale) | ||
} | ||
.padding(EdgeInsets(top: 16, leading: 20, bottom: 16, trailing: 20)) | ||
.background(PDS.COLOR.white3.scale) | ||
.border(PDS.COLOR.gray2.scale, width: 1) | ||
.cornerRadius(10) | ||
} | ||
.padding(EdgeInsets(top: 0, leading: 20, bottom: 0, trailing: 20)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by 한상준 on 2023/04/01. | ||
// | ||
|
||
import APIClient | ||
import ComposableArchitecture | ||
import Foundation | ||
import Planz_iOS_Secrets | ||
import Repository | ||
import UIKit | ||
|
||
public struct SharePromiseFeature: ReducerProtocol { | ||
let firebaseRepository: FirebaseRepository | ||
let kakaoRepository: KakaoRepository | ||
public init( | ||
firebaseRepository: FirebaseRepository = FirebaseRepositoryImpl(), | ||
kakaoRepository: KakaoRepository = KakaoRepositoryImpl() | ||
) { | ||
self.firebaseRepository = firebaseRepository | ||
self.kakaoRepository = kakaoRepository | ||
} | ||
|
||
public struct State: Equatable { | ||
var linkForShare = "" | ||
var id: Int | ||
public init(id: Int) { | ||
self.id = id | ||
} | ||
} | ||
|
||
public enum Action: Equatable { | ||
case viewDidAppear | ||
case copyLinkTapped | ||
case shareAsKakaoTapped | ||
} | ||
|
||
func shareViaKakao(link: String) { | ||
Task { | ||
let sharingResult = await self.kakaoRepository.getKakaoTalkSharingResult(url: link) | ||
do { | ||
let url = try sharingResult.get().url | ||
await UIApplication.shared.open(url) | ||
} catch { | ||
// TODO: 공유 에러 팝업 노출 | ||
print(error) | ||
} | ||
} | ||
} | ||
|
||
public var body: some ReducerProtocol<State, Action> { | ||
Reduce { state, action in | ||
switch action { | ||
case .viewDidAppear: | ||
if let link = self.firebaseRepository.getDynamicLink(id: state.id) { | ||
state.linkForShare = link.absoluteString | ||
} | ||
return .none | ||
case .copyLinkTapped: | ||
UIPasteboard.general.string = state.linkForShare | ||
return .none | ||
case .shareAsKakaoTapped: | ||
shareViaKakao(link: state.linkForShare) | ||
return .none | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 부분도 디펜던시로 분리시켜주시면 감사하겠습니다.