Reputation: 1839
I try to check if a logged in FB User has the needed permissions. I try it like this in Swift:
let permissions : Set<String> = ["public_profile", "user_friends"];
NSLog("Contains Permissions:%@",FBSDKAccessToken.currentAccessToken()
.permissions.contains(permissions));
NSLog always returns 0, even though the permissions in the currentAccessToken and in the permissions variable are equal to each other.
My guess is, that I am doing something wrong while comparing the 2 Set´s, I hope some of you can help ;)
Upvotes: 1
Views: 3953
Reputation: 1704
for checking facebook permission..& give a permission
var login: FBSDKLoginManager = FBSDKLoginManager()
login.logInWithReadPermissions(["public_profile", "user_friends"], handler: { (result:FBSDKLoginManagerLoginResult!, error:NSError!) -> Void in
if (error != nil)
{
//Process error
}
else if result.isCancelled
{
//Handle cancellations
}
else
{
// If you ask for multiple permissions at once, you
// should check if specific permissions missing
if result.grantedPermissions.contains("user_friends"){
//Do work
}
}
})
If you want to more information about facebook with swift then read follow link...
http://www.brianjcoleman.com/tutorial-how-to-use-login-in-facebook-sdk-4-0-for-swift/
May be this will help you.
Upvotes: 3