Android: Facebook share content is empty

I have a Xamarin Forms App. Which I created a FBShareButton : Button to handle the sharing via custom renderers. This is the code in my renderer:

public class FacebookShareRenderer : ButtonRenderer
{   
    ShareButton sb;
    protected override void OnElementChanged (ElementChangedEventArgs<Xamarin.Forms.Button> e)
    {
        base.OnElementChanged (e);
        sb = new ShareButton(Context);

        this.Control.Click += (sender, eargs) => sb.PerformClick();
        sb.Click += (sender, eargs) => {
                ShareLinkContent.Builder shareLinkContentBuilder = new ShareLinkContent.Builder().
                    SetContentDescription("Hello").
                    SetContentTitle("Desc");
                shareLinkContentBuilder.SetImageUrl("url");
                ShareLinkContent shareLinkContent = shareLinkContentBuilder.Build();
                sb.ShareContent = shareLinkContent;
            }
        };
    }
}

The share dialog opens and asks me to right something as I supposed to. However, the content does not appear and when I share they do not show. Any ideas?

Answers

  • MarioMaqueoMarioMaqueo MXMember

    Hello, I believe your problem must be the same as this:
    https://forums.xamarin.com/discussion/62245/xamarin-facebook-sdk-sharing-problem
    Which can be solved easily as stated in that thread if the user has the Facebook app installed, but if he doesn't, then the solution doesn't work. Please comment in that thread if you have found a solution :/

  • EgeAydinEgeAydin TRMember

    I did find a solution actually. However, I don't have my mac at the moment and I won't have it for a while. If I remember correctly it was because SetContentUrl or something similar like that has to be set too otherwise it appears empty. I hope this helps. If I get a chance to look in to my mac, which very unlikely, I will give you the correct solution. for the time being I hope this helps.

  • MarioMaqueoMarioMaqueo MXMember

    Unfortunately, even with SetContentUrl the problem isn't solved in my case. What happens is the link gets posted, but as I described in that other thread, the title and description that had been set disappear and a new title and description gotten from the Url are shown.
    But thanks.

  • EgeAydinEgeAydin TRMember

    I will try to check my code and return back to you.

  • LakshyaLakshya Member ✭✭✭

    @EgeAydin Could you please share the code..

Sign In or Register to comment.