How to Get Email Id of User Using Facebook Sdk 4.7 in iOS 9

How to get email id of user using facebook sdk 4.7 in ios 9

I am using pod for Facebook sdk and it's work in iOS9.0 with xcode 7.1. Try this code

    void (^sendRequestsBlock)(void) = ^{

FBSDKGraphRequest *postRequest = nil;
NSDictionary *parameters = [NSDictionary dictionaryWithObject:@"id,email,first_name,last_name,name,picture{url}" forKey:@"fields"];

postRequest = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:parameters HTTPMethod:@"GET"];
[postRequest startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error)
{
if (!error) {
NSDictionary *dictResult = (NSDictionary *)result;

}
}];
};

/// login start
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logOut];
NSArray *permissions = [NSArray arrayWithObjects:@"email",@"public_profile", nil];

[login logInWithReadPermissions:permissions fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {

} else if (result.isCancelled) {

} else {

if ([result.grantedPermissions containsObject:@"email"]) {

sendRequestsBlock();

}
}
}]

login with facebook in Xcode and iOS 9 with objective C

last night struggle this problem i got correct Answer for my problem

    - (IBAction)loginFBAction:(id)sender{
UIButton *button=sender;
if ([button isSelected]) {
// [fb facebookLogOut];
[button setSelected:NO];
}else{
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login
logInWithReadPermissions: @[@"public_profile",@"user_friends",@"email",@"user_birthday"]
fromViewController:self
handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
NSLog(@"Process error");

} else if (result.isCancelled) {
NSLog(@"Cancelled");

} else {
NSLog(@"Logged in");
[self checkUser];
}
}]; [button setSelected:YES];
}
}
- (void)checkUser{
NSMutableDictionary* parametersDic = [NSMutableDictionary dictionary];
[parametersDic setValue:@"id, name, email, birthday, picture" forKey:@"fields"];

FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"me"
parameters:parametersDic
HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
NSLog(@"result %@",result);
NSString* nameFB = [result objectForKey:@"name"];
NSString* emailFB = [result objectForKey:@"email"];
}];
}

this is code but you need to make sure that you have enable the your app from FB developer page if you are not enable that your application will not work i am showing here the pic of that enter image description here

here you are seeing green light side of app name for enable this green you need to go APP review option and public you app like this enter image description here

now you will be able to lunch your application and get access for the fb login.

FBSDK 4.7.0 and iOS 9 Invite friends not getting notification

You can visit the link below. i have the same problem and this must help

FBSDKAppInviteDialog in Facebook iOS SDK version 4.0.1 invite successfully sent, but no notifications received

1) You invited Facebook user who already used your app

2) Must be a live Apple App id in App Setting Facebook

3) If user already installed your app. you can assign them as a tester then they always receive your notification.

Hope this help :)

Facebook SDK login never calls back my application on iOS 9

Turns out that on iOS 9 when UIApplicationDelegate's application:openURL:options: is implemented, application:openURL:sourceApplication:annotation: will not get called.

So what I had to do is call FBSDKApplicationDelegate's application:openURL:sourceApplication:annotation: from UIApplicationDelegate's application:openURL:options:

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options {
return [[FBSDKApplicationDelegate sharedInstance] application:app
openURL:url
sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
}


Related Topics



Leave a reply



Submit