my app has mobile only content. It uses hosted urls to refer to the content (http://fb.me/CANONICAL_ID) that only opens in app. like the ones shown on (https://developers.facebook.com/docs/applinks/hosting-api). After fetching the canonical url from my server. The facebook dialog box is suppose to share it like so:
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
[content setContentURL:[NSURL URLWithString:canonical_urlString]];
[content setContentTitle:appName]; //ignored??
[content setImageURL:[NSURL URLWithString:thumbnailUrlString]];//ignored??
[content setContentDescription:caption];//ignored??
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:nil];
when i share, the post only has the fb.me link and it ignores the thumbnail assigned above, the title and the description.
Why can`t i share the link with the content attributes assigned?
Any suggestion will help.
Related
In my app, I am using SLComposeViewController to post images on Facebook app, which works fine. Requirement is, if the Facebook app is not installed, I would like to open the web page and allow user to post the image though web. Please anyone can advise how to post the image on Facebook web? I have iOS 9 and above with Xcode 8.1.
Use Facebook SDK for post image to facebook. You can find code and documentation here:
https://developers.facebook.com/docs/sharing/ios
Facebook SDK will handle all types of exception and scenario.
If Facebook app is not installed. but you FB accounts synced with setting app in your iPhone.
you can use below code to share the photo. But it will not open web browser.
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = img; // your image
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = #[photo];
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:self];
To share via web browser, you can use below code.
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.imageURL = [NSURL URLWithString:img]; // image url
[FBSDKShareDialog showFromViewController:self.viewController
withContent:content
delegate:self];
In one of our app, we are supposed to give an option to share newly unlocked Achievement. Requirement also includes to post defined text if share box is empty.
The problem is, we are unable to find relevant delegate method when user clicks on POST/Send button.
Code for posting status is,
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:awardToBeShareOnFB];
content.contentTitle = #"Helloworld";
content.contentDescription = #"Helloworld";
[FBSDKShareDialog showFromViewController:[self parentViewController]
withContent:content
delegate:self];
It should post "Helloworld" as a status if posting box is empty.
In facebook SDK 3.x it was possible to use the share dialog to add a caption. Is this feature available in 4.x? Should the caption now be part of the web page the share is pointing to?
As of right now, the caption being shown is just the weblink.
Here's some code to clarify question:
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:#"www.google.com"];
content.contentDescription = #"2-4 sentences of description.";
content.contentTitle = #"Title";
content.contentCaption = ?
shareDialog.shareContent = content;
shareDialog.delegate = self;
[shareDialog show];
Note - obviously there is no 'contentCaption' setter but maybe it's a property? Not sure if it's even available anymore but figured I would ask.
I am using Facebook sdk v4.10.1 now and this is work for me.
[content setValue:#{#"caption":#"?"} forKey:#"feedParameters"];
It seems Facebook has recently broken (or intentionally removed?) the ability to share images and links in one post via their share extension, trying to share an image with a link now results in only the image posting. Sharing only the link works and generates a post with an image preview of the linked page.
Previously you could share images and links in one post, is there a way to restore this functionality with the after Facebook app v29?
Here's a brief sample that illustrates what previously worked, but now only shares the image.
NSArray *activityItems = #[
[NSURL URLWithString:#"http://stackoverflow.com/"],
[UIImage imageNamed:#"shareImage"]
];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:nil];
Update
- Facebook has acknowledged this as a bug
As per Facebook latest SDK v4.0.1. we can surely share image and link but not both at same time.
Sharing URL Link and image URL (not Image):-
FBSDKShareLinkContent model includes attributes that show up in the post:
contentURL - the link to be shared
contentTitle - represents the title of the content in the link
imageURL - the URL of thumbnail image that appears on the post
contentDescription - of the content, usually 2-4 sentences
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:#"http://google.com"];
content.imageURL=[NSURL URLWithString:#"http://nasa.org/a.jpg"];
content.contentTitle=#"Facebook Share";
content.contentDescription=#"Lets see, How my share works guyz..";
[FBSDKShareDialog shareFromViewController:self
withContent:content
delegate:nil];
Sharing Only Image:-
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = self.imgView.image;// you can edit it by your choice
photo.userGenerated = YES;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = #[photo];
I am using Facebook SDK 4.0,https://developers.facebook.com/docs/sharing/ios#share_dialog
I am using FBSDKShareDialog to share Photo.It does share Photo if user has installed Facebook app,
But it fails when user hasn't installed FB App. but they say "If someone doesn't have Facebook app installed it will automatically falls back to a web-based dialog."
Idk whats wrong please help me in sharing photo using FBSDK 4.0.
My code is
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = self.capturedImageView.image;
photo.userGenerated = YES;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = #[photo];
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:self];
This is error report
error:"com.facebook.sdk:FBSDKErrorArgumentNameKey=shareContent,
com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Feed share dialogs
support FBSDKShareLinkContent."
FBSDKShareDialog only supports FBSDKShareLinkContent to post image or URL.So to use share Dialog you have to use FBSDKShareLinkContent.
You could use it as follows :
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.imageURL = [NSURL URLWithString:#"http://upload.wikimedia.org/wikipedia/commons/3/36/Hopetoun_falls.jpg"];
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:self];
If you want to share a link then just use content.contentURL.
Refer to : https://developers.facebook.com/docs/sharing/ios#share_dialog
If you are using FBSDKSharePhoto then you need the native Facebook for iOS app installed.
Refer to :https://developers.facebook.com/docs/sharing/ios#photos
I also had the same issue as the documentation is also saying that they provide fallback mechanisms, which seems not true for this case:
Built-In Share Fallbacks
In past versions of the SDK for iOS, your app had to check for a
native, installed Facebook app before it could open the Share Dialog.
If the person didn't have the app installed, you had to provide your
own code to call a fallback dialog.
Now the SDK automatically checks for the native Facebook app. If it
isn't installed, the SDK switches people to their default browser and
opens the Feed Dialog. If someone wants to share an Open Graph story,
the SDK opens the Web Share Dialog.
First configure Facebook account of iOS device before and then use following code it will work:
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = self.capturedImageView.image;
photo.userGenerated = YES;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = #[photo];
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:self];