Calling a Cloud Function from an iOS app looks like this:
var functions = Functions.functions()
functions.httpsCallable(name).call(data){ (result, error) in
// Code here
}
How can I send an error from my Cloud Function, so it will get picked up in the above code? For example:
Cloud Function:
exports.joinGame = functions.https.onCall((data, context) => {
return Error("The game is full")
})
SwiftUI:
var functions = Functions.functions()
functions.httpsCallable("joinGame").call(data){ (result, error) in
print(error) // "The game is full"
}