0

I'm using the 3.16.1 version of the Facebook SDK for iOS to publish a custom story object to a user's timeline, however I am getting some unexpected results. I specify the url and optionally an image (which I stage on FB). The problem is that only in the browser, the post comes out with the title (see red box in screenshot) linked to my FB app page instead of the url I provided. The picture is linked to the URL I provide just fine. When viewed in the FB mobile app, clicking the title DOES as I expect and opens the url I provided. This is a big problem when there is no picture attached, which is sometimes the case.

I feel like I have some obscure setting misconfigured or there is some field other than the url that I have to set to get this to work but I can't find any documentation other than the standard stuff which got me as far as I am. Note that I have DeepLinking turned off and it is not appropriate for my application where the person viewing something produced by the mobile app wouldn't view it in the mobile app itself, but instead on a web page.

Here is the JSON from the object debugger (names changed to protect the innocent ;-) ):

{
    "id": "this-replaced-for-security",
    "url": "this-replaced-for-security",
    "is_scraped": "false",
    "type": "dataparenting:babymilestone",
    "title": "First 'high five'",
    "image": {
        "url": "fbstaging://graph.facebook.com/staging_resources/xxx"
    },
    "created_time": "2014-08-06T23:43:02+0000",
    "updated_time": "2014-08-06T23:42:31+0000",
    "data": {
        "baby_name": "Mateo",
        "baby_is_male": "true",
        "completion_date": "2014-08-06T23:40:26+0000"
    }
}

Here is the code I'm using in the iOS app:

            NSString *url = [NSString stringWithFormat:@"this-replaced-for-security", VIEW_HOST, achievement.objectId];
            NSMutableDictionary <FBOpenGraphObject> *object =
                [FBGraphObject openGraphObjectForPostWithType:@"dataparenting:babymilestone"
                                                        title:achievement.displayTitle
                                                        image:imageUrl
                                                          url:url
                                                  description:@""];
            object[@"al:ios"] = @"xxxxx";
            object[@"data"] = @{@"baby_name" : achievement.baby.name,
                    @"baby_is_male" : @(achievement.baby.isMale),
                    @"completion_date" : [achievement.completionDate asISO8601String],
            };
            if (achievement.comment) object[@"data"][@"comment"] = achievement.comment;
            if (achievement.standardMilestone.url) object[@"see_also"] = achievement.standardMilestone.url;

            [FBRequestConnection startForPostOpenGraphObject:object completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                if (!error) {
                    block([result objectForKey:@"id"], nil);
                } else {
                    block(nil, error);
                }
            }];

Image Showing Title With Link

1 Answer 1

0

In case it helps any future googler I figured this out.

Facebook docs: " The object URL is what a story on Facebook links to when it shows up in News Feed. Note that any URL you reference must be below the URL that's set in your app's website URL that's set in your app dashboard. This isn't required for hosted objects. You can also use this URL to set up deep linking to your native app. You can use canonical_url of an App Link Host in this parameter. "

This means you need to set the "App Domains" field under Settings to the domain of your website where you will show the linked content. However, I DID in fact try this, but I got a very unhelpful error message and I could not save the app (or the field). The secret was adding 'Website' platform that also points to the same domain. After adding the Website, I was then able to go back and add in the App domain, which then allowed the links in the title to point where they are supposed to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.