I've create a workable Cloud Function using Firebase in which works using my browser. Now, I'm working with my iOS Swift code, and have successfully installed all dependencies.
However, I'm new to iOS/Swift and try to figure out where to call the URL from the Cloud Function? Here is the code Firebase provides to call from within an iOS App:
functions.httpsCallable("addMessage").call(["text": "test"]) { (result, error) in
if let error = error as NSError? {
if error.domain == FunctionsErrorDomain {
let code = FunctionsErrorCode(rawValue: error.code)
let message = error.localizedDescription
let details = error.userInfo[FunctionsErrorDetailsKey]
}
// ...
}
if let text = (result?.data as? [String: Any])?["text"] as? String {
print(text) // WOULD EXPECT A PRINT OF THE CALLABLE FUNCTION HERE
}
}
Here's the callable Cloud Function (which is deployed):
exports.addMessage = functions.https.onCall((data, context) => {
const text = data.text;
return {
firstNumber: 1,
secondNumber: 2,
operator: '+',
operationResult: 1 + 2,
};
});
As of now, I see nothing printed in my XCode console, expect the callable function. Thank you!