【问题标题】:Consecutive declarations on a line must be separated by ';' with regards to createstripeuser一行中的连续声明必须用';'分隔关于createstripeuser
【发布时间】:2022-01-07 04:22:53
【问题描述】:

我正在尝试从我的视图控制器中调用函数“createStripeUser”。它显示错误

这是我的视图控制器:-

import UIKit
import FirebaseFirestore
import FirebaseAuth
import Stripe
import FirebaseFunctions
class SignUpViewController: UIViewController {
var paymentContext = STPPaymentContext()
@IBOutlet weak var email: UITextField!
@IBOutlet weak var password: UITextField!
@IBOutlet weak var passwordConfirm: UITextField!
@IBAction func signUpAction(_ sender: Any) {
    if password.text != passwordConfirm.text {let alertController = UIAlertController(title: "Password Incorrect", message: "Please re-type password", preferredStyle: .alert)
        let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
           
alertController.addAction(defaultAction)
self.present(alertController, animated: true, completion: nil)
        }else{
Auth.auth().createUser(withEmail: email.text!, password: password.text!){ (user, error) in if error == nil {
   self.performSegue(withIdentifier: "signupToHome", sender: self)
    
                }
 else{
   let alertController = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: .alert)
   let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
                   
    alertController.addAction(defaultAction)
    self.present(alertController, animated: true, completion: nil)
       }
            }
      }
}
Functions.functions().httpsCallable("createStripeUser").call(["email": email]) { (result, error) in **// error - Consecutive declarations on a line must be separated by ';'**
    
    if let error = error {
        debugPrint(error.localizedDescription)
        return
    }
    
    self.dismiss(animated: true)
   }
 }

这是错误的屏幕截图

这些功能已完全部署在 Firebase 中。为什么显示错误?

【问题讨论】:

    标签: ios swift firebase google-cloud-functions stripe-payments


    【解决方案1】:

    您已在 signUpAction 函数的关闭 } 之后添加了对 Cloud Functions 的调用。如果您重新格式化代码,这会更容易看到:

    func signUpAction(_ sender: Any) {
        if password.text != passwordConfirm.text {
            let alertController = UIAlertController(title: "Password Incorrect", message: "Please re-type password", preferredStyle: .alert)
            let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
            alertController.addAction(defaultAction)
            self.present(alertController, animated: true, completion: nil)
        }
    
        else{
            Auth.auth().createUser(withEmail: email.text!, password: password.text!){
                (user, error) in if error == nil {
                    self.performSegue(withIdentifier: "signupToHome", sender: self)
                }
                else{
                    let alertController = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: .alert)
                    let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
                    alertController.addAction(defaultAction)
                    self.present(alertController, animated: true, completion: nil)
                }
            }
        }
    
    }
    Functions.functions().httpsCallable("createStripeUser").call(["email": email]) {
        (result, error) in **// error - Consecutive declarations on a line must be separated by ';'**
        if let error = error {
            debugPrint(error.localizedDescription)
            return
        }
    
        self.dismiss(animated: true)
    }
    

    我的猜测是,您希望 Functions.functions().httpsCallable("createStripeUser") 调用位于其上方的 } 之上,以便它成为 signUpAction 函数的一部分。

    【讨论】:

    • 是的,没错,错误消失了,谢谢。但它仍然没有创造一个条纹客户。我会问一个不同的问题
    • 支持您的回复
    • 更好。我的答案左侧有一个投票按钮。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多