2

在我的 iOS iPhone 应用程序中,我使用 facebook connect。SSO 工作得很好,我可以发布到墙上等,但是有一个问题:

  1. 我启动我的应用程序
  2. 允许 facebook 连接
  3. 应用程序中的一切都很好,
    但现在......
  4. 我删除了 facebook 网站上的应用程序!
  5. 如果我现在启动我的应用程序 - NSLOG 说,FB-Connections 没问题。..?

所以我想,如果我在我的帐户中删除在线应用程序,则 iphone 应用程序没有有效会话并且必须要求重新登录,但这失败了。

怎么了?我怎样才能以正确的方式检查?或者 sessionValid 是如何记录的?在该方法再次运行之前是否有时间限制?那么我的检查(在线删除,重新启动应用程序)是否快速?

- - 更新:

- (void)fbLogin:(id)sender{
    NSLog(@"FB Login Alert");

    [self checkForPreviouslySavedAccessTokenInfo];    
    if (!isConnected == YES) {              
        NSLog(@"NO - Facebook Connection");

        UIAlertView *popupFacebook =  [[UIAlertView alloc]                     
                                      initWithTitle:NSLocalizedString(@"Headline_FacebookL", @"Headline")
                                            message:NSLocalizedString(@"Facebook-Text", @"Facebook") 
                                           delegate:self
                                  cancelButtonTitle:NSLocalizedString(@"later",@"Facebook Login später")
                                  otherButtonTitles:NSLocalizedString(@"Facebook",@"Login"), nil];
    popupFacebook.tag = alertFacebook;
    [popupFacebook show];
    [popupFacebook release];

}
    else{
        NSLog(@"Facebook Connection OK");
    }

}


(void)checkForPreviouslySavedAccessTokenInfo:

-(void)checkForPreviouslySavedAccessTokenInfo{
// Initially set the isConnected value to NO.
isConnected = NO;
NSLog(@"FB Status erst mal auf NEIN");

// Check if there is a previous access token key in the user defaults file.
appDelegate.facebook = [[Facebook alloc] initWithAppId:@"XXXXXXXXX" andDelegate:(AppDelegate *) [[UIApplication sharedApplication] delegate]];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"] 
    && [defaults objectForKey:@"FBExpirationDateKey"]) {
    appDelegate.facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
    appDelegate.facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}  

    // Check if the facebook session is valid.
    // If it’s not valid clear any authorization and mark the status as not connected.
if (![appDelegate.facebook isSessionValid]) {
        //[facebook authorize:permissions];
        isConnected = NO;
        NSLog(@"FB NO");
    }
    else {

        isConnected = YES;
        NSLog(@"FB YES");
    }
}

转变:

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    NSLog(@"clicking");
    //NSString *title = [actionSheet buttonTitleAtIndex:buttonIndex];

    if (alertView.tag == alertWelcome )  {
        if (buttonIndex == 0) {
            NSLog(@"close");
        }
    }  

    else if (alertView.tag == alertFacebook )  {

        if (buttonIndex == 0) {
            NSLog(@"später");
        }  

        if (buttonIndex == 1) {
            //self.label.text = NSLocalizedString(@"Facebook",@"Login"),
            [self fbActive:nil];
            NSLog(@"Login to FB");
        }  

    }
}

权限:

-(void)fbActive:(id)sender{

    if (![appDelegate.facebook isSessionValid]) {
        NSArray *permissions = [[NSArray alloc] initWithObjects:
                                @"user_likes", 
                                @"read_stream",
                                @"user_status",
                                @"publish_stream",
                                //@"publish_actions",
                                //@"manage_pages",
                                @"read_requests",
                                nil];
        [appDelegate.facebook authorize:permissions];
        NSLog(@"FB - Permissions");
        [permissions release];   
    }
}
4

0 回答 0