I\'m new with iOS development. I have to integrate Facebook login in my iOS app, as user logs in it fetches all the info and navigates it to home screen. I have done this via Fa
Facebook login using Accounts and social framework (swift)
var facebookAccount: ACAccount?
let options: [NSObject : AnyObject] = [ACFacebookAppIdKey: "YOUR_FACEBOOK_API_KEY", ACFacebookPermissionsKey: ["publish_stream","publish_actions"],ACFacebookAudienceKey:ACFacebookAudienceFriends]
let accountStore = ACAccountStore()
let facebookAccountType = accountStore.accountTypeWithAccountTypeIdentifier(ACAccountTypeIdentifierFacebook)
accountStore.requestAccessToAccountsWithType(facebookAccountType, options: options) { (granted, error) -> Void in
if granted
{
let accounts = accountStore.accountsWithAccountType(facebookAccountType)
self.facebookAccount = accounts.last as? ACAccount
let accountsArray=accountStore.accountsWithAccountType(facebookAccountType) as NSArray
self.facebookAccount=accountsArray.lastObject as? ACAccount
var dict:NSDictionary
dict=NSDictionary()
dict=self.facebookAccount!.dictionaryWithValuesForKeys(["properties"])
let properties:NSDictionary=dict["properties"] as! NSDictionary
print("facebook Response is-->:%@",properties)
}
else
{
if error.code == Int(ACErrorAccountNotFound.rawValue) {
dispatch_async(dispatch_get_main_queue(), { () -> Void in
self.displayAlert("There is no Facebook accounts configured. you can add or created a Facebook account in your settings.")
})
} else {
dispatch_async(dispatch_get_main_queue(), { () -> Void in
self.displayAlert("Permission not granted For Your Application")
})
}
}
}