i am publishing some story on the user's facebook wall in my app. its working fine but i wanna know if some other user wanna login in my app with ot开发者_开发百科her facebook account how can he do that. i mean how can i logout an existing user and allow other user to login. my code in AppDelegate is:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.window addSubview:navigationController.view];
[self.window makeKeyAndVisible];
facebook = [[Facebook alloc] initWithAppId:@"app_id"];
NSArray* permissions = [[NSArray arrayWithObjects:
@"publish_stream", nil] retain];
[facebook authorize:permissions delegate:self];
return YES;
}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [facebook handleOpenURL:url];
}
and my code in DetailViewController is:
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
[sTitle stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""], @"name",
[sSummary stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""], @"description",
[sLink stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""], @"href", nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"XXX", @"api_key",
@"Share on Facebook", @"user_message_prompt",
attachmentStr, @"attachment",
nil];
[appDelegate.facebook dialog:@"stream.publish" andParams:params andDelegate:self];
once app is installed it asks for username and password for facebook. and then it publishes stories to only that user. what about if i wanna change user in my app. where should i write
[facebook logout:self];
You'll need to provide the options for login/ logout. This post will help you how to do it.
精彩评论