2016-08-01 21 views
0

我嘗試使用doc的火力提供。也許我錯誤地從obj轉換它。 C.請看下面。FBSDKLoginMangerLoginResult,NSError斯威夫特7.3.1

override func viewDidLoad() { 
    super.viewDidLoad() 

    facebookLoginBtn.addTarget(self, action: #selector(self.facebookLoginBtnPress), forControlEvents: .TouchUpInside) 
} 

    // MARK Facebook btn pressed 
    @IBAction func facebookLoginBtnPress(sender: AnyObject) { 

    let login = FBSDKLoginManager() 

    login.logInWithReadPermissions(["email"], fromViewController: self, handler: {(facebookResult: FBSDKLoginManagerLoginResult, facebookError: NSError?) -> Void in 

     if facebookError != nil { 

     } else if facebookResult.isCancelled { 
      let accessToken = FBSDKAccessToken.currentAccessToken().tokenString 
     } 
    }) 

} 

這是目標。 ç

// Handle clicks on the button 
[myLoginButton 
addTarget:self 
action:@selector(loginButtonClicked) forControlEvents:UIControlEventTouchUpInside]; 

// Once the button is clicked, show the login dialog 
-(void)loginButtonClicked 
{ 
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init]; 
[login 
    logInWithReadPermissions: @[@"public_profile"] 
     fromViewController:self 
       handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) { 
    if (error) { 
     NSLog(@"Process error"); 
    } else if (result.isCancelled) { 
     NSLog(@"Cancelled"); 
    } else { 
     NSLog(@"Logged in"); 
    } 
    }]; 
} 

這是錯誤

無法將類型的價值 - '!FBSDKLoginMangerRequestTokenHandler' '(FBSDKLoginMangerLoginResult,NSError?)>虛空' 預期參數類型

回答

1

//使用此方法在登錄與FB butn - (無效)loginWithFbBtnMethode { FBSDKLoginManager *登錄= [[FBSDKLoginManager的alloc] INIT];

if ([FBSDKAccessToken currentAccessToken]) 
{ 
    NSLog(@"Token is available : %@",[[FBSDKAccessToken currentAccessToken]tokenString]); 
    [self fetchUserInfo]; 
} 
else 
{ 
    [login logInWithReadPermissions:@[@"email"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) 
    { 
     if (error) 
     { 
      [self.view makeToast:@"Login process error" duration:2.0 position:@"center"]; 
      NSLog(@"Login process error"); 
     } 
     else if (result.isCancelled) 
     { 
      [self.view makeToast:@"User cancelled login" duration:2.0 position:@"center"]; 
      NSLog(@"User cancelled login"); 
     } 
     else 
     { 
      NSLog(@"Login Success"); 
      if ([result.grantedPermissions containsObject:@"email"]) 
      { 
       NSLog(@"result is:%@",result); 
       [self fetchUserInfo]; 
      } 
      else 
      { 
      } 
     } 
    }]; 
} 

}

//用戶細節越來越方法

0

對不起,我只是在尋找,我只是被迫拆開FBSDKLoginMangerLoginResult不知道這是很好的做法,但現在的工作。

0

我也有這麼多的錯誤7.3.1當使用FB或Gmail和開發者證書創建這樣嘗試降級到7.2.1它是罰款的任何地方。