2

私のiOS iPhoneアプリでは、facebook connectを使用しています。SSO は素晴らしく機能し、ウォールなどに投稿できますが、問題が 1 つあります。

  1. アプリを起動します
  2. Facebook の接続を許可する
  3. アプリではすべて問題ありませんが、
    今...
  4. facebookサイトの応募を削除します!
  5. 今すぐアプリを起動すると、NSLOG によると、FB 接続は問題ありません。..?

したがって、アカウントでアプリケーションをオンラインで削除すると、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