如何确定用户是否在iPhone设置中设置了FB帐户

时间:2013-04-17 21:09:21

标签: ios facebook account

我想询问用户是否要启用FB集成并为他们提供UISwitch来表明他们的偏好。但是,我只想在用户实际在iPhone设置中设置其FB帐户的情况下启用/取消显示该选项。如何检查他们是否做了那么多?

2 个答案:

答案 0 :(得分:2)

give it a try this will help you .....


        if(iOSVersion >= 6.0)
        {
                if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
             {
                     NSLog(@"user have filled fb acount details");
             }
             else
            {

                    NSLog(@"settings is empty");
            }   

        }

答案 1 :(得分:1)

我明白了。这是适用于我的代码块。我欢迎改进建议:)

self.myStore = [[ACAccountStore alloc] init];
    ACAccountType *acct = [self.myStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
    NSArray *fbAccounts = [self.myStore accountsWithAccountType:acct];

    // Check to make sure the user has a FB account setup, or bail:
    if ([fbAccounts count] == 0) {
        userDoesNotHaveFBAccountSetup = YES;
        self.fbSwitch.enabled = NO;
        [[self fbSwitch] setOn:NO];
        [self viewDidLoad];
    } else {
        userDoesNotHaveFBAccountSetup = NO;
        self.fbSwitch.enabled = YES;
    }