我正在尝试将我的应用程序连接到Firebase。我遵循了执行此操作的步骤。我在Firebase中创建了一个项目。我下载了Google services.info文件。我将pod文件放入项目中。该项目在Xcode中运行,但不允许我连接到我的 将Firebase项目添加到服务器。
以下是我收到的错误消息。我什至在Safari中清除了我的缓存,但似乎无济于事。在我的应用程序委托中,我正在尝试测试我的项目以查看是否在Firebase数据库中检测到了它。以下是我在Xcode控制台中收到的错误。
":ResponseBody={
"error": {
"code": 400,
"message": "Permission denied. Could not access bucket sya2-moments-1e2c9.appspot.com. Please enable Firebase Storage for your bucket by visiting the Storage tab in the Firebase Console and ensure that you have sufficient permission to properly provision resources."
}
}, "
代码:
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
let dummyUser = User(uid: "123", username: "myUserNameDummy", bio: "My Dummy User", fullName: "My Dummy User", website: "My Dummy User", follows: [], followedBy: [], profileImage: UIImage(named: "1"))
dummyUser.save { (error) in
print(error)
}
return true
}
}
答案 0 :(得分:0)
只需在Firebase中检查您的规则。如果您想从Firebase Server写入和读取数据,则将其更改为“ true”,如下面的图像所示。
并用于这样的存储:
将以下代码添加到您的Firebase中,以确保用户安全:
var db: DatabaseReference!
override func viewDidLoad() {
super.viewDidLoad()
db = Database.database().reference()
// checkForPrivacy()
}
self.db.child("key").setValue(dummyUser, withCompletionBlock: {error ,ref in
if error != nil{
print("error")
}else{
print("ok")
}
})