Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 来自firebase函数的错误消息显示';请求无效,无法处理;_Ios_Swift_Firebase_Google Cloud Functions - Fatal编程技术网

Ios 来自firebase函数的错误消息显示';请求无效,无法处理;

Ios 来自firebase函数的错误消息显示';请求无效,无法处理;,ios,swift,firebase,google-cloud-functions,Ios,Swift,Firebase,Google Cloud Functions,我编写一个函数并将其部署到firebase云函数中,然后在iOS中编写一个函数来调用它 云功能: exports.verifyApp=functions.https.onCall((数据,上下文)=>{ functions.logger.info(JSON.stringify(data)); 返回{ 代码:200,, msg:'这是来自函数的消息' } }) iOS功能: 导入FirebaseFunctions 导入UIKit 类ViewController:UIViewController{

我编写一个函数并将其部署到firebase云函数中,然后在iOS中编写一个函数来调用它

云功能:
exports.verifyApp=functions.https.onCall((数据,上下文)=>{
functions.logger.info(JSON.stringify(data));
返回{
代码:200,,
msg:'这是来自函数的消息'
}
})
iOS功能:
导入FirebaseFunctions
导入UIKit
类ViewController:UIViewController{
let label:UILabel=UILabel()
let button=UIButton(帧:CGRect(x:(UIScreen.main.bounds.width-100)/2,y:100,width:100,height:50))
重写func viewDidLoad(){
super.viewDidLoad()
button.setTitleColor(.black,表示:。正常)
按钮.setTitle(“单击”,表示:。正常)
button.addTarget(self,action:#选择器(测试),for:.touchUpInside)
view.addSubview(按钮)
label.frame=CGRect(x:20,y:140,宽度:UIScreen.main.bounds.width-40,高度:100)
label.textColor=.blue
label.textAlignment=.center
label.numberOfLines=0
view.addSubview(标签)
}
@objc专用函数测试(){
button.isEnabled=false
label.text=“请求已启动”
打印(“请求已启动”)
Functions.Functions().httpscalable(“verifyApp”)
.调用{[weak self]结果,出现错误
guard let self=self-else{return}
self.button.isEnabled=true
打印(“响应=>结果:\(字符串(描述:结果));错误:\(字符串(描述:错误)))
如果let error=error{
self.label.text=error.localizedDescription
}否则{
如果let res=result?.data as?[字符串:任意]{
打印(“结果:\(res)”)
var text:String=“”
res.forEach{(键,值)在
文本+=“\(键)=\(值)|”
}
self.label.text=文本
}
}
}
}
}
现在,它总是显示:

请求无效,无法处理

我现在能做什么?如何解决这个问题?有人能帮我吗