Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
205 views
in Technique[技术] by (71.8m points)

ios - Is there a race condition when using cloud functions inside a UIAlertController action?

I using a native UIAlertController action in my app to allow a user to report an individual post, and I'm using Firebase to create a data structure for these reports. However, for whatever reason, the cloud function is not being executed, and I'm wondering whether this is due to some race condition that's related to using the UIAlertController. I'm able to execute a print statement inside the handler, so there's nothing wrong with the alert action per se.

Below is my code.

let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
        
        // Report Post
        alertController.addAction(UIAlertAction(title: "Report", style: .default, handler: { (_) in
            
            print("you've pressed report")
            
            guard let postId = self.post?.postId else { return }
            guard let uid = Auth.auth().currentUser?.uid else { return }
            let creationDate = Int(NSDate().timeIntervalSince1970)
    
            let values = ["creationDate": creationDate,
                          "uid": uid] as [String : Any]
    
            REPORT_REF.child(postId).childByAutoId().updateChildValues(values)

        }))
        
        alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
        
        present(alertController, animated: true, completion: nil)
question from:https://stackoverflow.com/questions/65947166/is-there-a-race-condition-when-using-cloud-functions-inside-a-uialertcontroller

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...