iOS requestAccessToAccountsWithType未显示权限提示/ NSAlert [英] iOS requestAccessToAccountsWithType is Not Showing Permission Prompt / NSAlert
问题描述
据我所知,当我调用 [ACAccountStore requestAccessToAccountsWithType:options:completion]
时,用户应该看到一个UIAlert询问他们是否授予我的权限应用程序。
It is my understanding that when I invoke [ACAccountStore requestAccessToAccountsWithType:options:completion]
, the user is supposed to see an UIAlert that asks them if they grant permission to my app.
当我运行此代码时,从来没有提示,已授予
变量始终为false
When I run this code, there is never a prompt and the granted
variable is always "false"
-(void)myfunction {
if (!_accountStore) _accountStore = [[ACAccountStore alloc] init];
ACAccountType *fbActType = [_accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSDictionary *options = [[NSDictionary alloc] initWithObjectsAndKeys:
(NSString *)ACFacebookAppIdKey, @"##########",
(NSString *)ACFacebookPermissionsKey, [NSArray arrayWithObject:@"email"],
nil];
[_accountStore requestAccessToAccountsWithType:fbActType options:options completion:^(BOOL granted, NSError *error) {
NSLog(@"Home.m - getFBDetails - Check 2");
if (granted == YES) {
NSLog(@"Success");
NSArray *accounts = [_accountStore accountsWithAccountType:fbActType];
_facebookAccount = [accounts lastObject];
[self me];
} else {
NSLog(@"ERR: %@ ",error);
// Fail gracefully...
}
}
];
}
我收到错误:错误:错误域= com.apple.accounts代码= 8操作无法完成。(com.apple.accounts错误8。)
更新:我做了一些测试,如果我使用 ACAccountTypeIdentifierTwitter
运行,我会收到连接到我的Twitter帐户的提示,所以我认为它与我的Facebook设置有关...
Update: I did some testing and if I run with using ACAccountTypeIdentifierTwitter
, I get the prompt to connect to my Twitter accounts, so I am supposing it is something with my Facebook settings ...
推荐答案
您的选项词典中有倒置的对象和键:
You have inverted objects and keys in your options dictionary :
NSDictionary *options = [[NSDictionary alloc] initWithObjectsAndKeys:
@"##########", ACFacebookAppIdKey,
[NSArray arrayWithObject:@"email"], ACFacebookPermissionsKey,
nil];
这篇关于iOS requestAccessToAccountsWithType未显示权限提示/ NSAlert的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!