Skip to content

Conversation

@Kiyoung-Kim-57
Copy link
Member

🤔 배경

  • 딥링크를 통해 앱으로 진입할 필요가 있었다.

📃 작업 내역

  1. 딥링크 진입을 위한 URL types 속성 추가(PhotoGether 앱만 설정)
  2. 딥링크로 진입 시 게스트로 설정될 수 있도록 함
  3. 딥링크 URI에서 방번호를 파싱하기 위한 메서드 구현

✅ 리뷰 노트

  1. 딥링크를 통해 앱에 진입했을 때 어떻게 초기 생성되는 객체들에 호스트 게스트 여부를 전달해줄까 고민했습니다.
    제가 아는 기존의 방식의 아래의 openURLContexts를 이용해 URI를 처리하는 방식이었습니다.
 func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { }

하지만 해당 방식은 앱 실행 시 초기화되는 객체들이 생성되고 난 이후에 호출이 되기 때문에 다른 방법을 찾아야 했습니다.

찾아보니 앱 실행 시 호출되는 willConnectTo 메서드의 connectionOptions에 있는 URLContexts 속성을 이용해서 처리할 수 있었습니다. 아래의 방식처럼 urlContexts의 배열에 접근해서 URI를 처리할 수 있습니다. 해당 배열은 일반적인 경우처럼 앱 아이콘을 터치해 들어갈 경우 빈 배열입니다. 딥링크로 접속 시 URI가 배열에 추가됩니다.

 func scene(
        _ scene: UIScene,
        willConnectTo session: UISceneSession,
        options connectionOptions: UIScene.ConnectionOptions
 ) {
    var isHost: Bool = true
		      
    if let urlContext = connectionOptions.urlContexts.first {
        // MARK: 딥링크로 들어온지 여부로 호스트 게스트 판단
        isHost = false
    }
 }
  1. 딥링크에 사용된 URI를 파싱하기 위한 네임 스페이스 생성

아래와 같은 URLParser를 만들어 URL 정보를 파싱하기 위한 메서들을 생성했습니다.
엄밀히 따지면 URI 파싱이긴한데...내부에서 사용되는 타입들의 이름이 URL 관련이라 URLParser로 이름 지었습니다.
파일 위치를 어디에 둘까 고민하다가 일단 현재는 데이터 모듈에 위치시켰습니다.

public enum URLParser {
    public static func parsingRoomID(from url: URL) -> String? { ... }
    
    private static func parsingURLQueryItems(_ url: URL) -> [URLQueryItem]? { ... }
}

🎨 스크린샷

iPhone 16 Pro Max

🚀 테스트 방법

PhotoGether://testing 해당 URI를 사파리 주소창에 입력 시 앱에 접근 가능

- URL을 파싱하기 위한 네임 스페이스 생성
- 현재는 딥링크 참여용 URI에서 방번호를 추출하기 위한 로직 구현
@Kiyoung-Kim-57 Kiyoung-Kim-57 added the ✨ feat 새로운 기능 추가 label Nov 24, 2024
@Kiyoung-Kim-57 Kiyoung-Kim-57 self-assigned this Nov 24, 2024
@Kiyoung-Kim-57 Kiyoung-Kim-57 linked an issue Nov 24, 2024 that may be closed by this pull request
1 task
Copy link
Collaborator

@hsw1920 hsw1920 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

캬 드디어..! 고생하셨습니다! 리뷰노트를 자세히 작성해주셔서 이해가 더 쉬웠습니다!

@@ -0,0 +1,20 @@
import Foundation

public enum URLParser {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URLParser를 아직 사용하는 곳이 없어서 잘못 예측하는 걸수도 있는데, 아마 앱 진입점에서 딥링크로 진입 시 roomID를 파싱하기 위함으로 보여요.
이 메소드를 Data Layer에 둔 근거가 궁금해요!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 Parser의 위치에 대한 근거만 조금 궁금한것 같습니다!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

안그래도 어디에 둘지 고민을 하긴 했는데 말씀을 들어보니 SceneDelegate에서만 사용될 것 같아 App Layer으로 이동시키도록 하겠습니다!
84a7b71 수정했습니다!

Copy link
Collaborator

@0Hooni 0Hooni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@@ -0,0 +1,20 @@
import Foundation

public enum URLParser {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 Parser의 위치에 대한 근거만 조금 궁금한것 같습니다!

Copy link
Member

@youn9k youn9k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

드디어 저희가 딥링크에 들어가는군요ㅜㅜ

@Kiyoung-Kim-57 Kiyoung-Kim-57 merged commit d9639bb into develop Nov 25, 2024
1 check passed
@Kiyoung-Kim-57 Kiyoung-Kim-57 deleted the feat/#78-deeplink branch November 25, 2024 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ feat 새로운 기능 추가

Projects

None yet

Development

Successfully merging this pull request may close these issues.

딥링크를 타고 들어올 수 있다

5 participants