我正在尝试使用iOS Social.framework与Facebook共享。然而,大多数用户不会在Settings>Facebook中安装Facebook,因此当您打开UIActivityViewController时,Facebook就不会出现,它只是没有列出。(请看UIActivity with no settings for Facebook或谷歌"facebook在UIActivityViewController中没有显示“,有很多人试图解决这个问题。)
我们的应用程序已经使用了Facebook,所以我可以获得Facebook帐户的信息,所以我想我只需要得到信息,然后将信息保存在Settings>Facebook中。这是我的密码。(我是从)account of ACAccountStore class?和iOS requestAccessToAccountsWithType is Not Showing Permission Prompt / NSAlert那里得到的)
- (void)storeAccountWithAccessToken:(NSString *)token secret:(NSString *)secret {
if (self.accountStore == nil) {
self.accountStore = [[ACAccountStore alloc] init];
}
//We start creating an account by creating the credentials object
ACAccountCredential *credential = [[ACAccountCredential alloc] initWithOAuthToken:token tokenSecret:secret];
ACAccountType *acctType =[self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
ACAccount *newAccount = [[ACAccount alloc] initWithAccountType:acctType];
//Here we assign credentials and now can save account
newAccount.credential = credential;
NSDictionary *options = [[NSDictionary alloc] initWithObjectsAndKeys:
[VVEnvironment stringForKey:kVVEnvironmentKeyFacebookAppID], (NSString *)ACFacebookAppIdKey,
[NSArray arrayWithObject:@"basic_info"], (NSString *)ACFacebookPermissionsKey,
ACFacebookAudienceEveryone, (NSString *)ACFacebookAudienceKey,
nil];
[_accountStore requestAccessToAccountsWithType:acctType options:options completion:^(BOOL granted, NSError *error) {
if (granted == YES) {
[self.accountStore saveAccount:newAccount withCompletionHandler:^(BOOL success, NSError *error) {
if (success) {
NSLog(@"the account was saved!");
}
else {
if ([error code] == ACErrorPermissionDenied) {
NSLog(@"Got a ACErrorPermissionDenied, the account was not saved!");
}
NSLog(@"the account was not saved! %d, %@", [error code], error);
}
}];
}
else {
NSLog(@"ERR: %@ ",error);
}
}];
}我在那里添加了对requestAccessToAccountsWithType的调用,因为在没有saveAccount的情况下,我得到了一个ACErrorPermissionDenied。当我运行这个程序时,我确实看到我的应用程序在Facebook对话框中短暂地滑到一边(如果我在Facebook的网站上删除我的应用程序,它会弹出完整的对话框,询问我所授予的权限)。
问题是,授予总是不,所以我从来没有机会保存帐户。我在这里错过了什么?
我是在一个真正的设备上运行的,它安装和安装了Facebook。
我很感谢你在这方面的帮助,谢谢!
发布于 2014-01-21 07:30:59
没有解决办法可供使用。iOS本地facebook应用程序不允许向ACAccountStore写入或保存帐户。它只允许从ACAccountStore访问帐户。iOS一次只允许存储1个facebook帐户。试着做这些你会很容易理解的步骤,
ACAccountStore,这将说明本机应用程序不允许将帐户保存到ACAccountStore。建议的解决方案是,将帐户添加到设置应用程序并与其登录,并使用社交框架( Social )或presentOSIntegratedDialog共享。
https://stackoverflow.com/questions/20407468
复制相似问题