Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- import FBSDKCoreKit
- import FBSDKLoginKit
- import FBSDKShareKit
- class ViewController: UIViewController, FBSDKLoginButtonDelegate {
- override func viewDidLoad() {
- super.viewDidLoad()
- var loginButton:FBSDKLoginButton = FBSDKLoginButton()
- loginButton.center = self.view.center
- self.view.addSubview(loginButton)
- loginButton.delegate = self
- var contentShare:FBSDKShareLinkContent = FBSDKShareLinkContent()
- var button:FBSDKShareButton = FBSDKShareButton()
- button.frame = CGRectMake(200,500,100,50)
- var contentURL = NSURL(string: "https://xxx/")
- var imgURL = NSURL(string: "xxx.png")
- contentShare.imageURL = imgURL
- contentShare.contentURL = contentURL
- contentShare.contentTitle = "Tech Blog-"
- contentShare.contentDescription = "Great, do you like this?"
- button.shareContent = contentShare
- self.view.addSubview(button)
- }
- func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
- print("Login success!")
- // loadProfile()
- // // load avatar
- // var hinh = FBSDKProfilePictureView(frame: CGRectMake(view.frame.size.width/2, 100, 100, 100))
- // self.view.addSubview(hinh)
- // FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init];
- // dialog.fromViewController = self;
- // dialog.content = content;
- // dialog.mode = FBSDKShareDialogModeShareSheet;
- // [dialog show];
- }
- func loginButtonDidLogOut(loginButton: FBSDKLoginButton!) {
- print("Logout success!")
- }
- func loadProfile(){
- var request:FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me?fields=id,name,gender", parameters: nil)
- request.startWithCompletionHandler({
- (connection,result,error)-> Void in
- if error != nil {
- print("Error load Profile")
- } else {
- print("Result: \(result)")
- }
- })
- }
- override func didReceiveMemoryWarning() {
- super.didReceiveMemoryWarning()
- // Dispose of any resources that can be recreated.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement