andreelias
andreelias

Reputation: 238

Which FBSDKShareDialog didCompleteWithResults?

Using Facebook SDK 4.0, if I have different Facebook share buttons on the same view controller.

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

On the delegate how do I know, using the sharer object, which share dialog completed with results ?

-(void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results;

Upvotes: 1

Views: 2595

Answers (2)

andreelias
andreelias

Reputation: 238

Thanks for your answer Ming.

So, if you need to do this you should use the instance methods instead of the class method showFromViewController:withContent:delegate:

.h

@property (strong, nonatomic) FBSDKShareDialog *shareCodeDialog;

.m

self.shareCodeDialog = [FBSDKShareDialog new];
[self.shareCodeDialog setDelegate:self];
[self.shareCodeDialog setShareContent:content];
[self.shareCodeDialog setFromViewController:self];
[self.shareCodeDialog show];

-(void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results {

      if ([sharer isEqual:self.shareCodeDialog]) {
           // Your delegate code
      }
}

Upvotes: 2

Ming Li
Ming Li

Reputation: 15662

The sharer object in the delegate is the FBSDKShareDialog instance that called the showFromViewController:withContent:delegate: method. So you can either compare against your share dialog instances, or do internal bookkeeping yourself (right before you call the showFromViewController:... method).

Upvotes: 0

Related Questions