回答:
iOS 9向けにアプリをビルドし、URLスキームを呼び出したい場合は、URLスキームを引き続き使用できます。これで、アプリをInfo.plistで宣言する必要があります。新しいキーであるLSApplicationQueriesSchemesがあり、ここでcanOpenURLにしたいスキームのリストを追加する必要があります。
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbauth2</string>
</array>
iOS9を使用している場合は、info.plistファイルを更新することが重要です。3つの手順を実行するだけで済みます。1. 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
、これを行うことをあなたに伝えます、あなたがそれを指摘したのは良いことです!
Facebookの説明に従ってください:iOS9のためのアプリの準備
Appleはそれについて言及しています:プライバシーとアプリの基調講演2015
これをCFBundleURLSchemesに追加しないでください... Facebookの認証でアプリの試行が実際にハイジャックされ、ポップアップに「Xアプリが開こうとしています」ダイアログが表示されます...
あなたはそれをしたくありません。
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
テストターゲットがメインバンドルにアクセスできなかったため、Kiwiテストを実行したときにこれを取得しました。だから私はに条件を追加する必要があり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
}