From 81486895407e726f8a10e42d527fbc26c952297a Mon Sep 17 00:00:00 2001 From: LeeMyeongJin Date: Thu, 7 Sep 2023 16:18:44 +0900 Subject: [PATCH] =?UTF-8?q?[Fix]=20#178=20-=20=EC=BD=94=EC=8A=A4=20?= =?UTF-8?q?=EA=B3=B5=EC=9C=A0=20=EC=93=B8=EB=AA=A8=20=EC=97=86=EB=8A=94=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Global/Supports/SceneDelegate.swift | 69 +++++++++---------- .../UIComponents/CustomNavigationBar.swift | 1 - .../CourseDetail/VC/CourseDetailVC.swift | 8 ++- .../Presentation/TabBar/TaBarController.swift | 2 + 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS/Global/Supports/SceneDelegate.swift b/Runnect-iOS/Runnect-iOS/Global/Supports/SceneDelegate.swift index 87d9e543..6dc0c4de 100644 --- a/Runnect-iOS/Runnect-iOS/Global/Supports/SceneDelegate.swift +++ b/Runnect-iOS/Runnect-iOS/Global/Supports/SceneDelegate.swift @@ -19,15 +19,12 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { - print("🔥 scene에서 willConnectTo 동작 🔥") guard let _ = (scene as? UIWindowScene) else { return } if let userActivity = connectionOptions.userActivities.first { - print("🔥 scene에서 userActivity 동작 🔥") self.scene(scene, continue: userActivity) } - print("🔥 scene에서 SplashVC() 동작 🔥") guard let windowScene = (scene as? UIWindowScene) else { return } let window = UIWindow(windowScene: windowScene) @@ -39,26 +36,30 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { } func scene(_ scene: UIScene, continue userActivity: NSUserActivity) { + if let incomingURL = userActivity.webpageURL { let linkHandled = DynamicLinks.dynamicLinks() .handleUniversalLink(incomingURL) { dynamicLink, error in - if let courseId = self.handleDynamicLink(dynamicLink) { guard let _ = (scene as? UIWindowScene) else { return } if let windowScene = scene as? UIWindowScene { let window = UIWindow(windowScene: windowScene) - let rootVC = CourseDetailVC() - rootVC.setPublicCourseId(publicCourseId: Int(courseId)) - rootVC.getUploadedCourseDetail(courseId: Int(courseId)) + let courseDetailVC = CourseDetailVC() + courseDetailVC.setPublicCourseId(publicCourseId: Int(courseId)) + courseDetailVC.getUploadedCourseDetail(courseId: Int(courseId)) + + let tabBarController = TabBarController() + let navigationController = UINavigationController(rootViewController: tabBarController) + navigationController.navigationBar.isHidden = true + navigationController.pushViewController(courseDetailVC, animated: false) - // CourseDetailVC를 NavigationController로 감싸고, rootViewController로 설정합니다. - let navigationController = UINavigationController(rootViewController: rootVC) window.rootViewController = navigationController window.makeKeyAndVisible() self.window = window + } } } @@ -66,36 +67,34 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { } func scene(_ scene: UIScene, openURLContexts URLContexts: Set) { - print("🔥 SceneDelegate의 openURLContexts입니다~ 🔥") - - print(URLContexts) - print(URLContexts.first!) if let url = URLContexts.first?.url { // Firebase Dynamic Links를 사용하여 딥 링크를 처리합니다. - print("🔥 SceneDelegate의 url은 : \(url) 🔥") - let linkHandled = DynamicLinks.dynamicLinks().handleUniversalLink(url) { dynamicLink, error in - if let courseId = self.handleDynamicLink(dynamicLink) { - guard let _ = (scene as? UIWindowScene) else { return } + let linkHandled = DynamicLinks.dynamicLinks() + .handleUniversalLink(url) { dynamicLink, error in - if let windowScene = scene as? UIWindowScene { - let window = UIWindow(windowScene: windowScene) - window.overrideUserInterfaceStyle = .light - - // CourseDetailVC 인스턴스를 생성합니다. - let rootVC = CourseDetailVC() - rootVC.setPublicCourseId(publicCourseId: Int(courseId)) + if let courseId = self.handleDynamicLink(dynamicLink) { + guard let _ = (scene as? UIWindowScene) else { return } - // CourseDetailVC를 NavigationController로 감싸고, rootViewController로 설정합니다. - let navigationController = UINavigationController(rootViewController: rootVC) - window.rootViewController = navigationController - window.makeKeyAndVisible() - self.window = window + if let windowScene = scene as? UIWindowScene { + let window = UIWindow(windowScene: windowScene) + + let courseDetailVC = CourseDetailVC() + courseDetailVC.setPublicCourseId(publicCourseId: Int(courseId)) + courseDetailVC.getUploadedCourseDetail(courseId: Int(courseId)) + + let tabBarController = TabBarController() + let navigationController = UINavigationController(rootViewController: tabBarController) + navigationController.navigationBar.isHidden = true + navigationController.pushViewController(courseDetailVC, animated: false) + + window.rootViewController = navigationController + window.makeKeyAndVisible() + self.window = window + + } } } - } - print("🔥 바인딩 유무 ", linkHandled, "🔥") - // Kakao SDK가 처리해야 하는지 확인합니다. if AuthApi.isKakaoTalkLoginUrl(url) { _ = AuthController.handleOpenUrl(url: url) @@ -138,16 +137,14 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { let queryItems = components.queryItems { for item in queryItems { if item.name == "courseId", let courseId = item.value { - // courseId를 사용하여 특정 뷰로 이동 - // 예: courseId를 기반으로 상세 화면을 열거나 특정 기능 수행 - print("🔥코스아이디가 제대로 여기까지 오는가!", courseId, "🔥") + // 동적링크 핸들링 하여 courseId 추출 + return courseId } } } return nil } - } extension CourseDetailVC { diff --git a/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomNavigationBar.swift b/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomNavigationBar.swift index d6ad2fac..132cd403 100644 --- a/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomNavigationBar.swift +++ b/Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomNavigationBar.swift @@ -317,4 +317,3 @@ extension CustomNavigationBar: UITextFieldDelegate { return true } } - diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDetail/VC/CourseDetailVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDetail/VC/CourseDetailVC.swift index aa2e7f68..85d966e0 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDetail/VC/CourseDetailVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDetail/VC/CourseDetailVC.swift @@ -13,10 +13,11 @@ import NMapsMap import Moya import SafariServices import KakaoSDKCommon -import KakaoSDKShare -import KakaoSDKTemplate import FirebaseCore import FirebaseDynamicLinks +import KakaoSDKShare +import KakaoSDKTemplate + final class CourseDetailVC: UIViewController { @@ -184,6 +185,7 @@ extension CourseDetailVC { linkBuilder?.shorten(completion: { url, _, _ in guard let url = url else { return } print("The short URL is: \(url)") + }) let activityVC = UIActivityViewController(activityItems: [longDynamicLink.absoluteString], applicationActivities: nil) @@ -265,7 +267,7 @@ extension CourseDetailVC { self.publicCourseId = publicCourseId } - func setPublicCourseId(publicCourseId: Int?) { + func setPublicCourseId(publicCourseId: Int?) { // 추가한 것 self.publicCourseId = publicCourseId } diff --git a/Runnect-iOS/Runnect-iOS/Presentation/TabBar/TaBarController.swift b/Runnect-iOS/Runnect-iOS/Presentation/TabBar/TaBarController.swift index 21d8ffab..0bb3866a 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/TabBar/TaBarController.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/TabBar/TaBarController.swift @@ -59,4 +59,6 @@ extension TabBarController { nav.navigationBar.isHidden = true return nav } + + }