【发布时间】:2019-06-04 12:39:54
【问题描述】:
我已将一个 iOS 应用程序添加到一个 firebase 项目,由于某种原因,当我从 iOS 调用它时,该函数没有被调用。与 Firebase 的连接似乎很好,因为我可以在 swift 项目中对 Firebase 数据库运行查询,但是当我运行 swift 云功能时,它似乎绕过了代码。
以下是我创建的测试云功能,只是为了调查:
exports.testFunction = functions.https.onCall((data,context) => {
console.log("hi the test function worked");
return "hi the test function worked";
})
这是我用来调用函数的快速代码,
lazy var functions = Functions.functions()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
functions.httpsCallable("testFunction").call("Hi", completion: {(result,error) in
if let error = error{
print("An error occurred while calling the test function: \(error)" )
}
print("Results from test cloud function: \(result)")
})
return true
}
我已尝试更新可可豆荚并创建新项目,但似乎没有任何效果。没有任何内容返回到我的 iOS 项目或登录到 Firebase 控制台。没有抛出任何错误,是否有人对可能导致这种奇怪事件发生的原因有任何想法?谢谢。
【问题讨论】:
-
你找到解决办法了吗,我卡住了
-
@yusuftezel 不,我向 firebase 提交了错误报告,但不知何故它自行解决了。 Firebase 似乎出现了某种故障或崩溃,因为它只是在 10 小时后自动恢复,而没有更改任何一行代码。
标签: ios swift firebase firebase-realtime-database google-cloud-functions