0

i need facebook share component for ios app. i use fbcoonect but it doesn't work properly. After the login screen it gives white screen when i use fbdialog. Also sharekit example gives same error. Photo share works but text, link share doesn't work at sharekit default example. it gives  white white blank screen after login dialog when you want share something. Any idea?

Sergio
  • 28,539
  • 11
  • 85
  • 132
mturhan55
  • 211
  • 3
  • 9

1 Answers1

-1

Try this code and it will work. Dont forget to add you APP_ID in .plist and code.

-(void)buttonPressed:(id)sender{
facebook = [[Facebook alloc] initWithAppId:@"YOUR_APP_ID" andDelegate:self];

 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) {
            facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
            facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
        }
if (![facebook isSessionValid]) {
    [facebook authorize:nil];
}else{
[self postWall];
}
// Pre 4.2 support
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    return [facebook handleOpenURL:url]; 
}
- (void)fbDidLogin {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
    [defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
    [defaults synchronize];
    [self postWall];
}
-(void)postWall{

    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   @"https://developers.facebook.com/docs/reference/dialogs/",@"link",
                                   @"http://fbrell.com/f8.jpg",@"picture",
                                   @"Facebook Dialogs",@"name",
                                   @"Reference Documentation",@"caption",
                                   @"Using Dialogs to interact with users.",@"description",
                                   @"Facebook Dialogs are so easy!",@"message",
                                   nil];

    [[self facebook] dialog:@"feed" andParams:params andDelegate:self];

}
Dinesh Raja
  • 8,501
  • 5
  • 42
  • 81
  • i changed all code with last fbconnect library and it's worked. sharekit's fbconnect is not the same standalone fbconnect library. for example sharekit's facebook library doesn't contains json folder and library. – mturhan55 Apr 09 '12 at 16:33
  • Sharekit is outdated. I think you don't have to use that. – Dinesh Raja Apr 10 '12 at 04:13
  • Sorry. I can't help you with sharekit. I know well about sharekit. Till they improve sharekit API,there is no use of trying to work on that. Not even worth trying it. – Dinesh Raja Apr 10 '12 at 04:16
  • I never seen "sharekit is outdated" anywhere on the internet. On the otherhand' I can still use sharekit's twitter library. But Sharekit's facebook library outdated. I accept that. – mturhan55 Apr 11 '12 at 18:48
  • Ya. but not every functionality will work. What if it is not work,after you released your app?? – Dinesh Raja Apr 12 '12 at 03:53
  • Yes, You're right but now i have no time. Maybe later I'll update my app. – mturhan55 Apr 14 '12 at 08:41