Get Up & Code, MacKin Talk

CFBundleURLSchemes 과 LSApplicationQueriesSchemes 본문

IOS

CFBundleURLSchemes 과 LSApplicationQueriesSchemes

맥킨 2024. 3. 5. 17:43

서드파티 로그인 또는 앱간인증을 진행하다보면 info.plist 파일에 상단 키워드들을 작성하게 된다.

 

둘 모두 개발중인 앱이 다른 앱과의 상호 작용을 위해 사용하는 URL 스킴을 정의하나, 이 둘은 사용 목적과 방식에서 차이가 있다.

 

 

1. CFBundleURLSchemes(외부에서 호출될 현재 앱의 URL Scheme)

 

앱이 외부에서 호출될 수 있는 URL Scheme을 정의.

이 설정을 통해 앱은 다른 앱이나 웹 페이지로부터 특정 URL Scheme을 사용하여 직접 호출될 수 있다.

 

예를 들어, "luyan://" URL Scheme을 앱에 설정하면, 다른 앱이나 브라우저에서 이 URL을 호출하여 현재 앱을 열 수 있습니다. CFBundleURLSchemes를 사용하면 앱은 외부 요청을 받아 특정 액션을 수행하거나 정보를 제공할 수 있다.

 

 

2. LSApplicationQueriesSchemes(실행할 다른 앱의 URL Scheme)

 

현재 앱이 다른 앱을 호출하기 위해 사용할 수 있는 URL Scheme을 정의.

iOS 9 이상에서는 앱이 canOpenURL: 메소드를 사용하여 다른 앱을 열 수 있는지 확인하기 전에, 해당 앱의 URL Scheme이 LSApplicationQueriesSchemes에 명시되어 있어야 한다.

 

이는 보안과 프라이버시를 강화하기 위한 조치로, 앱이 사전에 선언하지 않은 상황에서, 임의의 앱을 호출하는 것을 방지한다.

예를 들어, 앱이 서드파티 로그인을 시도하기 위해 페이스북 앱을 열고 싶다면, Info.plist 파일에 페이스북 앱의 URL Scheme을 LSApplicationQueriesSchemes에 추가해야 한다.

 

 UIApplication의 canOpenURL과 관련 있는 Scheme

 

Specifies the URL schemes the app is able to test using the canOpenURL: method. See LSApplicationQueriesSchemes for details.

 

https://developer.apple.com/documentation/uikit/uiapplication/1622952-canopenurl

 

canOpenURL(_:) | Apple Developer Documentation

Returns a Boolean value that indicates whether an app is available to handle a URL scheme.

developer.apple.com

 

 

 

위에 설명한 두 가지를 포함하여 여러 property list에 대한 자세한 내용은 하단 링크 확인

 

https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/TP40009249-102207-TPXREF115

 

Core Foundation Keys

Core Foundation Keys The Core Foundation framework provides the underlying infrastructure for bundles, including the code used at runtime to load bundles and parse their structure. As a result, many of the keys recognized by this framework are fundamental

developer.apple.com

 

https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW14

 

Launch Services Keys

Launch Services Keys Launch Services (part of the Core Services framework in macOS) provides support for launching apps and matching document types to apps. As a result, the keys recognized by Launch Services allow you to specify the desired execution envi

developer.apple.com