Friday, November 28, 2014

Check Twitter Service availability on iOS Device



Add Social and Accounts framework:

 if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
   
   
    ACAccountStore *store = [[ACAccountStore alloc] init];
    ACAccountType *twitterType = [store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
    [store requestAccessToAccountsWithType:twitterType options:nil completion:^(BOOL granted, NSError *error) {
     
      if(error != nil) {
       
        NSLog(@"Twitter Error : %@", [error description]);
       
      } else {
       
        if(granted) {
         
          NSLog(@"Twitter permission granted");
         
        } else {
          NSLog(@"Twitter permission not granted");
        }
       
      }
     
    }];
   
  }
 

No comments: