Nikita Vlasenko
Nikita Vlasenko

Reputation: 4352

iOS, Facebook, GraphAPI issue

I need to allow users to post on Facebook info from the iOS app and the following is almost what I want to have, but:

  1. I do not want ISBN obviously, since the info within the app (actually a post from another user) is not smth that can be described as a 'book' and does not have ISBN
  2. I need to attach somehow logo of the app. Right now it is shown just as a footnote. I can attach just one image, but need a second one, the logo.

Could anyone propose of what other schema should I use, if not 'books.book' that would express the sense correctly: "User A reads (or likes) a post of user B".

That's how the post to FB looks right now:

enter image description here

And the code that I am using for this is the following:

NSString *title = self.currSelecectedContextCell.uploaderDemoLabel.text;
NSURL *imageURL = self.currSelecectedContextCell.upload.screenshotURL;
NSString *description = self.currSelecectedContextCell.contextLabel.text;
NSDictionary *properties = @{
                             @"og:type": @"books.book",
                             @"og:title": title,
                             @"og:image": imageURL,
                             @"og:description": description,
                             @"books:isbn": @"0-553-57340-3",
                             };
FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];

// Create an action
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
action.actionType = @"books.reads";
[action setObject:object forKey:@"books:book"];

FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
content.action = action;
content.previewPropertyName = @"books:book";

[FBSDKShareDialog showFromViewController:self
                             withContent:content
                                delegate:nil];

Upvotes: 0

Views: 51

Answers (1)

Nikita Vlasenko
Nikita Vlasenko

Reputation: 4352

Solved it in the following way:

NSString *title = self.currSelecectedContextCell.uploaderDemoLabel.text;
NSURL *imageURL = self.currSelecectedContextCell.upload.screenshotURL;
NSString *description = self.currSelecectedContextCell.contextLabel.text;
NSDictionary *properties = @{
                             @"og:type": @"object",
                             @"og:url":@"http://www.textpertapp.co/",
                             @"og:title": title,
                             @"og:image": imageURL,
                             @"og:description": description
                             };
FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];

// Create an action
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
action.actionType = @"og.likes";
[action setObject:object forKey:@"object"];

FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
content.action = action;
content.previewPropertyName = @"object";

[FBSDKShareDialog showFromViewController:self
                             withContent:content
                                delegate:nil];

Upvotes: 2

Related Questions