Search code examples
iosfacebooksharekit

How to get Facebook ID from ShareKit


I'd like to get the Facebook id from ShareKit anyone have any idea? There's this reference but I still dont get it. Reference

TIA


Solution

  • I got this by using the request:-

    Facebook *facebook = [[Facebook alloc] initWithAppId:SHKCONFIG(facebookAppId) 
                                         urlSchemeSuffix:SHKCONFIG(facebookLocalAppId) 
                                             andDelegate:nil];
    // ... do authorization stuff
    
    // when authorized...
    [facebook requestWithGraphPath:@"me" andDelegate:self];
    

    and implementing the delegate callback in the same file:-

    - (void)request:(FBRequest *)request didLoad:(id)result
    {
        NSString *fbid = [result objectForKey:@"id"];
        NSLog( @"facebook ID %@", fbid );
    }
    

    This does work, but I've no idea if this is the recommended technique, since it's the first time I've used sharekit. It seems odd to me the singleton method [SHKFacebook facebook] is private and you have to instantiate an object yourself.