Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/105.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用ACAccountStore IOS在两个Facebook帐户之间登录_Ios_Facebook_Acaccountstore - Fatal编程技术网

使用ACAccountStore IOS在两个Facebook帐户之间登录

使用ACAccountStore IOS在两个Facebook帐户之间登录,ios,facebook,acaccountstore,Ios,Facebook,Acaccountstore,好的,所以我一直在我的应用程序中使用SLRequest到Facebook。这个问题似乎相对简单,我部分知道出了什么问题,但通过几个小时的搜索无法找到修复方法 -我只通过设备设置登录Facebook,而不是在我的应用程序中 -该应用程序有一个弹出窗口,允许发布,并按预期工作 -我在设置中注销Facebook并登录到另一个Facebook帐户,问题就在这里。当使用第二个帐户登录时,它将永远不会通过应用程序中的授权(下面的代码) -我可以使用设置中的第一个帐户重新登录,该应用程序继续按预期发布 -我知

好的,所以我一直在我的应用程序中使用SLRequest到Facebook。这个问题似乎相对简单,我部分知道出了什么问题,但通过几个小时的搜索无法找到修复方法

-我只通过设备设置登录Facebook,而不是在我的应用程序中

-该应用程序有一个弹出窗口,允许发布,并按预期工作

-我在设置中注销Facebook并登录到另一个Facebook帐户,问题就在这里。当使用第二个帐户登录时,它将永远不会通过应用程序中的授权(下面的代码)

-我可以使用设置中的第一个帐户重新登录,该应用程序继续按预期发布

-我知道你在商店里只能有一个FB帐户,当然必须有办法重置它,以允许应用程序从我最初使用的帐户以外的帐户发布

任何帮助都会得到报答

- (void)shareSessionToFacebook {
        // Specify App ID and permissions
        NSDictionary *options = @{ACFacebookAppIdKey: @“XXXXXXXXXXXXX”,
        ACFacebookPermissionsKey: @[@"email", @"publish_stream", @"publish_actions"],
       ACFacebookAudienceKey: ACFacebookAudienceFriends};
        accountStore = [[ACAccountStore alloc]init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
[accountStore requestAccessToAccountsWithType:accountType options:options completion:^(BOOL granted, NSError *error) {
        if (granted) {

您可以先获得可用的帐户尝试使用twitter,您可以获得多个帐户,但Facebook只能获得一个帐户


   [account requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error)
  {
    if (granted == YES)
    {
     // Populate array with all available accounts only for twitter accounts not for Facebook
        NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType]; //type of twitter as your case and you will get all the availble twitter accounts
        if ([arrayOfAccounts count] > 0)
         {
           //use the first account available
           ACAccount *acct = [arrayOfAccounts objectAtIndex:0]; //select the account based on the array index

   [account requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error)
  {
    if (granted == YES)
    {
     // Populate array with all available accounts only for twitter accounts not for Facebook
        NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType]; //type of twitter as your case and you will get all the availble twitter accounts
        if ([arrayOfAccounts count] > 0)
         {
           //use the first account available
           ACAccount *acct = [arrayOfAccounts objectAtIndex:0]; //select the account based on the array index

希望这对你有帮助:)

我跌跌撞撞地回到了我的答案上。关于像我这样只使用设备的设置菜单登录,在任何第一次登录时,您必须在第一次呼叫时单独请求电子邮件(或其他几个电子邮件中的一个),然后您可以请求varios发布权限

因此,在初次登录或切换到其他帐户时,只需使用电子邮件,然后再次请求您的发布等权限

//INITIAL LOGIN START//
NSDictionary *optionsX = @{
                           ACFacebookAppIdKey: @"XXXXXXXXXXXXXX",
                           ACFacebookPermissionsKey: @[@"email"],
                           ACFacebookAudienceKey: ACFacebookAudienceFriends
                           };
ACAccountStore *accountStoreX = [[ACAccountStore alloc]init];
ACAccountType *accountTypeX = [accountStoreX accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
[accountStoreX requestAccessToAccountsWithType:accountTypeX options:optionsX completion:^(BOOL granted, NSError *error) {
    if (granted) {
        NSLog(@"ALPHA GRANTED!!!!");
    } else {
        NSLog(@"ALPHA NOT GRANTED");
    }
}];
//INITIAL LOGIN END//

Hi Shan感谢您抽出时间回复。但我的问题是,每当我登录到我第一次使用的应用程序以外的帐户时,它总是返回0个帐户,如果我再登录到原始帐户,它将返回一个FB帐户并按预期工作。我假设我需要清除一些默认、设置或权限,但是我发现这些示例都不起作用。(同样,我正在处理所有通过Facebook设备设置的登录,而不是在我的应用程序中)干杯。很抱歉,在IOS中,我们只能为Facebook帐户设置一个帐户不多,可能这就是你面临的问题。是的,先生,据我所知,你是对的,只是似乎必须有某种方式允许用户杀死一个,并且在每次只使用一个的情况下访问另一个:)。。哦,再次感谢!