这是我的脸书方法:
- (void)getMeFacebook{
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
__block ACAccount *facebookAccount = nil;
ACAccountType *facebookAccountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
// Specify App ID and permissions
NSDictionary *options = @{ACFacebookAppIdKey : @"1405219416361729",
ACFacebookPermissionsKey : @[@"email", @"publish_stream"],
ACFacebookAudienceKey:ACFacebookAudienceFriends};
[accountStore requestAccessToAccountsWithType:facebookAccountType
options:options completion:^(BOOL granted, NSError *error)
{
if (granted)
{
NSArray *accounts = [accountStore accountsWithAccountType:facebookAccountType];
facebookAccount = [accounts lastObject];
NSLog(@"Granted!!!");
}
else {
NSLog(@"error.localizedDescription======= %@", error.localizedDescription);
}
}];
NSArray *accounts = [accountStore accountsWithAccountType:facebookAccountType];
facebookAccount = [accounts lastObject];
NSLog(@"Break 1");
调试代码时,它从不评估 if(granted),似乎方法 requestAccessToAccountsWithType 的行为不正确。我已经检查了应用程序中的 facebook 设置,但仍然无法正常工作。
对这个问题有任何想法吗?