简体   繁体   English

Firebase与模拟器连接,但未在真实设备iOS中连接

[英]Firebase connecting with simulator but not in real device iOS

I am developing a app which has the connection with Firebase DB. 我正在开发与Firebase DB有连接的应用程序。 This is one part of my code, 这是我代码的一部分,

let ref1 = Database.database().reference()
ref1.child("UserId").child("\(user_id)").setValue(["name": "\(name)"])

And this one is working fine in simulator(updating value in firebase DB), but not in real device. 而且这一程序在模拟器中工作正常(在Firebase DB中更新值),但在实际设备中却没有。 I have tried some solutions from this site, still I can't get the output. 我已经从该站点尝试了一些解决方案,但仍然无法获得输出。

Is anyone there to help me? 有谁可以帮助我吗?

This could be because you are not authenticated on your device or any other reasons. 这可能是因为您未在设备上进行身份验证或任何其他原因。 In order to debug it, I suggest you to add a completion block for your setValue which is going to be called whenever the write has been committed to the database. 为了对其进行调试,建议您为setValue添加一个完成块,只要将写入提交到数据库,就会调用该完成块。 If the call was unsuccessful for any reasons, you can get the error object and take a look at the error. 如果由于某种原因调用失败,则可以获取错误对象并查看错误。

yourRef.setValue(["name": "\(name)"]) { (error, dbRef) in
   if (error != nil) {
     //catch the error here 
     print("Data could not be saved.")
   } else {
      print("Data saved successfully!")
  }
}

At last, the issue was the real device's date and time. 最后,问题是真实设备的日期和时间。 The date and time was incorrect in my device. 我的设备中的日期和时间不正确。 So, the connection with firebase DB failed. 因此,与Firebase DB的连接失败。 Now, it's fixed. 现在,它已修复。 Thanks for you suggestions!! 谢谢你的建议!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase 在 ios 模拟器上运行良好,但在真实设备上不起作用 - Firebase works fine on ios simulator but it does't work on real device 模拟器和iOS设备表查看Firebase - Simulator and iOS device tableView Firebase Firebase数据库在模拟器和真实设备中不响应 - Firebase Database not respond in Simulator and Real Device iOS模拟器崩溃而真实设备没有崩溃 - iOS Simulator crashes while real device does not free()使用iOS Simulator,但不能在实际设备上使用 - free() working with iOS Simulator but not on real device 在真实设备中编译但在模拟器iOS 8中编译时出错 - Error compiling in real device but not simulator iOS 8 iOS应用可在模拟器上运行,但不能在真实设备上运行 - iOS app works on simulator but not on real device 在iOS模拟器和真实设备之间从Firebase获取不同的结果 - Getting different results reading from Firebase between iOS simulator and real device iOS Firebase Crashlytics ::出现了模拟器的测试崩溃,但没有出现设备的真正崩溃 - iOS Firebase Crashlytics :: Test crash from simulator appears, but real crash from device doesn't iOS-在真实设备上连接到数据库时出错 - iOS - Error connecting to db on real device
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM