管理用户Presense' onDisconnect' Firebase和Swift?

时间:2018-04-27 05:26:06

标签: swift firebase firebase-authentication

我已使用Firebase / Facebook Auth在我的应用中构建了身份验证,现在我想在我的应用中构建一个管理用户存在的系统(例如;更新&# 39; Firebase上的状态'字段,用户可以在Firebase Docs here

中说明在​​线或离线')

*我的问题是......我在哪里放置所有这些管理presense代码?,这是我的' signIntoFirebase'功能。我会创建一个名为' manageUserPresense'在firebaseLoginComplete'?

之后直接调用它
    func signIntoFirebase(firebaseLoginComplete: @escaping (_ status: Bool, _ error: Error?) -> ()){

    //Getting FB authentication
    guard let authenticationToken = AccessToken.current?.authenticationToken else { return }

    //Getting credential using authentication token
    let credential = FacebookAuthProvider.credential(withAccessToken: authenticationToken)

    //Signing in to Firebase using FB authentication token
    Auth.auth().signIn(with: credential) { (user, error) in
        if let error = error { //if there is an error
            print (error)
            firebaseLoginComplete(false, error)
            return
        }

        firebaseLoginComplete(true, nil)
        self.isLoggedIn = true

        print ("Successfully authenticated into Firebase")
    }

}//end func

0 个答案:

没有答案