简体   繁体   English

iOS 9上的Facebook共享按钮打开浏览器而不是本机Facebook应用程序

[英]Facebook share button on iOS 9 opens browser instead of native Facebook app

My app uses an FBSDKShareButton , which launches a popup from the native Facebook app on iOS 8. However, on iOS 9 it launches a browser window, even though I've followed all the instructions for supporting iOS 9 here and added the necessary LSApplicationQueriesSchemes (and recompiled for iOS 9). 我的应用程序使用一个FBSDKShareButton ,这将启动从iOS上的8原生的Facebook应用程序的弹出然而,在iOS 9中启动一个浏览器窗口,即使我已经照着所有的说明支持的iOS 9 这里并添加了必要的LSApplicationQueriesSchemes (并重新编译为iOS 9)。

I keep reading that it's "by design" that the facebook login opens a browser instead of the native app on iOS 9, but there's no info on why/whether the share button is supposed to launch the native app. 我一直在阅读它是“按设计”,Facebook 登录打开浏览器而不是iOS 9上的本机应用程序,但没有关于为什么/是否应该启动本机应用程序的共享按钮的信息。 It appears that the share dialog ( FBSDKShareDialog ) indeed launches the native app, but I'd like to avoid using my own button if I can. 看来共享对话框FBSDKShareDialog )确实启动了本机应用程序,但如果可以,我想避免使用我自己的按钮。

And a secondary question: if I do use my own button and launch an FBSDKShareDialog , I get the following errors in the log (although the actual sharing seems to work fine). 第二个问题:如果我使用自己的按钮并启动FBSDKShareDialog ,我会在日志中收到以下错误(尽管实际共享似乎工作正常)。 Why? 为什么?

-canOpenURL: failed for URL: "fbapi20150629:///" - error: "This app is not allowed to query for scheme fbapi20150629" -canOpenURL:URL失败:“fbapi20150629:///” - 错误:“此应用程序不允许查询方案fbapi20150629”

plugin com.apple.share.Facebook.post invalidated 插件com.apple.share.Facebook.post无效

I'm using the latest Facebook SDK (v4.6), so the referenced URL scheme should not be necessary. 我正在使用最新的Facebook SDK(v4.6),因此不需要引用的URL方案。 I'm compiling with Xcode 7.0.1. 我正在使用Xcode 7.0.1进行编译。

I believe the problem is due to the FBSDKShareButton constructing a FBSDKShareDialog without a ViewController. 我认为问题是由于FBSDKShareButton在没有ViewController的情况下构建了一个FBSDKShareDialog。 And so without the VC, it is falling back to using the Safari view for sharing. 因此,如果没有VC,它将回归到使用Safari视图进行共享。 :( You can see this behavior in the FB SDK source here: :(你可以在这里看到FB SDK源代码中的这种行为:

https://github.com/facebook/facebook-ios-sdk/blob/fe777bd7a8b335c5780e2ee160d81719e132e76c/FBSDKShareKit/FBSDKShareKit/FBSDKShareButton.m https://github.com/facebook/facebook-ios-sdk/blob/fe777bd7a8b335c5780e2ee160d81719e132e76c/FBSDKShareKit/FBSDKShareKit/FBSDKShareButton.m

I've subclassed FBSDKShareButton to launch a dialog directly, which correctly uses the sharesheet for me, with a minimal amount of overriding code, and maintains the native look and feel (and localization) of the FBSDKShareButton: 我已经将FBSDKShareButton子类化为直接启动对话框,它正确地为我使用了shareheet,只需要少量的覆盖代码,并保持FBSDKShareButton的原生外观(和本地化):

public class EventShareButton: FBSDKShareButton {
    func _share(sender: AnyObject) {
        FBSDKShareDialog.showFromViewController(parentViewController(), withContent: shareContent, delegate: nil)
    }
}

Unfortunately, I have no answer to the fbapi20150629 warning, and my attempts to search for an answer are what led me here. 不幸的是,我对fbapi20150629警告没有答案,我试图寻找答案的原因是我在这里。 :) :)

FBSDKShare , with iOS 9 , swift2.0 FBSDKShare,iOS 9,swift2.0

For first question: Facebook Share content can share url other than iTunes with content description. 对于第一个问题:Facebook共享内容可以与iTunes共享内容描述以外的网址。 If iTunes url is shared it wont share our description. 如果共享iTunes网址,则不会分享我们的说明。

I was having the same issue, FB Share button clicking redirects me to browser and the workaround I'm using is to set the Share Dialog mode to use the native app. 我遇到了同样的问题,FB Share按钮点击将我重定向到浏览器,我正在使用的解决方法是将Share Dialog模式设置为使用本机应用程序。

