facebookarchive / account-kit-samples-for-ios

Samples for the account kit product on ios.
43 stars 26 forks source link

'AccessToken' is ambiguous for type lookup in this context #28

Closed marcellofiore closed 5 years ago

marcellofiore commented 5 years ago

After updating the sdk, I have this error => ('AccessToken' is ambiguous for type lookup in this context) on method => func viewController(viewController: UIViewController!, didCompleteLoginWithAccessToken accessToken: AccessToken!, state: String!)

I want to clarify that: I use it in the same ViewController FBSDKCoreKit and FBSDKLoginKit for facebook Login, if I remove import FBSDKCoreKit and import FBSDKLoginKit the problem is solved.

Can anyone help me?

robtimp commented 5 years ago

I'd recommend moving your AKFViewControllerDelegate conformance to a separate file due to the collision between the AccessToken types:

// ViewController+AccountKit.swift

import AccountKit

extension ViewController: AKViewControllerDelegate {

  func viewController(_ viewController: UIViewController & AKFViewController, didCompleteLoginWith accessToken: AccessToken, state: String) {
    ...
  }

}

Then, remove import AccountKit from your current file.

danielrobleM commented 5 years ago

I have the same issue and that solution doesn't work for me. Any others solutions ? @robtimp what did you do ? @marcellofiore

eduardofiorezi commented 5 years ago

Use FBSDKCoreKit.AccessToken

func viewController(viewController: UIViewController!, didCompleteLoginWithAccessToken accessToken: FBSDKCoreKit.AccessToken!, state: String!) {
        print("did complete login with access token \(accessToken.tokenString) state \(state)")
    }
Shrikant-iOS commented 5 years ago

Use FBSDKCoreKit.AccessToken

func viewController(viewController: UIViewController!, didCompleteLoginWithAccessToken accessToken: FBSDKCoreKit.AccessToken!, state: String!) {
        print("did complete login with access token \(accessToken.tokenString) state \(state)")
    }

Instance method 'viewController(:didCompleteLoginWith:state:)' nearly matches optional requirement 'viewController(:didCompleteLoginWith:state:)' of protocol 'AKFViewControllerDelegate'

robtimp commented 5 years ago

I think this issue here may be that this doesn't match the new method signature for this protocol, which is func viewController(_ viewController: UIViewController & AKFViewController, didCompleteLoginWith accessToken: AccessToken, state: String)