Reputation: 6133
I can share to Facebook from within my iOS application using the standard share action. I have seen other applications do the same.
However, what I have noticed in other applications is their application name is included in the Facebook shared post.
If I tap on that link from within a browser, it goes to this:
https://apps.facebook.com/carousell/?fb_source=feed
If I tap on that link from within the Facebook mobile app, it goes to app's store page.
Can I do the same thing from an iOS application? Or is it something that is identified in the website? If so, how can I accomplish the same?
Upvotes: 0
Views: 346
Reputation: 1959
I'm not sure I understand your question but looking at your two images, I get the impression that you are trying to Post to the user's wall using the Facebook app on the user's device, while the "Carousell" app is creating a post programmatically. I'm not sure if the Facebook app can be set to include meta data about the app that called the post action, but I know how to do it programmatically. One approach is to create a "Story" post (I realize that's not what Carousell is doing here; just using this as an example).
To create a Story post you first need to set up the story in your developer portal. To do that, sign into your Facebook Developer portal and select your app. Then select "Open Graph" from the menu to the left. I will not bother to explain how to create an actual story from here because it is incredibly simple. Once you have finished creating a story, click "Get Code" to see the code snippets you need.
Here's an example from one of my apps. In this case I am performing all of this inside the imagePickerController:didFinishPickingMediaWithInfo:
delegate method. I am creating an object, action, and content for the story then presenting that to the user through a Share dialog:
UIImage *image = info[UIImagePickerControllerOriginalImage];
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = image;
photo.userGenerated = YES;
NSDictionary *properties = @{
@"og:type": @"appNamespace:objectTypeName",
@"og:title": @"Type Title",
@"og:description": @"Facebook story post!",
@"og:url": @"http://samples.ogp.me/bignumber",
@"og:image": @[photo]
};
FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
action.actionType = @"appNamespace:objectTypeName";
[action setObject:object forKey:@"objectTypeName"];
FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
content.action = action;
content.previewPropertyName = @"objectTypeName";
[FBSDKShareDialog showFromViewController:someViewController
withContent:content
delegate:self];
This approach will create a "story" post which also includes your app name and a link to your app. I re Most of this code will be automatically generated for you on the Facebook developer portal, but play around with the default code and experiment by posting to your timeline programmatically until you get the result you're looking for. No one other than your app testers can see these posts until your story has been approved, or at least that has been my experience thus far. I hope this helps answer your question.
Upvotes: 1