ios Facebook SDK:应用程序未注册为 URL Scheme
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21893447/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Facebook SDK: app not registered as a URL Scheme
提问by L. Desjardins
I am using the Facebook SDK
found here, and am trying the sample that is provided (in the folder FacebookiOSSample
).
我正在使用Facebook SDK
found here,并且正在尝试提供的示例(在文件夹中FacebookiOSSample
)。
If I simply replace the AppId
here with my specific AppId
, then I can no longer Share. (I replaced it in both the AppDelegate
file and the info.plist
file). I now receive the following error:
如果我只是AppId
用我的特定替换here AppId
,那么我就不能再分享了。(我在AppDelegate
文件和info.plist
文件中都替换了它)。我现在收到以下错误:
FBSDKLog: Invalid use of FBAppCall, fb**** is not registered as a URL Scheme. Did you set 'FacebookUrlSchemeSuffix' in your plist?
FBSDKLog:FBAppCall 的使用无效,fb**** 未注册为 URL Scheme。您是否在 plist 中设置了“FacebookUrlSchemeSuffix”?
Otherwise this works fine with the sample's original AppId
which points to something named IFaceTouch
.
否则,这适用于AppId
指向名为IFaceTouch
.
What could be wrong with the setup of my app, how do I register my AppId
?
我的应用程序设置可能有什么问题,如何注册我的应用程序AppId
?
回答by RaffAl
Follow these three steps:
请遵循以下三个步骤:
- Create a key called FacebookAppIDwith a string value, and add the app ID there.
- Create a key called FacebookDisplayNamewith a string value, and add the Display Name you configured in the App Dashboard.
- Create an array key called URL types with a single array sub-item called URL Schemes. Give this a single item with your app ID prefixed with fb. This is used to ensure the application will receive the callback URLof the web-based OAuth flow.
- 使用字符串值创建一个名为FacebookAppID的键,并在其中添加应用程序 ID。
- 使用字符串值创建一个名为FacebookDisplayName的键,并添加您在 App Dashboard 中配置的显示名称。
- 使用名为URL Schemes的单个数组子项创建一个名为 URL types 的数组键。使用您的应用 ID 以 fb 为前缀,为它提供一个单独的项目。这用于确保应用程序将接收基于 Web 的 OAuth 流的回调URL。
The finished .plist should look something like this:
完成的 .plist 应该是这样的:
回答by clearwater82
In terms of raw keys and values you should have CFBundleURLTypes and CFBundleURLSchemes. Hope that helps!
就原始键和值而言,您应该有 CFBundleURLTypes 和 CFBundleURLSchemes。希望有帮助!
回答by Aviram Netanel
there is another section below the info - URL Types
信息下方还有另一部分 - URL 类型
check that the values there, under the URL Schemesfield match the value in the URL types -> URL Schemesin the property list above. (and also match the FacebookAppID)
检查URL Schemes字段下的值是否与上面属性列表中的URL types -> URL Schemes中的值匹配。(也匹配 FacebookAppID)
回答by JeffersonBe
For iOS 9
对于 iOS 9
If you have an error: 'LSApplicationQueriesSchemes'
如果出现错误:'LSApplicationQueriesSchemes'
Based on Bear with me answer, you will also have to add those lines:
根据Bear with me 的回答,您还必须添加以下几行:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbauth2</string>
</array>
See this.
看到这个。
You shouldend up with those lines at the end of your .plist files:
您应该在 .plist 文件的末尾使用这些行:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb2R3234544534554</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>2R3234544534554</string>
<key>FacebookDisplayName</key>
<string>stevejeff</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>facebook.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>fbcdn.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>akamaihd.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbauth2</string>
</array>
</dict>
</plist>
* If you're using v4.6.0 or higher of the SDK, you only need to add:*(Thanks mohsinj)
* 如果您使用的是 v4.6.0 或更高版本的 SDK,您只需要添加:*(感谢 mohsinj)
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
回答by Mahgol Fa
1- In Xcode, right-click your project's Info.plist file and select Open As -> Source Code.
1- 在 Xcode 中,右键单击项目的 Info.plist 文件并选择 Open As -> Source Code。
2- Insert the following XML snippet into the body of your file just before the final </dict>
element.
2- 将以下 XML 片段插入文件正文的最后一个</dict>
元素之前。
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb{your-app-id}</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>{your-app-id}</string>
<key>FacebookDisplayName</key>
<string>{your-app-name}</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-share-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
3- Replace {your-app-id}, and {your-app-name} with your app's App's ID and name found on the Facebook App Dashboard.
3- 将 {your-app-id} 和 {your-app-name} 替换为在 Facebook 应用仪表板上找到的应用的应用 ID 和名称。
回答by ZAFAR007
回答by Krutarth Patel
Today i solved this bug by just removing space from FacebookDisplayName.
今天我通过从FacebookDisplayName 中删除空间解决了这个错误。
make sure you don't have any space in FacebookDisplayName
确保FacebookDisplayName 中没有任何空格
回答by Daniel Vilela
I don't know if your problem is the same as mine. But it took me some time to find it and i will put it here so that it can help anyone.. The problem was that google sign in used the same info.plist attribute name and it was overriding the ones of facebook.. So i could see this in X-Code and put them together, now everything works fine! (URL Types attribute).
不知道你的问题是否和我的一样。但是我花了一些时间才找到它,我会把它放在这里,以便它可以帮助任何人。可以在 X-Code 中看到这一点并将它们放在一起,现在一切正常!(URL 类型属性)。
回答by sugeet goyal
I was also facing same issue. Then did this:
我也面临同样的问题。然后做了这个:
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb154510174913175</string>
<string>fbauth2</string> // add this line to remove the error
</array>
</dict>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb154510174913175</string>
<string>fbauth2</string> // add this line to remove the error
</array>
</dict>
and issue is fixed now.
现在问题已解决。