2011-03-01 74 views
0

我在我的應用程序的用戶的Facebook牆上發佈了一些故事。它的工作正常,但我想知道是否有其他用戶想在我的應用程序與其他Facebook帳戶登錄他怎麼能做到這一點。我的意思是我如何註銷現有的用戶並允許其他用戶登錄。我在AppDelegate的代碼是:如何在您的應用的Facebook上登錄其他用戶?

 - (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]; 
    } 

和我DetailViewController代碼:

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]; 

一旦應用程序被安裝,它要求爲Facebook用戶名和密碼。然後它僅向該用戶發佈故事。如果我想在我的應用程序中更改用戶,那該怎麼辦?我應該在哪裏寫

[facebook logout:self]; 

回答

1

您需要提供登錄/註銷選項。 This的帖子將幫助你如何做到這一點。

相關問題