Can't create new user using Parse 1.7.2 and Facebook SDK 4.1 in Xcode using Swift

Armin

I've linked my app to both the Facebook SDK and Parse, but now I'm trying to integrate Facebook's login with Parse but keep running into issues. My current issue is that the app runs, but when I press the FBSDKLoginButton, it will go to safari and ask for permissions (as it should), but then when pressing okay, it simply returns to the app's login screen like nothing happened and does not perform the segue to the rest of the app. I also checked Parse and it did not create a new PFUser. I will post the code I think may be relevant from my LoginViewController below (that means the code will be missing sections like my viewDidLoad for it has nothing in it that affects the login process):

import UIKit
import Parse
import FBSDKCoreKit
import FBSDKLoginKit

protocol LoginViewControllerDelegate {
    func onRegister(loginViewController : LoginViewController)
    func onFacebookLogin(loginViewController : LoginViewController)
    func onLogin(loginViewController : LoginViewController)
}

class LoginViewController: UIViewController {

@IBAction func onFacebookLogin(sender: AnyObject?) {

    // Set permissions required from the facebook user account
    let permissions = [ "user_about_me", "user_relationships", "user_location", "user_birthday", "public_profile", "user_friends", "user_email", "user_gender"]

    // Login PFUser using Facebook
    PFFacebookUtils.logInInBackgroundWithReadPermissions(permissions, block: {
        (user: PFUser?, error: NSError?) -> Void in
        if let user = user {
            if user.isNew {
                println("User signed up and logged in through Facebook!")
                self.loadData()
                self.performSegueWithIdentifier("loggedIn", sender: self)
            } else {
                println("User logged in through Facebook!")
                self.performSegueWithIdentifier("loggedIn", sender: self)
            }
            if self.delegate != nil {
                self.delegate!.onFacebookLogin(self)
            }
        } else {
            println("Uh oh. The user cancelled the Facebook login.")
        }
    })
}

func loadData(){
    let request:FBSDKGraphRequest = FBSDKGraphRequest()
    request.startWithCompletionHandler { (connection:FBSDKGraphRequestConnection!, result:AnyObject!, error:NSError!) -> Void in
        if error == nil{
            if let dict = result as? Dictionary<String, AnyObject>{
                let name:String = dict["first_name"] as AnyObject? as! String
                let facebookID:String = dict["id"] as AnyObject? as! String
                let email:String = dict["email"] as AnyObject? as! String
                let birthday:String = dict["birthday"] as AnyObject? as! String
                let gender:String = dict["gender"] as AnyObject? as! String

                let hostCount:Int = 0
                let attendCount:Int = 0

                let pictureURL = "https://graph.facebook.com/\(facebookID)/picture?type=large&return_ssl_resources=1"

                var URLRequest = NSURL(string: pictureURL)
                var URLRequestNeeded = NSURLRequest(URL: URLRequest!)


                NSURLConnection.sendAsynchronousRequest(URLRequestNeeded, queue: NSOperationQueue.mainQueue(), completionHandler: {(response: NSURLResponse!,data: NSData!, error: NSError!) -> Void in
                    if error == nil {
                        var picture = PFFile(data: data)
                        PFUser.currentUser()!.setObject(picture, forKey: "profilePicture")
                        PFUser.currentUser()!.saveInBackground()
                    }
                    else {
                        println("Error: \(error.localizedDescription)")
                    }
                })
                PFUser.currentUser()!.setValue(name, forKey: "name")
                PFUser.currentUser()!.setValue(email, forKey: "email")
                PFUser.currentUser()!.setValue(birthday, forKey: "birthday")
                PFUser.currentUser()!.setValue(gender, forKey: "gender")
                PFUser.currentUser()!.setValue(hostCount, forKey: "hostCount")
                PFUser.currentUser()!.saveInBackground()
            }
        }
    }
}
}
Armin

After updating to Parse 1.7.4 and deleting the old PFFacebookUtils Framework (keeping the PFFacebookUtilsV4) seems to have fixed the problem by itself! I hope this answer helps other people with the same problem.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Using foreach loop container to create new columns in a table- can't solve "incorrect syntax near '@P1'" error

分類Dev

Create list of T2 from list of T1, using T2's constructor that requires T1

分類Dev

Cannot get user profile using Facebook's PHP SDK in Laravel 4

分類Dev

