如何在设置中编辑facebook的权限

时间:2016-03-15 12:19:55

标签: ios facebook

enter image description here

- (void)viewDidLoad {
        [super viewDidLoad];

    if (NO == [SLComposeViewController isAvailableForServiceType: SLServiceTypeFacebook]) {
        [self showAlert:@"There are no Facebook accounts configured. Please add or create a Facebook account in Settings."];
        return;
    }

    [self getMyDetails];
    // Do any additional setup after loading the view from its nib.
}

- (void) getMyDetails {
    if (! accountStore) {
        accountStore = [[ACAccountStore alloc] init];
    }

    if (! facebookAccountType) {
        facebookAccountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
    }

    NSDictionary *options = @{ ACFacebookAppIdKey: [NSString stringWithFormat:@"1725978560966525"] };

    [accountStore requestAccessToAccountsWithType: facebookAccountType
                                           options: options
                                        completion: ^(BOOL granted, NSError *error) {
        if (granted)
            {
    NSArray *accounts = [accountStore accountsWithAccountType:facebookAccountType];
    facebookAccount = [accounts lastObject];

    NSURL *url = [NSURL URLWithString:@"https://graph.facebook.com/me"];

SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET
                                                                                            URL:url
                                                                                           parameters:nil];
                                                request.account = facebookAccount;

    [request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
                                                    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:responseData
                                                                                                                       options:NSJSONReadingMutableContainers
                                                                                                                         error:nil];
                                                    NSLog(@"id: %@", responseDictionary[@"id"]);
                                                    NSLog(@"first_name: %@", responseDictionary[@"first_name"]);
                                                    NSLog(@"last_name: %@", responseDictionary[@"last_name"]);
                                                    NSLog(@"gender: %@", responseDictionary[@"gender"]);
                                                    NSLog(@"city: %@", responseDictionary[@"location"][@"name"]);
                                                }];
                                            } else {
                                                [self showAlert:@"Facebook access for this app has been denied. Please edit Facebook permissions in Settings."];
                                            }
                                        }];
}

- (void) showAlert:(NSString*) msg {
    dispatch_async(dispatch_get_main_queue(), ^(void) {
        UIAlertView *alertView = [[UIAlertView alloc]
                                  initWithTitle:@"WARNING"
                                  message:msg
                                  delegate:nil
                                  cancelButtonTitle:@"OK"
                                  otherButtonTitles:nil];
        [alertView show];
    });
}

我试图获取Facebook(登录用户)的个人信息,但它需要许可,因为我不知道在哪里添加权限,我已经检查了设置,尝试了模拟器中的所有东西但仍然没有。

enter image description here

0 个答案:

没有答案