Preview:
    func addPonits(_ fieldName : String, _ points : Int,_ message : String) {
        
        let data = [
            fieldName : FieldValue.increment(Int64(points))
        ]
        
        let db = Firestore.firestore()
        let docRef = db.collection("Games").document(gameID)
        docRef.updateData(data) { error in
            if let error = error {
                print("Error updating document: \(error.localizedDescription)")
            } else {
                print("Document successfully updated")
                self.showToast(message: message)
            }
        }
    }
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter