使Facebook用户可以发帖

时间:2018-11-09 23:53:04

标签: ios swift firebase-realtime-database firebase-authentication facebook-login

我能够设置我的应用程序,以便用户可以使用电子邮件和密码注册并能够发布帖子,但是当我集成了Facebook登录名后,我无法发布任何帖子(写入Firebase) ,我调查了这些用户可能需要的权限,但找不到任何东西。以下是我发布到firebase的代码

    @IBAction func handlePostButton(_ sender: Any) {

    guard let userProfile = UserService.currentUserProfile else { return }


    //Firebase code
    //Lets make a reference to the database
    let postref = Database.database().reference().child("posts").childByAutoId()    //This will assign this post a specific identifier that we can reference it by.
    //This is referencing the place where you write a post
    let postObject = [
        "author":[
            "uid": userProfile.uid,
            "photoURL": userProfile.photoURL.absoluteString,
            "username": userProfile.username
        ],
        "text": textView.text,
        "timestamp": [".sv": "timestamp"]           //This is actually getting the time from Firebase, this is a server value.
    ] as [String:Any]
    postref.setValue(postObject, withCompletionBlock: {Error, ref in
        if Error == nil {
            self.dismiss(animated: true, completion: nil)
        }else {

            self.creatAlert(title: "Error", message: "Error making a Post!")
        }
    })

}

不确定我还应该提出什么。

0 个答案:

没有答案