我有一个 Xcode 应用程序(用 Swift 编写),它调用部署在 Firebase 中的 HTTP python 函数。它应该得到一个响应作为回报,但由于某种原因,它总是在数据为零时返回。
// swift function in xcode
Functions.functions().httpsCallable("python_callable").call(["ID": ID, "time": String(currentTime)]) { (result, error) in
if error != nil {
//does not enter this
return
}
else {
guard let data = result?.data as? Data else {return}
print(data)
}
}
Run Code Online (Sandbox Code Playgroud)
以下是用Python编写的谷歌云函数。根据Google Cloud 文档,Firebase 功能使用 Flask 来处理 HTTP 请求。
#deployed python Firestore function
import Flask
def python_callable(request):
** processes firestore data **
result = {"text":"example", "score": 100}
return jsonify(data=result)
Run Code Online (Sandbox Code Playgroud)
我知道 python_callable …