Sometimes we want to design our own UI for "Sign In With Facebook" button instead of the original button that comes with FacebookSDK.
Swift:
let loginButton = FBSDKLoginButton()
loginButton.delegate = self
// Your Custom Permissions Array
loginButton.readPermissions =
[
"public_profile",
"email",
"user_about_me",
"user_photos"
]
// Hiding the button
loginButton.hidden = true
self.view.addSubview(loginButton)
// Simulating a tap for the actual Facebook SDK button
loginButton.sendActionsForControlEvents(UIControlEvents.TouchUpInside)
Objective-C:
FBSDKLoginButton *FBButton = [FBSDKLoginButton new];
// Your Custom Permissions Array
FBButton.readPermissions = @[@"public_profile",
@"email",
@"user_about_me",
@"user_photos"
];
FBButton.loginBehavior = FBSDKLoginBehaviorNative;
[FBButton setDelegate:self];
[FBButton setHidden:true];
[loginButton addSubview:FBButton];
[FBButton sendActionsForControlEvents:UIControlEventTouchUpInside];
You're done.