ShareKit 2.0:如何获得Sharer授权通知?

时间:2012-03-27 07:04:53

标签: iphone objective-c sharekit

我需要知道何时共享器已被授权(更改某些UI),看起来有一个SharerDelegate sharerAuthDidFinish方法(我认为)我实现了,但它没有被调用。

任何?

谢谢!

1 个答案:

答案 0 :(得分:3)

在SHKSharer.m中,有以下代码:

- (void)authDidFinish:(BOOL)success 
{
    [[NSNotificationCenter defaultCenter] postNotificationName:@"SHKAuthDidFinish" object:self userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:success] forKey:@"success"]];  

    if ([self.shareDelegate respondsToSelector:@selector(sharerAuthDidFinish:success:)]) {      
        [self.shareDelegate sharerAuthDidFinish:self success:success];
    }
}

所以你可以在任何需要知道的课程中听取通知,如:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sharerAuthorized:) name:@"SHKAuthDidFinish" object:nil];

然后实现类似的方法:

- (void)sharerAuthorized:(NSNotification *)notification {
    //check for success and type of sharer
    //do whatever you need to do once it is authorized
}