답변:
iOS 9 용 앱을 빌드 할 때 URL 스킴을 계속 사용할 수 있으며 URL 스킴을 호출하려면 앱 Info.plist에서이를 선언해야합니다. LSApplicationQueriesSchemes 라는 새로운 키가 있으며 여기 에서 canOpenURL 을 사용하려는 구성표 목록을 추가해야합니다.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbauth2</string>
</array>
iOS9를 사용하는 경우 info.plist 파일을 업데이트하는 것이 중요합니다. 3 단계 만 수행하면됩니다. info.plist로 이동하십시오. 2. LSApplicationQueriesSchemes NSArray 데이터 유형 필드를 추가하십시오 . 3. NSString 데이터 유형의 항목을 fbauth2로 추가하십시오.
FaceBook SDK v4.6.0과 관련하여 plist 파일에 다음 키를 추가하십시오.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
not이 작업을 수행하도록 지시합니다.
: 그냥 페이스 북의 설명을 따라 iOS9에 대한 내 앱을 준비
애플 자신에 그것을 언급 : 개인 정보 보호 및 2015 년 당신의 앱 기조
CFBundleURLSchemes에 이것을 추가하지 마십시오 ... 실제로 Facebook 인증에서 앱의 시도를 HIJACK하여 팝업에 "X app want to open"대화 상자가 표시됩니다.
당신은 그렇게하고 싶지 않습니다.
cf :
https://developers.facebook.com/docs/applinks/ios
https://www.fireeye.com/blog/threat-research/2015/04/url_masques_on_apps.html
https://www.reddit.com/r/workflow/comments/2tlx29/get_url_scheme_of_any_app
테스트 대상이 기본 번들에 액세스 할 수 없으므로 키위 테스트를 실행할 때 이것을 얻었습니다. 그래서에 조건을 추가해야 isRegisteredCanOpenURLScheme했습니다.FBSDKInternalUtility.m
+ (BOOL)isRegisteredCanOpenURLScheme:(NSString *)urlScheme
{
static dispatch_once_t fetchBundleOnce;
static NSArray *schemes = nil;
dispatch_once(&fetchBundleOnce, ^{
schemes = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"LSApplicationQueriesSchemes"];
if (!schemes) { // This is a work around for our Kiwi tests as the Specs target doesn't have access to main bundle
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *path = [bundle pathForResource:@"Info" ofType:@"plist"];
NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfFile:path];
schemes = [dictionary valueForKey:@"LSApplicationQueriesSchemes"];
}
});
return [schemes containsObject:urlScheme];
}
Write the below code in your info.plist under the **LSApplicationQueriesScheme**
<string>fbapi</string>
<string>fbapi20130214</string>
<string>fbapi20130410</string>
<string>fbapi20130702</string>
<string>fbapi20131010</string>
<string>fbapi20131219</string>
<string>fbapi20140410</string>
<string>fbapi20140116</string>
<string>fbapi20150313</string>
<string>fbapi20150629</string>
<string>fbauth</string>
<string>fbauth2</string>
<string>fb-messenger-api20140430</string>
<string>fb-messenger-platform-20150128</string>
<string>fb-messenger-platform-20150218</string>
<string>fb-messenger-platform-20150305</string>
아래 코드로 시도해 볼 수 있습니다. swift 5.0
extension Bundle {
static let externalURLSchemes: [String] = {
guard let urlTypes = main.infoDictionary?["LSApplicationQueriesSchemes"]
as? [String] else {
return []
}
return urlTypes
}()
}
사용하여 전화 할 수 있습니다 Bundle
guard Bundle.externalURLSchemes.contains(URLScheme) else {
return
}