From dfac57ee23b96c8c4266af4f976a17a488377d85 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Thu, 6 Mar 2025 00:21:01 +0900 Subject: [PATCH] =?UTF-8?q?Firebase=20=EB=8B=A4=EC=9D=B4=EB=82=98=EB=AF=B9?= =?UTF-8?q?=20=EB=A7=81=ED=81=AC=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SodaLive/Sources/App/SodaLiveApp.swift | 63 ------------------- .../Detail/ContentDetailViewModel.swift | 37 ----------- .../Profile/UserProfileViewModel.swift | 29 --------- .../Room/Detail/LiveDetailViewModel.swift | 48 -------------- .../Sources/Live/Room/LiveRoomViewModel.swift | 43 ------------- 5 files changed, 220 deletions(-) diff --git a/SodaLive/Sources/App/SodaLiveApp.swift b/SodaLive/Sources/App/SodaLiveApp.swift index de2ebf5..fc6b650 100644 --- a/SodaLive/Sources/App/SodaLiveApp.swift +++ b/SodaLive/Sources/App/SodaLiveApp.swift @@ -9,52 +9,12 @@ import SwiftUI import AppTrackingTransparency import FBSDKCoreKit -import FirebaseDynamicLinks @main struct SodaLiveApp: App { @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate - func handleIncomingDynamicLink(_ dynamicLink: DynamicLink) { - guard let url = dynamicLink.url else { - DEBUG_LOG("That's weired. My dynamic link object has no url") - return - } - - DEBUG_LOG("incoming link parameter is \(url.absoluteString)") - - let queryItems = URLComponents(url: url, resolvingAgainstBaseURL: true)?.queryItems - let roomId = queryItems?.filter({$0.name == "room_id"}).first?.value - let channelId = queryItems?.filter({$0.name == "channel_id"}).first?.value - let messageId = queryItems?.filter({$0.name == "message_id"}).first?.value - let audioContentId = queryItems?.filter({$0.name == "content_id"}).first?.value - - if let roomId = roomId { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { - AppState.shared.pushRoomId = Int(roomId) ?? 0 - } - } - - if let channelId = channelId { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { - AppState.shared.pushChannelId = Int(channelId) ?? 0 - } - } - - if let messageId = messageId { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { - AppState.shared.pushMessageId = Int(messageId) ?? 0 - } - } - - if let audioContentId = audioContentId { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { - AppState.shared.pushAudioContentId = Int(audioContentId) ?? 0 - } - } - } - var body: some Scene { WindowGroup { ContentView() @@ -69,29 +29,6 @@ struct SodaLiveApp: App { .onOpenURL { url in DEBUG_LOG("I have received a URL through a custom scheme! \(url.absoluteString)") ApplicationDelegate.shared.application(UIApplication.shared, open: url, options: [:]) - if let scheme = url.scheme { - if scheme == "kr.co.vividnext.sodalive" { - if let dynamicLink = DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url) { - self.handleIncomingDynamicLink(dynamicLink) - } else { - DEBUG_LOG("dynamic link fail") - } - } else { - DynamicLinks.dynamicLinks().handleUniversalLink(url) { dynamicLink, error in - guard error == nil else { - DEBUG_LOG("Found an error! \(error!.localizedDescription)") - DEBUG_LOG("dynamic link fail") - return - } - - if let dynamicLink = dynamicLink { - self.handleIncomingDynamicLink(dynamicLink) - } else { - DEBUG_LOG("dynamic link fail") - } - } - } - } } } } diff --git a/SodaLive/Sources/Content/Detail/ContentDetailViewModel.swift b/SodaLive/Sources/Content/Detail/ContentDetailViewModel.swift index 8b06165..55cb67c 100644 --- a/SodaLive/Sources/Content/Detail/ContentDetailViewModel.swift +++ b/SodaLive/Sources/Content/Detail/ContentDetailViewModel.swift @@ -8,8 +8,6 @@ import Foundation import Combine -import FirebaseDynamicLinks - final class ContentDetailViewModel: ObservableObject { private let repository = ContentRepository() @@ -202,41 +200,6 @@ final class ContentDetailViewModel: ObservableObject { } func shareAudioContent(contentImage: String, contentTitle: String) { - isLoading = true - guard let link = URL(string: "https://sodalive.net/?audio_content_id=\(contentId)") else { return } - let dynamicLinksDomainURIPrefix = "https://sodalive.page.link" - guard let linkBuilder = DynamicLinkComponents(link: link, domainURIPrefix: dynamicLinksDomainURIPrefix) else { - self.errorMessage = "공유링크를 생성하지 못했습니다.\n다시 시도해 주세요." - self.isShowPopup = true - return - } - - linkBuilder.iOSParameters = DynamicLinkIOSParameters(bundleID: "kr.co.vividnext.sodalive") - linkBuilder.iOSParameters?.appStoreID = "6461721697" - - linkBuilder.androidParameters = DynamicLinkAndroidParameters(packageName: "kr.co.vividnext.sodalive") - - let socialMetaTagParameters = DynamicLinkSocialMetaTagParameters() - socialMetaTagParameters.title = contentTitle - socialMetaTagParameters.descriptionText = "지금 보이스온에서 이 콘텐츠 감상하기" - socialMetaTagParameters.imageURL = URL(string: contentImage) - linkBuilder.socialMetaTagParameters = socialMetaTagParameters - - guard let longDynamicLink = linkBuilder.url else { - self.errorMessage = "공유링크를 생성하지 못했습니다.\n다시 시도해 주세요." - self.isShowPopup = true - return - } - DEBUG_LOG("The long URL is: \(longDynamicLink)") - - DynamicLinkComponents.shortenURL(longDynamicLink, options: nil) { [unowned self] url, warnings, error in - let shortUrl = url?.absoluteString - let urlString = shortUrl != nil ? shortUrl! : longDynamicLink.absoluteString - - self.isLoading = false - self.shareMessage = urlString - self.isShowShareView = true - } } func registerComment(comment: String, isSecret: Bool) { diff --git a/SodaLive/Sources/Explorer/Profile/UserProfileViewModel.swift b/SodaLive/Sources/Explorer/Profile/UserProfileViewModel.swift index 991162d..e5b6e9c 100644 --- a/SodaLive/Sources/Explorer/Profile/UserProfileViewModel.swift +++ b/SodaLive/Sources/Explorer/Profile/UserProfileViewModel.swift @@ -8,8 +8,6 @@ import Foundation import Combine -import FirebaseDynamicLinks - final class UserProfileViewModel: ObservableObject { private var repository = ExplorerRepository() @@ -401,33 +399,6 @@ final class UserProfileViewModel: ObservableObject { } func shareChannel(userId: Int) { - guard let link = URL(string: "https://sodalive.net/?channel_id=\(userId)") else { return } - let dynamicLinksDomainURIPrefix = "https://sodalive.page.link" - guard let linkBuilder = DynamicLinkComponents(link: link, domainURIPrefix: dynamicLinksDomainURIPrefix) else { - self.errorMessage = "공유링크를 생성하지 못했습니다.\n다시 시도해 주세요." - self.isShowPopup = true - return - } - - linkBuilder.iOSParameters = DynamicLinkIOSParameters(bundleID: "kr.co.vividnext.sodalive") - linkBuilder.iOSParameters?.appStoreID = "6461721697" - - linkBuilder.androidParameters = DynamicLinkAndroidParameters(packageName: "kr.co.vividnext.sodalive") - - guard let longDynamicLink = linkBuilder.url else { - self.errorMessage = "공유링크를 생성하지 못했습니다.\n다시 시도해 주세요." - self.isShowPopup = true - return - } - DEBUG_LOG("The long URL is: \(longDynamicLink)") - - DynamicLinkComponents.shortenURL(longDynamicLink, options: nil) { [unowned self] url, warnings, error in - let shortUrl = url?.absoluteString - let urlString = shortUrl != nil ? shortUrl! : longDynamicLink.absoluteString - - self.shareMessage = "보이스온 \(self.creatorProfile!.creator.nickname)님의 채널입니다.\n\(urlString)" - self.isShowShareView = true - } } func userBlock(userId: Int) { diff --git a/SodaLive/Sources/Live/Room/Detail/LiveDetailViewModel.swift b/SodaLive/Sources/Live/Room/Detail/LiveDetailViewModel.swift index caffebb..6351abf 100644 --- a/SodaLive/Sources/Live/Room/Detail/LiveDetailViewModel.swift +++ b/SodaLive/Sources/Live/Room/Detail/LiveDetailViewModel.swift @@ -8,8 +8,6 @@ import Foundation import Combine -import FirebaseDynamicLinks - final class LiveDetailViewModel: ObservableObject { private let repository = LiveRepository() private var subscription = Set() @@ -112,51 +110,5 @@ final class LiveDetailViewModel: ObservableObject { } func shareRoom(roomId: Int) { - isLoading = true - guard let link = URL(string: "https://sodalive.net/?room_id=\(roomId)") else { return } - let dynamicLinksDomainURIPrefix = "https://sodalive.page.link" - guard let linkBuilder = DynamicLinkComponents(link: link, domainURIPrefix: dynamicLinksDomainURIPrefix) else { - self.errorMessage = "공유링크를 생성하지 못했습니다.\n다시 시도해 주세요." - self.isShowPopup = true - isLoading = false - return - } - - linkBuilder.iOSParameters = DynamicLinkIOSParameters(bundleID: "kr.co.vividnext.sodalive") - linkBuilder.iOSParameters?.appStoreID = "6461721697" - - linkBuilder.androidParameters = DynamicLinkAndroidParameters(packageName: "kr.co.vividnext.sodalive") - - guard let longDynamicLink = linkBuilder.url else { - self.errorMessage = "공유링크를 생성하지 못했습니다.\n다시 시도해 주세요." - self.isShowPopup = true - isLoading = false - return - } - DEBUG_LOG("The long URL is: \(longDynamicLink)") - - DynamicLinkComponents.shortenURL(longDynamicLink, options: nil) { [unowned self] url, warnings, error in - let shortUrl = url?.absoluteString - - if let liveRoomInfo = self.room { - let urlString = shortUrl != nil ? shortUrl! : longDynamicLink.absoluteString - if liveRoomInfo.isPrivateRoom { - shareMessage = "\(UserDefaults.string(forKey: .nickname))님이 귀하를 보이스온 비공개라이브에 초대하였습니다.\n" + - "※ 라이브 참여: \(urlString)\n" + - "(입장 비밀번호: \(liveRoomInfo.password!))" - } else { - shareMessage = "\(UserDefaults.string(forKey: .nickname))님이 귀하를 보이스온 공개라이브에 초대하였습니다.\n" + - "※ 라이브 참여: \(urlString)" - } - - isShowShareView = true - } else { - self.errorMessage = "공유링크를 생성하지 못했습니다.\n다시 시도해 주세요." - self.isShowPopup = true - return - } - - isLoading = false - } } } diff --git a/SodaLive/Sources/Live/Room/LiveRoomViewModel.swift b/SodaLive/Sources/Live/Room/LiveRoomViewModel.swift index 9de53d9..e4b4888 100644 --- a/SodaLive/Sources/Live/Room/LiveRoomViewModel.swift +++ b/SodaLive/Sources/Live/Room/LiveRoomViewModel.swift @@ -12,8 +12,6 @@ import Combine import AgoraRtcKit import AgoraRtmKit -import FirebaseDynamicLinks - final class LiveRoomViewModel: NSObject, ObservableObject { private var agora: Agora = Agora.shared @@ -926,47 +924,6 @@ final class LiveRoomViewModel: NSObject, ObservableObject { } func shareRoom() { - guard let link = URL(string: "https://sodalive.net/?room_id=\(AppState.shared.roomId)") else { return } - let dynamicLinksDomainURIPrefix = "https://sodalive.page.link" - guard let linkBuilder = DynamicLinkComponents(link: link, domainURIPrefix: dynamicLinksDomainURIPrefix) else { - self.errorMessage = "공유링크를 생성하지 못했습니다.\n다시 시도해 주세요." - self.isShowErrorPopup = true - return - } - - linkBuilder.iOSParameters = DynamicLinkIOSParameters(bundleID: "kr.co.vividnext.sodalive") - linkBuilder.iOSParameters?.appStoreID = "6461721697" - - linkBuilder.androidParameters = DynamicLinkAndroidParameters(packageName: "kr.co.vividnext.sodalive") - - guard let longDynamicLink = linkBuilder.url else { - self.errorMessage = "공유링크를 생성하지 못했습니다.\n다시 시도해 주세요." - self.isShowErrorPopup = true - return - } - DEBUG_LOG("The long URL is: \(longDynamicLink)") - - DynamicLinkComponents.shortenURL(longDynamicLink, options: nil) { [unowned self] url, warnings, error in - let shortUrl = url?.absoluteString - - if let liveRoomInfo = self.liveRoomInfo { - let urlString = shortUrl != nil ? shortUrl! : longDynamicLink.absoluteString - if liveRoomInfo.isPrivateRoom { - shareMessage = "\(UserDefaults.string(forKey: .nickname))님이 귀하를 보이스온 비공개라이브에 초대하였습니다.\n" + - "※ 라이브 참여: \(urlString)\n" + - "(입장 비밀번호: \(liveRoomInfo.password!))" - } else { - shareMessage = "\(UserDefaults.string(forKey: .nickname))님이 귀하를 보이스온 공개라이브에 초대하였습니다.\n" + - "※ 라이브 참여: \(urlString)" - } - - isShowShareView = true - } else { - self.errorMessage = "공유링크를 생성하지 못했습니다.\n다시 시도해 주세요." - self.isShowErrorPopup = true - return - } - } } func kickOut() {