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
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
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>
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
How to Open Amazon App from Within My App
Increase the Width of Content View Programmatically in Swift
Adding a Target to a Button Programmatically Throws an Error "Unrecognized Selector Sent to Class"
How to Add Storyboard Viewcontroller into Swiftui Project
Transfer Gestures on a Uiview to a Uitableview in Swift - iOS
Update Storyboard Constraint Using Code
Swift:Background Color Fading Animation (Spritekit)
How to Open a Local PDF File Using a Swiftui Button
How to Get Only Keys from Firebase
How to Get a Substring from a Specific Character to the End of the String in Swift 4
How to Call a View Controller Function from an iOS Appdelegate
Uitableview with Uiviewrepresentable in Swiftui
Mapbox Navigation Pod Unable to Install with Objectivec Where I am Using Xcode 9.2