Skip to content

Latest commit

 

History

History
64 lines (48 loc) · 2.3 KB

SharingContent.md

File metadata and controls

64 lines (48 loc) · 2.3 KB

Sharing Content in Facebook

Android Considerations

If you're sharing links, images or video via the Facebook for Android app, you also need to declare the FacebookContentProvider in the manifest.

Append your app id to the end of the authorities value. For example if your Facebook app id is 1234, the declaration looks like:

<provider android:authorities="com.facebook.app.FacebookContentProvider1234"
          android:name="com.facebook.FacebookContentProvider"
          android:exported="true" />

Testing Sharing Content

If your app is public on Facebook developer portal, you should be able to test sharing with any users. In case it isn't yet public then you need to add the users you want to be able to test sharing:

Add your testers

Testers

Share content types

You can share 3 types of content:

  • FacebookSharePhotoContent - Photos
  • FacebookShareLinkContent - Link
  • FacebookShareVideoContent - Video

Simple photo share

 await CrossFacebookClient.Current.SharePhotoAsync(myPhotoBytes, captionText);

Share Photo using bytes

FacebookSharePhoto photo = new FacebookSharePhoto(text, image);
FacebookSharePhoto[] photos = new FacebookSharePhoto[] { photo };                    
FacebookSharePhotoContent photoContent = new FacebookSharePhotoContent(photos);
await CrossFacebookClient.Current.ShareAsync(photoContent);

Share Photo using url

FacebookSharePhoto photo = new FacebookSharePhoto(text, imageUrl);
FacebookSharePhoto[] photos = new FacebookSharePhoto[] { photo };                    
FacebookSharePhotoContent photoContent = new FacebookSharePhotoContent(photos);
 await CrossFacebookClient.Current.ShareAsync(photoContent);

Share Link

FacebookShareLinkContent linkContent = new FacebookShareLinkContent("awesome plugins",new Uri( "http://www.github.com/crossgeeks"));
var ret = await CrossFacebookClient.Current.ShareAsync(linkContent);

Share Video

FacebookShareVideo video = new FacebookShareVideo(videoPath);
FacebookShareVideoContent videoContent = new FacebookShareVideoContent(video);
await CrossFacebookClient.Current.ShareAsync(videoContent);

<= Back to Table of Contents