Facebook share button on iOS 9 opens browser instead of Facebook’s own application

My application uses FBSDKShareButtonone that launches a pop-up window from its own Facebook application on iOS 8. However, on iOS 9 it launches a browser window, although I followed all the instructions for supporting iOS 9 here and added the necessary one LSApplicationQueriesSchemes(and recompiled for iOS 9).

I continue to read that it is “by design” that the facebook login opens a browser instead of its own application on iOS 9, but there is no information on why / whether the sharing button should launch its own application. It appears that the FBSDKShareDialognative application ( ) dialog does indeed launch its own application, but I would like it if I hadn't used my own button.

And the secondary question is: if I use my own button and run FBSDKShareDialog, I get the following errors in the log (although the actual sharing works fine). Why?

-canOpenURL: failed URL: "fbapi20150629: ///" - error: "This application is not allowed to request for the fbapi20150629 schema"

plugin com.apple.share.Facebook.post is invalid

I use the latest SDK for Facebook (v4.6), so a link to the URL scheme is not needed. I am compiling with Xcode 7.0.1.

+4
source share
4 answers

I believe the problem is with FBSDKShareButton creating FBSDKShareDialog without ViewController. Thus, without VC, he reverts to using the Safari view for sharing. :( You can see this behavior in the FB SDK source here:

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

FBSDKShareButton, , sharecheet ( ) FBSDKShareButton:

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

, fbapi20150629, - .:)

+2

FBSDKShare, iOS 9, swift2.0

: Facebook Share content URL-, iTunes, . URL- iTunes , .

, FB Share , , , , - .

, URL, , URL- iTunes. 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()
     }
+1

, . , 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)

, .

+1

: Facebook URL- iOS 9

: , SDK Facebook (4.6.0), "fbapi20150629" p.list( "Whitelist Facebook Apps" ).

0
source

Source: https://habr.com/ru/post/1611312/


All Articles