iOS 9中Info.plist文件缺少“fbauth2”内容

147
FBSDKLog: fbauth2 is missing from your Info.plist under LSApplicationQueriesSchemes and is required for iOS 9.0

你知道这是什么吗?我已经在我的plist文件中添加了它,但并没有起作用。

9个回答

348

如果您在构建iOS 9应用程序时仍想使用URL方案来调用URL方案,则现在需要在应用程序的Info.plist文件中声明它们。新增了一个键LSApplicationQueriesSchemes,您需要在此处添加要在canOpenURL上使用的方案列表。

试试这样做。

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbauth2</string>
</array>

1
谢谢,伙计。我以为只有在构建到iOS9设备时才需要这样做。 - Felipe
xml复制/粘贴版本,可以吗? :D - Christopher Francisco
20
为什么这些信息没有出现在 iOS 快速入门指南中?https://developers.facebook.com/quickstarts/926602334080849/?platform=ios - Paweł Brewczynski
LSApplicationQueriesSchemes - 这样你就可以复制粘贴,而不是从屏幕上复制。 - sam_smith
1
@PaulBrewczynski 我不知道为什么它没有在快速入门指南中,但我在这里的文档中找到了它:https://developers.facebook.com/docs/ios/ios9 - TMin

25
如果您使用的是iOS9系统,则需要更新info.plist文件。您只需要完成以下3个步骤: 1. 进入info.plist文件; 2. 添加一个LSApplicationQueriesSchemes字段,数据类型为NSArray; 3. 添加一个NSString类型的项,名称为“fbauth2”。
这样就可以了。清理并运行后,警告将不会再出现。enter image description here

我正在Xcode 7.1下运行此程序,但使用的是运行iOS 8.1的iPhone 6 Plus模拟器。这不应该出现,对吗? - Jerome Chan Yeow Heong

21

针对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>

链接: https://developers.facebook.com/docs/ios/ios9


1
https://developers.facebook.com/docs/ios/getting-started/ 没有告诉你要做这个,很好你指出来了! - James111


5
请不要将此添加到您的CFBundleURLSchemes中...这实际上会劫持任何应用程序尝试进行Facebook身份验证的操作,导致弹出窗口显示“X应用程序想要打开”对话框...
您不想这样做。
参考:
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

2

当我在运行Kiwi测试时,由于我们的测试目标无法访问主要束,所以我不得不在FBSDKInternalUtility.m中的isRegisteredCanOpenURLScheme中添加一个条件。

+ (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];
}

这对我也起作用了。其他方法都行不通。我认为我们必须修改Facebook的代码,这似乎很奇怪,因为当FB更新他们的Cocoapods时,代码会被覆盖。 - user2285278

1

如何为 iOS 9 构建您的应用程序:(针对 Facebook 分享)

  1. 打开 Info.plist 文件,在 Information Property List 下添加另一个字段 LSApplicationQueriesSchemes,并将其数据类型设置为 ArrayNSArray
  2. LSApplicationQueriesSchemes 添加 3 个项目,并将它们的数据类型设置为 StringNSString
  3. 将项目值分别设置为 fbauth2fbshareextensionfbapi

请按照以下图片操作:

enter image description here


0
您可以在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
}

0
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>

1
过时了。新的SDK需要更少的内容。 - makerofthings7

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接