Skip to content

Commit

Permalink
[Fix] Runnect#178 - 코스 공유 쓸모 없는 코드 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
thingineeer committed Sep 7, 2023
1 parent 917876b commit 8148689
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 40 deletions.
69 changes: 33 additions & 36 deletions Runnect-iOS/Runnect-iOS/Global/Supports/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -39,63 +36,65 @@ 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

}
}
}
}
}

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
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)
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,3 @@ extension CustomNavigationBar: UITextFieldDelegate {
return true
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -265,7 +267,7 @@ extension CourseDetailVC {
self.publicCourseId = publicCourseId
}

func setPublicCourseId(publicCourseId: Int?) {
func setPublicCourseId(publicCourseId: Int?) { // 추가한 것
self.publicCourseId = publicCourseId
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ extension TabBarController {
nav.navigationBar.isHidden = true
return nav
}


}

0 comments on commit 8148689

Please sign in to comment.