Skip to content
This repository has been archived by the owner on Nov 2, 2019. It is now read-only.

Improve ambiguous logIn() function names in LoginManager. #95

Closed
nitisha1 opened this issue Nov 7, 2016 · 6 comments
Closed

Improve ambiguous logIn() function names in LoginManager. #95

nitisha1 opened this issue Nov 7, 2016 · 6 comments
Assignees

Comments

@nitisha1
Copy link

nitisha1 commented Nov 7, 2016

Hi,
I've integrated facebook-sdk-swift manually in my ios project in xcode8 following documents (https://developers.facebook.com/docs/swift/getting-started). I'm getting error "Ambiguous reference to memeber logIn(_:viewController:completion:)"on

loginManager.logIn(["public_profile","email"], viewController: self) { loginResult in switch loginResult { case .Failed(let error): print(error) case .Cancelled: print("User cancelled login.") case .Success(let grantedPermissions, let declinedPermissions, let accessToken): print("Logged in!") }
what i've done wrong any help please?

@nlutsenko
Copy link
Contributor

Hey @nitisha1,

Unfortunately, without more code around this - it could be very tricky to help you.
Though, I believe I have an idea on why this is failing...
Looks like you are using plain strings for permissions, which can be ambiguous, as the Swift compiler won't know whether to use

func logIn(_ permissions: [ReadPermission] = [.publicProfile],
                    viewController: UIViewController? = nil,
                    completion: ((LoginResult) -> Void)? = nil)

or

func logIn(_ permissions: [PublishPermission] = [.publishActions],
                    viewController: UIViewController? = nil,
                    completion: ((LoginResult) -> Void)? = nil)

Here is the updated method signature that I recommend replacing it with:

loginManager.logIn([ .public_profile, .email ], viewController: self) {
...
}

This will eliminate the ambiguousness and will let you compile.
Also, let me keep this open as a follow-up, since I believe we can improve these method names.

@nitisha1 nitisha1 added the enhancement Adds a feature or improvement label Nov 7, 2016
@nitisha1 nitisha1 changed the title Ambiguous reference to LoginManager Improve ambiguous logIn() function names in LoginManager. Nov 7, 2016
@nitisha1 nitisha1 removed the enhancement Adds a feature or improvement label Nov 7, 2016
@nitisha1
Copy link
Author

nitisha1 commented Nov 8, 2016

@nlutsenko thanks a lot ,it worked.

@flavian-iapp
Copy link

don't work for me

@bj97301
Copy link

bj97301 commented Mar 8, 2017

I am not using strings and still getting this error.

@JaapWeijland
Copy link

Me too.

@krishcdbry
Copy link

Me too

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants