2

I'm using ShareKit to allow users to share stuff from my app to Twitter and Facebook. After the user shared the object, I would like to get my app notified about it, in order to pass an API call to my server - so it can handle notifying the users "your friend just shared something, look it up!".

Facebook SDK allows to get a callback with information like the post ID. I'm wondering how to achieve something like this when using ShareKit 2.0 - should I override some methods of the Facebook and Twitter sharers?

kender
  • 85,663
  • 26
  • 103
  • 145

2 Answers2

2

All SHKSharers provide a delegate mechanism that you can use to be notified of the success / failure of the share (or authorisation). Check the superclass docs / .h file.

Wain
  • 118,658
  • 15
  • 128
  • 151
  • But is there a way to get into the response from Facebook? As it should give me the link to the shared post. – kender May 02 '13 at 08:12
  • I think you'd either have to modify share kit to do that, or, when you get the delegate callback then you can call FB to request the data. – Wain May 02 '13 at 08:30
0

It appears that modifying the ShareKit was the simplest (?) option.

In the SHKFacebook.m file, in the

-(void)FBRequestHandlerCallback:(FBRequestConnection *)connection
                         result:(id) result
                          error:(NSError *)error

method the result parameter actually contains what I needed - it is a dictionary-like object that has the id key - and the value is a string containing the FB id of the post:

result: {
    id = "XXXXXXXX_YYYYYYYYYYYYYYYYYYY";
}

So what I actually did was adding a @property (nonatomic, strong) id sharingResult to the base SHKSharer class and setting it to the result value just before calling the [self didFinishSending] in FBRequestHandlerCallback. This allows me to access the result in sharingDelegate later, in a - (void) sharerFinishedSending:(SHKSharer *)sharer method.

kender
  • 85,663
  • 26
  • 103
  • 145