Search code examples
iosswiftparse-platformpassword-recovery

Parse Password Reset Error in iOS Swift


I am using the code below for password reset as declared in parse documentation: https://parse.com/docs/ios/guide#users-resetting-passwords However I get the error: "cannot invoke "requestPasswordResetForEmailInBackground" with an argument of type (string (bool!,nserror!)->Void)

The code I am using is:

  var emailVar = emailField.text
    PFUser.requestPasswordResetForEmailInBackground(emailVar) { (success: Bool, error: NSError!) -> Void in

        if (error == nil) {

            let alertView = UIAlertController(title: "Password recovery e-mail sent", message: "Please check your e-mail inbox for recovery", preferredStyle: .Alert)
            alertView.addAction(UIAlertAction(title: "Ok", style: .Default, handler: nil))
            self.presentViewController(alertView, animated: true, completion: nil)

        }else {

            let alertView = UIAlertController(title: "Could not found your e-mail", message: "There is no such e-mail in our database", preferredStyle: .Alert)
            alertView.addAction(UIAlertAction(title: "Ok", style: .Default, handler: nil))
            self.presentViewController(alertView, animated: true, completion: nil)

        }
    }

Solution

  • In new parse api error changed to an optional value, using like that :

    PFUser.requestPasswordResetForEmailInBackground(emailVar) {
            (success: Bool, error: NSError?) -> Void in
    
    }