【问题标题】:Recognize if user has defined a native facebook account in iOS 6 settings识别用户是否在 iOS 6 设置中定义了本机 facebook 帐户
【发布时间】:2012-12-05 11:17:45
【问题描述】:

有没有办法通过 FACEBOOK SDK 3.1 和 iOS 6 知道用户是否在 iPhone 设置中定义了他的 facebook 帐户以供本地 facebook 使用?

我想要做的是在打开我的应用程序时,如果用户在 iPhone 设置中定义了“本机 facebook 帐户”,立即显示“允许/不允许”iOS 6 警报。但我只想为本地集成做这件事。 我的意思是,如果知道我可以尝试使用 FBSession 的“openSession”,它会显示它,但如果用户尚未定义本机帐户,我不希望应用程序转到 Safari 或 facebook 应用程序.所以我想只有在用户定义了一个帐户时才尝试连接。

有人知道方法吗?

【问题讨论】:

  • 这里已经回答了这个问题:stackoverflow.com/a/12811583/312312
  • 嘿首先感谢分配!!!问题似乎是,即使帐户已配置或未配置 ACAccountType* at = [as accountTypeWithAccountTypeIdentifier: @"com.apple.facebook"]; at 在 ios 6 中似乎不是 nil

标签: ios facebook login native account


【解决方案1】:

这对我有用:

//Step 1. create and store an ACAccountStore in an ivar
ACAccountStore* as = [[ACAccountStore alloc] init];
self.accountStore = as;
[as release];

//Step 2. Get the facebook account type
//Do not use the constant if you are in iOS5, use this string:@"com.apple.facebook"
ACAccountType* at = [self.accountStore accountTypeWithAccountTypeIdentifier: @"com.apple.facebook"];

//Step 3. request access to the facebook account, passing your facebook app id
__block typeof(self) bself = self;
[self.accountStore requestAccessToAccountsWithType:at
                            options:@{(NSString *)ACFacebookAppIdKey: kFBAppId }
                         completion:^(BOOL granted, NSError *error)
 {
     //Step 4. Check if the account is integrated natively
     //Note: if granted is NO, check for the error to see what's going on.
     BOOL nativeAccount = granted == YES && [bself.accountStore accountsWithAccountType:at];


     //Step 5. clean the account store.
     bself.accountStore = nil;
 }];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-21
    • 1970-01-01
    • 2012-09-16
    • 2020-05-15
    • 1970-01-01
    • 2011-07-30
    • 1970-01-01
    相关资源
    最近更新 更多