How to access user languages inside GraphObject using Facebook PHP SDK v4

分類Dev

Can't create simulator in Xcode 7

分類Dev

Combine elements of 1 array to create a new array using a for-loop

分類Dev

Using Google Maps SDK with Parse.com Project iOS Swift

分類Dev

Using Swift generics to create new NSManagedObjects

分類Dev

Can't log in to facebook accounts using pidgin

分類Dev

Get Facebook user details with swift and parse

分類Dev

Create a new user in Azure Active Directory (B2C) with Graph API, using http post request

分類Dev

Xcode 7 beta 1 view doesn't fit

分類Dev

PHP - Can't create new Google Calendar event using an API Key

分類Dev

Mysql ERROR 1045 (28000) at line 1: Access denied for user 'abc'@'slave4' (using password: YES)

分類Dev

User Session becomes null on page change when using Parse Javascript SDK

分類Dev

Parse an entire JSON array into a table using 1 key

分類Dev

Bash scripting using #1 & #2 params but if files not found reverting to read from user

分類Dev

How to differentiate Bot to user AND user to Bot messages using middleware in bot builder sdk v4?

分類Dev

How to create a 2D Numpy array using a function on a 1D array?

分類Dev

Keeping score in XCode using swift

分類Dev

Parse Server Aggregation using PHP SDK

分類Dev

Register a Facebook user on Parse

分類Dev

Swift xcodeエラー:スレッド1:EXC_BAD_ACCESS(code = 2、address = 0x7ff54b59ff8)

分類Dev

PHP: User status logged in or out - USER1 logged in but USER2 can logout USER1

分類Dev

Using Python and Numpy to blend 2 images into 1

分類Dev

Why does 1 / 2 == 0 using double?

分類Dev

If I build using iOS7 SDK, will my app have the new look on older devices?

分類Dev

Zend 1 to Zend 2, was using decorators, how can i achieve the same behavior now?

分類Dev

New column based on 1 condition using index and one column groupby

Related 関連記事

  1. 1

    Using foreach loop container to create new columns in a table- can't solve "incorrect syntax near '@P1'" error

  2. 2

    Create list of T2 from list of T1, using T2's constructor that requires T1

  3. 3

    Cannot get user profile using Facebook's PHP SDK in Laravel 4

  4. 4

    How to access user languages inside GraphObject using Facebook PHP SDK v4

  5. 5

    Can't create simulator in Xcode 7

  6. 6

    Combine elements of 1 array to create a new array using a for-loop

  7. 7

    Using Google Maps SDK with Parse.com Project iOS Swift

  8. 8

    Using Swift generics to create new NSManagedObjects

  9. 9

    Can't log in to facebook accounts using pidgin

  10. 10

    Get Facebook user details with swift and parse

  11. 11

    Create a new user in Azure Active Directory (B2C) with Graph API, using http post request

  12. 12

    Xcode 7 beta 1 view doesn't fit

  13. 13

    PHP - Can't create new Google Calendar event using an API Key

  14. 14

    Mysql ERROR 1045 (28000) at line 1: Access denied for user 'abc'@'slave4' (using password: YES)

  15. 15

    User Session becomes null on page change when using Parse Javascript SDK

  16. 16

    Parse an entire JSON array into a table using 1 key

  17. 17

    Bash scripting using #1 & #2 params but if files not found reverting to read from user

  18. 18

    How to differentiate Bot to user AND user to Bot messages using middleware in bot builder sdk v4?

  19. 19

    How to create a 2D Numpy array using a function on a 1D array?

  20. 20

    Keeping score in XCode using swift

  21. 21

    Parse Server Aggregation using PHP SDK

  22. 22

    Register a Facebook user on Parse

  23. 23

    Swift xcodeエラー:スレッド1:EXC_BAD_ACCESS(code = 2、address = 0x7ff54b59ff8)

  24. 24

    PHP: User status logged in or out - USER1 logged in but USER2 can logout USER1

  25. 25

    Using Python and Numpy to blend 2 images into 1

  26. 26

    Why does 1 / 2 == 0 using double?

  27. 27

    If I build using iOS7 SDK, will my app have the new look on older devices?

  28. 28

    Zend 1 to Zend 2, was using decorators, how can i achieve the same behavior now?

  29. 29

    New column based on 1 condition using index and one column groupby

ホットタグ

アーカイブ