Search code examples
iosswiftfacebookfbsdksharekit

Shared image open URL on tap


I'm using - FBSDKShareKit (4.40.0): I want to share image on facebook. It should be tappable and should open website just like the Endomondo app does.

enter image description here I've tried this code but url covers photo and they are not displayed:

    let sharePhoto = FBSDKSharePhoto()
    sharePhoto.image = someImage

    let content = FBSDKSharePhotoContent()
    content.photos = [sharePhoto];
    content.contentURL = URL(string: "https://facebook.com")!
    FBSDKShareDialog.show(from: self, with: content, delegate: nil)

How they do that?


Solution

  • It appears that @04FS is right. It is just an og:image. They send the picture to the server and then generate a page with html meta og tags. (There is a redirect between so it was not obvious for me)

    <meta property="fb:app_id" content="202423869273" />
    <meta property="al:ios:url" content="endoapp://workouts" />
    <meta property="al:ios:app_store_id" content="333210180" />
    <meta property="al:ios:app_name" content="Endomondo Sports Tracker" />
    <meta property="al:android:class" content="com.endomondo.android.EndoSplash" />
    <meta property="al:android:package" content="com.endomondo.android" />
    <meta property="al:android:app_name" content="Endomondo Sports Tracker" />
    <meta property="og:type" content="endoapp:workout" />
    <meta property="og:url" content="https://www.endomondo.com/users/11394222/workouts/1278713145?country=pl&lang=en&measure=metric" />
    <meta property="og:title" content="0.02 km run" />
    <meta property="og:description" content="(brak nazwy) ran 0.02 km using Endomondo." />
    <meta property="og:locale" content="en_US" />
    <meta property="og:site_name" content="Endomondo" />
    <meta property="og:determiner" content="auto" />
    <meta property="og:image" content="https://www.endomondo.com/resources/gfx/image/69040478/06074879f4cd011f6b7b8cfa028e146b/big.jpg" />
    <meta property="og:image:width" content="1200" />
    <meta property="og:image:height" content="630" />
    <meta property="endoapp:duration" content="38" />
    <meta property="endoapp:distance" content="0.02" />
    <meta property="endoapp:sport" content="https://www.endomondo.com/facebook/sport/0?country=pl&lang=en&measure=metric" />
    <meta property="endoapp:unit" content="km" />
    <meta property="endoapp:maxspeed" content="6.4" />
    <meta property="endoapp:avgspeed" content="1.5" />
    <meta property="endoapp:avg_speed" content="39:16" />
    <meta property="endoapp:avg_speed_unit" content="min/km" />
    <meta property="endoapp:calories" content="2" />
    <meta property="endoapp:route:latitude" content="54.19036" />
    <meta property="endoapp:route:longitude" content="16.17868" />
    <meta property="endoapp:route:altitude" content="0.01" />
    <meta property="endoapp:route:latitude" content="54.19023" />
    <meta property="endoapp:route:longitude" content="16.17856" />
    <meta property="endoapp:route:altitude" content="0.01" />