I am able to get the user profile permissions if user has set facebook account in his iPhone settings. For this I have used following code:
if(!_accountStore)
_accountStore = [[ACAccountStore alloc] init];
ACAccountType *facebookTypeAccount = [_accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
[_accountStore requestAccessToAccountsWithType:facebookTypeAccount
options:@{ACFacebookAppIdKey: @"app_id", ACFacebookPermissionsKey: @[@"email"]}
completion:^(BOOL granted, NSError *error) {
if(granted){
NSArray *accounts = [_accountStore accountsWithAccountType:facebookTypeAccount];
_facebookAccount = [accounts lastObject];
NSLog(@"Success");
[self me];
}else{
NSLog(@"go to iphone settings");
}
}];
-(void)me
{
NSURL *meurl = [NSURL URLWithString:@"https://graph.facebook.com/me"];
SLRequest *merequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodGET
URL:meurl
parameters:nil];
merequest.account = _facebookAccount;
[merequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *meDataString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"%@", meDataString);
}];
}
If user hasn't set his facebook account then control will move to else part i.e. go to iphone settings. In this else part I want to open the facebook login page so that user will be able to login in his facebook account without going to iPhone settings. SO how could we open the facebook login via SDK. Please help me out from this issue.
Thanks in advance.