0
votes

I've include the Facebook native Share dialog in my iOS app to let users share some data. The problem is, that the dialog does not open. Here is the code. Also, it is normal for me to pass URL of image to the method? Maybe, this is the problem?

    BOOL displayedNativeDialog =
        [FBNativeDialogs
           presentShareDialogModallyFrom:self
           initialText:activityName 
           image:activityImageURL
           url:activityURL
           handler:^(FBNativeDialogResult result, NSError *error) {
           if (error) {
               NSLOG(@"Error occured");
           } else {
               if (result == FBNativeDialogResultSucceeded) {
                   NSLOG(@"Success");
               } else {
                   NSLOG(@"No success");
               }
           }
      }];
   if (!displayedNativeDialog) {
      NSLOG("Window does notdisplayed");
   }
2
You could pass nil instead of an image URL to test out your image question. Also, did you log in to Facebook system account via the iOS 6 Settings? - C Abernathy

2 Answers

0
votes

Instead of image:activityImageURL pass the UIImage data to image image:[UIImage imageWithNamed:@"blahblah"]

0
votes

You can use Native Dialogs only when the user has the Facebook App installed. First check if the facebook app is available, then either display the native dialog or display the web dialog accordingly:

FBShareDialogParams *shareParams = [[FBShareDialogParams alloc] init];
shareParams.link = [NSURL URLWithString:@"http://some-url.com"];
shareParams.name = @"Post Name";
shareParams.picture= [NSURL URLWithString:someImageURL];
shareParams.description = @"Post Description";

if ([FBDialogs canPresentShareDialogWithParams:shareParams])
{
    [FBDialogs presentShareDialogWithParams:shareParams
                                clientState:nil
                                    handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
                                        NSLog(@"%@", [error localizedDescription]);
                                    }];
}
else
{
    NSDictionary *params = @{
                             @"name" : shareParams.name,
                             @"description" : shareParams.description,
                             @"picture" : objectiveCharacterImageURL,
                             @"link" : linkURL
                             };

    [FBWebDialogs presentFeedDialogModallyWithSession:nil
                                           parameters:params
                                              handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {

                                              }];
}