经过几个小时的尝试代码,在线搜索,我不得不寻求帮助。我在UITableViewCell中有一个共享按钮。在触摸操作中,我打开Facebook登录对话框,然后如果登录我显示提要对话框。它工作正常,但即使我通过Facebook应用程序注销,sessionIsValid显示YES。这是代码......
if(indexPath.row==0)
{
AppId=@"xxx";
AppDelegate *appDelegate=(AppDelegate*)[[UIApplication sharedApplication]delegate];
appDelegate.scheduleViewController=self;
self.facebook = [[Facebook alloc] initWithAppId:AppId andDelegate:self];
// [self.facebook requestWithGraphPath:@"me" andDelegate:self];
if ([defaults objectForKey:@"FBAccessTokenKey"]
&& [defaults objectForKey:@"FBExpirationDateKey"]) {
self.facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
self.facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}
if (![self.facebook isSessionValid]) {
[self.facebook authorize:permissions];
}
else
[self doStuffAfterLogin:[self.facebook accessToken]];
}
- (void)fbDidLogin {
[defaults setObject:[self.facebook accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[self.facebook expirationDate] forKey:@"FBExpirationDateKey"];
[defaults synchronize];
[self doStuffAfterLogin:[self.facebook accessToken]];
}
- (void)request:(FBRequest *)request didFailWithError:(NSError *)error {
NSLog(@"%@", [error localizedDescription]);
NSLog(@"Err details: %@", [error description]);
UIAlertView *alertView=[[UIAlertView alloc]initWithTitle:@"Error!" message:@"Error!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alertView show];
[defaults removeObjectForKey:@"FBAccessTokenKey"];
[defaults removeObjectForKey:@"FBExpirationDateKey"];
[self.facebook authorize:permissions];
}
-(void)doStuffAfterLogin:(NSString*)accessToken;
{
NSMutableString *imgUrl=[[NSMutableString alloc]init];
if([[defaults objectForKey:@"imageUrl"] isEqualToString:@""])
imgUrl= @"http://artist.eventseekr.com/images/no-photo.png";
else
imgUrl=[defaults objectForKey:@"imageUrl"];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
AppId, @"app_id",
imgUrl, @"picture",
[NSString stringWithFormat:@"Watch %@ in action at the %@ event",[defaults objectForKey:@"name"],[defaults objectForKey:@"eventName"]], @"caption",
@"Sample Festival App", @"description",
nil];
[self.facebook dialog:@"feed" andParams:params andDelegate:self];
}
答案 0 :(得分:1)
这是对的。每个应用程序都有自己的沙盒区域。因此,您已授权您的应用,并且您的应用已存储了可用于验证自身的令牌。它对任何其他应用程序一无所知。因此,如果您在Facebook应用程序中注销,它就不知道。