I want to detect that user already log in facebook in iphone's settings? I am using Facebook ios sdk 3.1 In twitter, I can check it by this
[TWTweetComposeViewController canSendTweet]
Any suggestions would be appreciate :), thank you very much for your time.
The following will tell you. It will prompt the user for permission, but only in the case that they have facebook enabled in the iOS settings. Look at the error code that is returned to distinguish between different failure cases. Replace 'YOUR_FACEBOOK_APPID' with the id for your facebook app.
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSDictionary* options = [NSDictionary dictionaryWithObject:@"YOUR_FACEBOOK_APPID" forKey:ACFacebookAppIdKey];
[accountStore requestAccessToAccountsWithType:accountType options:options completion:^(BOOL granted, NSError *error) {
if(granted) {
NSLog(@"Access granted");
}
}];
No account installed:
Error Domain=com.apple.accounts Code=6 "The operation couldn’t be completed. (com.apple.accounts error 6.)"
User denied permission:
Error Domain=com.apple.accounts Code=7 "The operation couldn’t be completed. (com.apple.accounts error 7.)"