Pregunta

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?

¿Fue útil?

Solución 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;
    }

Otros consejos

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

        }
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top