문제

I would like to ask users if they would like to enable FB integration and provide a UISwitch for them to indicate their preference. However, I only want to have that option enabled/unhid in the event that the user has actually set up their FB account in the iPhones settings. How does one go about checking to see if they have even done that much?

도움이 되었습니까?

해결책 2

I figured it out. Here is the block of code that works for me. I welcome suggestions for improvement :)

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

다른 팁

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");
            }   

        }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top