This occurs consistently if the URL you are sharing is an iTunes App Store URL. 如果您要共享的URL是iTunes App Store URL,则会一致地发生这种情况。 Changing the URL to any other website solved the problem. 将URL更改为任何其他网站解决了该问题。 https://developers.facebook.com/docs/sharing/ios "Note: If your app share links to the iTunes or Google Play stores, we do not post any images or descriptions that you specify in the share. Instead we post some app information we scrape from the app store directly with the Webcrawler. This may not include images. To preview a link share to iTunes or Google Play, enter your URL into the URL Debugger." https://developers.facebook.com/docs/sharing/ios “注意:如果您的应用程序共享指向iTunes或Google Play商店的链接,我们不会发布您在共享中指定的任何图像或说明。相反,我们会发布一些我们直接使用Webcrawler从应用程序商店中搜索的应用程序信息。这可能不包括图像。要预览链接共享到iTunes或Google Play,请在URL调试器中输入您的URL。

     func shareFB(sender: AnyObject) {
        let content : FBSDKShareLinkContent = FBSDKShareLinkContent()

        content.contentURL = NSURL(string: "http://google.com")
        content.contentTitle = “MyApp”
        content.contentDescription = “//Desc“

        content.imageURL = NSURL(string:“//Image URL”)


        let dialog : FBSDKShareDialog = FBSDKShareDialog()
        dialog.mode = FBSDKShareDialogMode.Native
      // if you don't set this before canShow call, canShow would always return YES
        if !dialog.canShow() {
            // fallback presentation when there is no FB app
          dialog.mode = FBSDKShareDialogModeFeedBrowser
         }
        dialog.show()
     }

I am not certain that this solves your problem. 我不确定这会解决你的问题。 To be honest I don't really understand the workings of this API very clearly - just a workable knowledge... but maybe this helps. 说实话,我并不是非常清楚地理解这个API的工作原理 - 只是一个可行的知识......但也许这会有所帮助。

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

For apps using the SDK v4.5 and earlier, insert the following into the app's info.plist 对于使用SDK v4.5及更早版本的应用,请将以下内容插入应用的info.plist

<key>LSApplicationQueriesSchemes</key>
<array>
    <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>
</array>

In my case, it got rid of this error: 在我的情况下,它摆脱了这个错误:

-canOpenURL: failed for URL: "fbapi20150629:///" - error: "This app is not allowed to query for scheme fbapi20150629"

and did not get rid of this message: 并没有摆脱这个消息:

plugin com.apple.share.Facebook.post invalidated

(I am using the latest SDK, above v4.5) (我使用的是最新的SDK,高于v4.5)

Hope this is of some assistance. 希望这是一些帮助。

For your first question: Facebook share content only shares URL in iOS 9 对于您的第一个问题: Facebook共享内容仅在iOS 9中共享URL

For your secondary question: It happened to me even though I have the new Facebook SDK (4.6.0), I added the string "fbapi20150629" also to the p.list ("Whitelist Facebook Apps"). 对于你的第二个问题:即使我有新的Facebook SDK(4.6.0),也发生在我身上,我还将字符串“fbapi20150629”添加到p.list(“Whitelist Facebook Apps”)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以生成一个“在 Facebook 上分享”链接,在 Android/iOS/手机上打开原生 Facebook 应用程序而不是网络共享对话框? - Is it possible to generate a 'share on Facebook' link that opens the native Facebook App on Android/iOS/mobile instead of the web share dialog? “在Facebook上共享”打开我的应用 - “Share on facebook” opens my app iOS 6上的本机Facebook分享 - Native Facebook share on iOS 6 Facebook App邀请打开SafariViewController而不是本机应用 - Facebook App Invites opens SafariViewController instead of Native app 将Facebook添加为iOS应用的“共享”按钮 - Adding Facebook as a Share button for iOS app Facebook SDK打开SafariViewController而不是Facebook应用程序 - Facebook SDK opens SafariViewController instead of Facebook app iOS Facebook登录而无需打开浏览器或本机Facebook App - iOS Facebook Login Without Opening Browser or native Facebook App 点赞按钮可打开Facebook应用 - Like button that opens Facebook app iOS:通过UIWebView共享链接打开Facebook本机应用程序 - iOS: Open Facebook native app from UIWebView share link 将用户重定向到iOS Facebook应用进行身份验证,而不是浏览器窗口 - Redirecting user to iOS facebook app for authentication instead of browser window
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM