-
Notifications
You must be signed in to change notification settings - Fork 6
[Feat] #259 - 개인 코스 공유 기능을 추가 하였습니다. #261
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
The head ref may contain hidden characters: "#259---\uAC1C\uC778\uCF54\uC2A4\uACF5\uC720\uAE30\uB2A5"
Changes from all commits
6da8786
02d54c1
f8c59f6
32956c9
66fe2b6
c86e7fa
9d3a764
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,11 +12,15 @@ import FirebaseDynamicLinks | |
| import FirebaseCore | ||
| import FirebaseCoreInternal | ||
|
|
||
| // 들어온 링크가 공유된 코스인지, 개인 보관함에 있는 코스인지 나타내기 위한 타입입니다. | ||
| enum CourseType { | ||
| case publicCourse, privateCourse | ||
| } | ||
|
Comment on lines
+16
to
+18
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sceneDelegate의 역할이 scene의 라이프 사이클을 관리하는 거라서 이 파일 내부에서 CourseType에 대한 정의를 하는게 저희를 제외한 외부한테는 조금 이해하기 어려울 수 있겠다는 생각이 들엇습니다... 장황하게 말하긴 했지만 위치를 옮기거나(근데 옮길 곳이 없는듯..?) 주석을 다는게 어떨까용?!
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 주석을 추가 하도록 하겠습니다! |
||
|
|
||
| class SceneDelegate: UIResponder, UIWindowSceneDelegate { | ||
|
|
||
| var window: UIWindow? | ||
|
|
||
|
|
||
| func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | ||
|
|
||
| guard let _ = (scene as? UIWindowScene) else { return } | ||
|
|
@@ -39,30 +43,33 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { | |
| func scene(_ scene: UIScene, continue userActivity: NSUserActivity) { | ||
|
|
||
| if let incomingURL = userActivity.webpageURL { | ||
| let linkHandled = DynamicLinks.dynamicLinks() | ||
| DynamicLinks.dynamicLinks() | ||
| .handleUniversalLink(incomingURL) { dynamicLink, error in | ||
|
|
||
| if let courseId = self.handleDynamicLink(dynamicLink) { | ||
| guard let _ = (scene as? UIWindowScene) else { return } | ||
| if let (courseType, courseId) = self.handleDynamicLink(dynamicLink) { | ||
| guard let windowScene = scene as? UIWindowScene else { return } | ||
| let window = UIWindow(windowScene: windowScene) | ||
| let navigationController = UINavigationController() | ||
|
|
||
| if let windowScene = scene as? UIWindowScene { | ||
| let window = UIWindow(windowScene: windowScene) | ||
|
|
||
| switch courseType { | ||
| case .publicCourse: | ||
| let courseDetailVC = CourseDetailVC() | ||
| courseDetailVC.getUploadedCourseDetail(courseId: Int(courseId)) | ||
|
|
||
| let tabBarController = TabBarController() | ||
| let navigationController = UINavigationController(rootViewController: tabBarController) | ||
| navigationController.navigationBar.isHidden = true | ||
| courseDetailVC.getUploadedCourseDetail(courseId: courseId) | ||
| navigationController.pushViewController(courseDetailVC, animated: false) | ||
|
|
||
| // 코스 발견 view 로 이동 | ||
| tabBarController.selectedIndex = 2 | ||
| window.rootViewController = navigationController | ||
| window.makeKeyAndVisible() | ||
| self.window = window | ||
|
|
||
| case .privateCourse: | ||
| let privateCourseDetailVC = RunningWaitingVC() | ||
| privateCourseDetailVC.setData(courseId: courseId, publicCourseId: nil) | ||
| navigationController.pushViewController(privateCourseDetailVC, animated: false) | ||
| } | ||
|
|
||
| let tabBarController = TabBarController() | ||
| navigationController.navigationBar.isHidden = true | ||
| navigationController.viewControllers = [tabBarController, navigationController.viewControllers.last].compactMap { $0 } | ||
|
|
||
| tabBarController.selectedIndex = 2 | ||
| window.rootViewController = navigationController | ||
| window.makeKeyAndVisible() | ||
| self.window = window | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -106,17 +113,26 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { | |
| // to restore the scene back to its current state. | ||
| } | ||
|
|
||
| func handleDynamicLink(_ dynamicLink: DynamicLink?) -> String? { | ||
| func handleDynamicLink(_ dynamicLink: DynamicLink?) -> (courseType: CourseType, courseId: Int)? { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 맞습니다. 아래와 같은 코드로 URL Scheme에 해당하는 요소를 빼고 어떤 건지 구별하여 타입을 구분하여 리턴을 하도록 만들었습니다.
|
||
| if let dynamicLink = dynamicLink, let url = dynamicLink.url, | ||
| let components = URLComponents(url: url, resolvingAgainstBaseURL: false), | ||
| let queryItems = components.queryItems { | ||
| var courseId: Int? | ||
| var courseType: CourseType? | ||
|
|
||
| for item in queryItems { | ||
| if item.name == "courseId", let courseId = item.value { | ||
| // 동적링크 핸들링 하여 courseId 추출 | ||
|
|
||
| return courseId | ||
| if item.name == "courseId", let id = item.value, let idInt = Int(id) { | ||
| courseId = idInt | ||
| courseType = .publicCourse | ||
| } else if item.name == "privateCourseId", let id = item.value, let idInt = Int(id) { | ||
| courseId = idInt | ||
| courseType = .privateCourse | ||
| } | ||
| } | ||
|
|
||
| if let courseId = courseId, let courseType = courseType { | ||
| return (courseType, courseId) | ||
| } | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
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.
익스텐션으로 따로 빼두는게 좋을 것 같다는 생각을 했는데 역시 명진쌤,,,,, 👍🏻