I will try to be clear in my problem. I want to enable facebook sharing in my swift app (Swift 3). When the user clicks the link on facebook, he should be redirected on the app (if he has it) on app store (if he is on iOS and doesn't have app) or another website for other case.
Facebook provides a simple tool to do that : App Links : https://developers.facebook.com/docs/applinks
So then I just had to create on my ios project a FBSDKShareLinkContent
class and give it the appLink url, a title, a description and an image :
let content:FBSDKShareLinkContent = FBSDKShareLinkContent()
content.contentURL = NSURL(string: linkURL)
content.contentTitle = nsTitle as! String
content.contentDescription = nsDesc as! String
content.imageURL = NSURL(string: imageURL)
But facebook change it's way to share content. The properties contentTitle
, contentDescription
and imageURL
are now read only and deprecated :
/**
The URL of a picture to attach to this content.
- Returns: The network URL of an image
@deprecated `imageURL` is deprecated from Graph API 2.9.
For more information, see https://developers.facebook.com/docs/apps/changelog#v2_9_deprecations
*/
@available(*, deprecated, message: "`imageURL` is deprecated from Graph API 2.9")
open var imageURL: URL! { get }
Now facebook uses metas from the contentURL
website to show image, title and description.
The problem is that the url given by facebook app link soen not provite any title, description or image data, here is the http reponse :
<html>
<head>
<title>Mowwgli</title>
<meta property="fb:app_id" content="1786124768326289" />
<meta property="al:ios:url" content="mowwgli://" />
<meta property="al:ios:app_name" content="Mowwgli" />
<meta property="al:ios:app_store_id" content="1184953498" />
<meta property="al:web:should_fallback" content="false" />
<meta property="al:web:url" content="http://www.mowwgli.com/" />
<meta http-equiv="refresh" content="0;url=http://www.mowwgli.com/" />
</head>
</html>
Then the sharing does not show any image title or description :