Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook SLComposeViewController URL shows up in body if both URL and image present

Tags:

ios

facebook

ios6

Using SLComposeViewController, I notice curious behavior when posting to Facebook if both the image and the URL are present. Specifically, if you have both image and URL, the URL appears in the body of the Facebook post in the view of the SLComposeViewController, immediately after the initialText if I do the following:

SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

NSString *text = @"This is a test Facebook post with SLComposeViewController.";
NSURL *url = [NSURL URLWithString:@"http://http://stackoverflow.com/questions/12503287/tutorial-for-slcomposeviewcontroller-sharing"];
UIImage *image = ...;

[controller setInitialText:text];
[controller addURL:url];
[controller addImage:image];

[self presentViewController:controller animated:YES completion:nil];

That's obviously a hassle because the if the URL is long, the initial text is pushed off of the visible portion of the view of SLComposeViewController and I only see the latter portion of the URL:

enter image description here

If I repeat this process, this time not adding the image to the post, the text of the URL conveniently does not show up in the body at all (even though it shows up properly online).

enter image description here

Bottom line, only if there is an image and and URL does the URL show up in the body of the post. And I see this same pattern when I use FBNativeDialogs.

Is there any way to stop that behavior with SLComposeViewController, so that I can have both image and URL connected to the Facebook post without exposing the user to the web site's long, ugly URL? Clearly I can use any of the non-SLComposeViewController solutions (e.g. design my own UI for composing the Facebook post, using Facebook's deprecated Feed Dialog, etc.). Just wondering if I'm overlooking some obvious SLComposeViewController solution.

like image 973
Rob Avatar asked Oct 12 '12 21:10

Rob


2 Answers

In the end, I've given up on the SLComposeViewController (as well as the FBNativeDialogs). They present a nice, integrated feel, but given that my posts invariably include both photo and URL, this really doesn't work. On top of that, the posts were not correctly attributed as being from my app.

So, in the end, I've written my own user interface and use the the Facebook SDK 3.1 FBRequestConnection as outlined here. I think it's a little silly that we all have to make our own UI because the weaknesses in the native UI, but it is what it is.

like image 151
Rob Avatar answered Oct 11 '22 07:10

Rob


The new dialog seems to be designed around you providing most of the share data as tags on the website the provided link points to. Like this:

Title:

<title>TITLE</title>

Description:

<meta name="description" content="DESCRIPTION">

Image:

<meta property="og:image" content="IMAGE_URL">

App ID:

<meta property="fb:app_id" content="APP_ID">

This way you only need to provide the initial text and an URL. You can look how the official Youtube app does it's Facebook sharing for an example.

like image 39
Max Huk Avatar answered Oct 11 '22 09:10

Max Huk