Created
September 2, 2012 06:01
-
-
Save anuragsolanki/3595224 to your computer and use it in GitHub Desktop.
Integrating Facebook in iOS 6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "Social/Social.h" | |
#import "Accounts/Accounts.h" | |
-(IBAction)postToFaceBook:(id)sender{ | |
//Deprecated in iOS6 | |
/* | |
ACAccountStore *accountStore = [[ACAccountStore alloc] init]; | |
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook]; | |
[accountStore requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) { | |
ACAccount *account = [[ACAccount alloc] initWithAccountType:accountType]; | |
NSLog(@"%@, %@", account.username, account.description); | |
}]; | |
*/ | |
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) { | |
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; | |
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){ | |
if (result == SLComposeViewControllerResultCancelled) { | |
NSLog(@"Cancelled"); | |
} else | |
{ | |
NSLog(@"Done"); | |
} | |
[controller dismissViewControllerAnimated:YES completion:Nil]; | |
}; | |
controller.completionHandler = myBlock; | |
[controller setInitialText:@"Test Post from iOS-6-facebook-library"]; | |
[controller addURL:[NSURL URLWithString:@"http://www.vinsol.com"]]; | |
[controller addImage:[UIImage imageNamed:@"fb.png"]]; | |
[self presentViewController:controller animated:YES completion:Nil]; | |
} | |
else { | |
NSLog(@"UnAvailable"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment