I am trying to share a graphobject on facebook but i'm encountering some problems when i add the image.
Here is my current code:
// Construct an FBSDKSharePhoto
UIImage* psImg = [UIImage imageNamed:@"fb_share_logo"];
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = psImg;
photo.userGenerated = NO;
NSDictionary *properties = @{@"og:type": @"my_obj",
@"og:title": @"Title",
@"og:description": @"Description",
@"og:web": @"http://www.mywebssite.com"
// @"og:image": @[photo]
};
//create GraphObject from properties
FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];
//create action
FBSDKShareOpenGraphAction *action = [FBSDKShareOpenGraphAction actionWithType:@"my_action" object:object key:@"my_key"];
//create content
FBSDKShareOpenGraphContent *content = [FBSDKShareOpenGraphContent new];
//set content action
content.action = action;
content.previewPropertyName = @"my_prop_type";
FBSDKShareDialog *shareDialog = [[FBSDKShareDialog alloc] init];
shareDialog.fromViewController = self;
shareDialog.shareContent = content;
if (![shareDialog canShow]) {
// update the app UI accordingly
NSLog(@"is showing");
}
NSError *error;
if (![shareDialog validateWithError:&error]) {
// check the error for explanation of invalid content
NSLog(@"error");
}
if([shareDialog canShow]){
[shareDialog show];
}
If i don't add the image it works and the dialog shows but i need it. If i add the image i get this: