Jac*_*pow 7 account facebook login native ios
有没有办法知道FACEBOOK SDK 3.1和iOS 6,如果用户在iPhone设置中定义他的Facebook帐户用于本机Facebook使用?
我想要做的是打开我的应用程序,如果用户在iPhone设置中定义了"本机facebook帐户",立即显示"允许/不允许"iOS 6警报.但我想只为原生集成做这件事.我的意思是,如果知道我可以尝试使用FBSession的"openSession",它会显示它,但如果用户没有定义本机帐户,我不希望该应用程序转到Safari或Facebook应用程序.所以我想尝试仅在用户定义帐户时才进行连接.
谁知道有办法知道?
这对我有用:
//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;
}];
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2911 次 |
最近记录: |