Share FBSDKShareLinkContent
with FBSDKShareDialog
works fine in iOS 8 but fails to share imageURL
, contentTitle
, contentDescription
on iOS 9 devices.
The app is built with iOS 9 SDK, Xcode 7, Facebook SDK 4.7.0, all actions mentioned in Preparing Your Apps for iOS9 are done. The app is currently not available in App Store and Facebook app is in dev mode.
The code to present the dialog is pretty common (Swift 2.0):
let content = FBSDKShareLinkContent()
content.contentURL = <URL to the app in the App Store>
content.imageURL = <valid image URL>
content.contentTitle = <some title>
content.contentDescription = <some descr>
let shareDialog = FBSDKShareDialog()
shareDialog.fromViewController = viewController
shareDialog.shareContent = content
shareDialog.delegate = self
if !shareDialog.canShow() {
print("cannot show native share dialog")
}
shareDialog.show()
On iOS 9 Facebook SDK presents native dialog with no image, title and description:
At the time the dialog is presented, when the FB app is installed on iOS 9 device, there is an error, which when resolved by adding respective URL to Info.plist does not fix the issue. It is just the log statement that does not appear anymore.
-canOpenURL: failed for URL: "fbapi20150629:/" - error: "This app is not allowed to query for scheme fbapi20150629"
This results in an empty post:
On iOS 8, though, the dialog is presented via FB app OR opens in-app Safari vc when FB app is not installed.
For the comparison sake, the same code works from iOS 8 devices:
UPDATE:
While @rednuht's answer below solves the initial issue, it worth noting about AppStore URL-specific case pointed out by @sophie-fader
question from:
https://stackoverflow.com/questions/33148544/facebook-share-content-only-shares-url-in-ios-9 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…