簡體   English   中英

iOS 9上的Facebook共享按鈕打開瀏覽器而不是本機Facebook應用程序

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

我的應用程序使用一個FBSDKShareButton ,這將啟動從iOS上的8原生的Facebook應用程序的彈出然而,在iOS 9中啟動一個瀏覽器窗口,即使我已經照着所有的說明支持的iOS 9 這里並添加了必要的LSApplicationQueriesSchemes (並重新編譯為iOS 9)。

我一直在閱讀它是“按設計”,Facebook 登錄打開瀏覽器而不是iOS 9上的本機應用程序,但沒有關於為什么/是否應該啟動本機應用程序的共享按鈕的信息。 看來共享對話框FBSDKShareDialog )確實啟動了本機應用程序,但如果可以,我想避免使用我自己的按鈕。

第二個問題:如果我使用自己的按鈕並啟動FBSDKShareDialog ,我會在日志中收到以下錯誤(盡管實際共享似乎工作正常)。 為什么?

-canOpenURL:URL失敗:“fbapi20150629:///” - 錯誤:“此應用程序不允許查詢方案fbapi20150629”

插件com.apple.share.Facebook.post無效

我正在使用最新的Facebook SDK(v4.6),因此不需要引用的URL方案。 我正在使用Xcode 7.0.1進行編譯。

我認為問題是由於FBSDKShareButton在沒有ViewController的情況下構建了一個FBSDKShareDialog。 因此,如果沒有VC,它將回歸到使用Safari視圖進行共享。 :(你可以在這里看到FB SDK源代碼中的這種行為:

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

我已經將FBSDKShareButton子類化為直接啟動對話框,它正確地為我使用了shareheet,只需要少量的覆蓋代碼,並保持FBSDKShareButton的原生外觀(和本地化):

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

不幸的是,我對fbapi20150629警告沒有答案,我試圖尋找答案的原因是我在這里。 :)

FBSDKShare,iOS 9,swift2.0

對於第一個問題:Facebook共享內容可以與iTunes共享內容描述以外的網址。 如果共享iTunes網址,則不會分享我們的說明。

我遇到了同樣的問題,FB Share按鈕點擊將我重定向到瀏覽器,我正在使用的解決方法是將Share Dialog模式設置為使用本機應用程序。

如果您要共享的URL是iTunes App Store URL,則會一致地發生這種情況。 將URL更改為任何其他網站解決了該問題。 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()
     }

我不確定這會解決你的問題。 說實話,我並不是非常清楚地理解這個API的工作原理 - 只是一個可行的知識......但也許這會有所幫助。

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

對於使用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>

在我的情況下,它擺脫了這個錯誤:

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

並沒有擺脫這個消息:

plugin com.apple.share.Facebook.post invalidated

(我使用的是最新的SDK,高於v4.5)

希望這是一些幫助。

對於您的第一個問題: Facebook共享內容僅在iOS 9中共享URL

對於你的第二個問題:即使我有新的Facebook SDK(4.6.0),也發生在我身上,我還將字符串“fbapi20150629”添加到p.list(“Whitelist Facebook Apps”)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM