Miffy  Stone
Miffy Stone

Reputation: 21

FBDialogs presentShareDialog does not work in both 5.1 and 6.1

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.

Upvotes: 2

Views: 1580

Answers (2)

shaioz
shaioz

Reputation: 450

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/

Upvotes: 1

stackOverFlew
stackOverFlew

Reputation: 1499

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.

Upvotes: 2

Related Questions