2
id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
    [action setObject:@"https://example.com/book/Snow-Crash.html"
               forKey:@"book"]; 
[FBDialogs presentShareDialogWithOpenGraphAction:action
                                          actionType:@"books.reads"
                                          previewPropertyName:@"book"
     handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
         if(error) {
             NSLog(@"Error: %@", error.description);
         } else {
             NSLog(@"Success!");
         }
     }];

I use the above codes to present a facebook shareDialog in my application ,but it does not work in both ios 5.1 and 6.1.I want to know the reason.

  • The code above is meant to invoke the "shareDialog" dialogue box of the facebook iOS app. The OP is asking why it doesn't work. I wouldn't say his question is overly ambiguous. In fact, I am curious myself to see if Miffy Stone ever got it to work. – stackOverFlew Jul 05 '13 at 08:31

2 Answers2

2

From my understanding as of now (I might be wrong), this code invokes the facebook native iOS app. If you are testing this on the simulator and don't have the iOS app installed, this will not work. It is unlikely you will be able to test this on the simulator. Try it on a real device that has the facebook iOS app installed.

stackOverFlew
  • 1,479
  • 2
  • 31
  • 58
1

Do you have the latest Facebook app installed? Also, you're trying to post an open graph action using facebook's example action, which I'm not sure even exists. If you have registered custom open graph actions with you app, I suggest you modify your code to invoke it instead. If you don't have custom actions, I suggest starting with posting simple urls to see if it works for you.

Use:

NSURL* url = [NSURL URLWithString:@"https://developers.facebook.com/"];
[FBDialogs presentShareDialogWithLink:url
                              handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
    if(error) {
        NSLog(@"Error: %@", error.description);
    } else {
        NSLog(@"Success!");
    }
 }];

And lastly I suggest you read this: https://developers.facebook.com/ios/share-dialog/

shaioz
  • 340
  • 3
  • 12