Error in Facebook Login, iOS 9, Swift

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 Sample Image

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 Sample Image

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

Facebook login issue in Swift and iOS9

Try add this line into your Info.plist: <string>fbauth2</string>

Info.plist

facebook login issue in ios9

I think there are a couple things that could cause your problem.

1) Are you sure that you have added the most recent FBSDKCoreKit and FBSDKLoginKit and added these lines to the top of your swift file:

import FBSDKCoreKit
import FBSDKLoginKit

2) I have read that this is just an error on the simulator and should be ignored. Make sure that you are testing on a real device for this feature.

3) Have you included the FBSDKLoginButtonDelegate in the heading of your class declaration?

4) I would make sure that your info.plist source code is all included and correct. Here is what I have added for Facebook in my app:

<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string> fb + FACEBOOKAPPIDFROMTHEFACEBOOKDEVCONSOLE </string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>FACEBOOKAPPIDFROMTHEFACEBOOKDEVCONSOLE</string>
<key>FacebookDisplayName</key>
<string>NAME OF YOUR APP</string>

<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>facebook.com</key>
<dict>
<key>NSIncludesSubdomains</key> <true />
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/>
</dict>
<key>fbcdn.net</key>
<dict>
<key>NSIncludesSubdomains</key> <true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/>
</dict>
<key>akamaihd.net</key>
<dict>
<key>NSIncludesSubdomains</key> <true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/>
</dict>
</dict>
</dict>


Related Topics



Leave a reply



Submit