【问题标题】:Firebase auth anonymous in Swift2Swift2 中的 Firebase 身份验证匿名
【发布时间】:2016-12-22 16:39:50
【问题描述】:

我正在尝试将 Firebase 后端集成到我的应用中。

创建了我的 podfile
pod 'Firebase'

使用 sdk 导入一切正常

在我的第一个视图控制器中:

    import Firebase

     override func viewDidLoad() {
        super.viewDidLoad()
        let ref = Firebase(url: "https://<YOUR-FIREBASE-APP>.firebaseio.com")
ref.authAnonymouslyWithCompletionBlock { error, authData in
          if error != nil {
             // There was an error logging in anonymously
          } else {
             // We are now logged in
          }
        }
     }

但我有一个Can not call value of non-function type error

提前致谢

【问题讨论】:

  • 您使用的是哪个版本的 firebase??
  • 在 podfile 中我没有提到这一点
  • @EICaptainv2.0 感谢您的链接,我认为每个定义都已更改
  • @EICaptainv2.0 使用 parse.com 后,真是一种折磨

标签: ios swift xcode firebase firebase-authentication


【解决方案1】:

所以他们改变了您使用 pod 安装 Firebase 的方式,现在您必须像这样添加单个 pod,而不仅仅是添加 pod 'Firebase'。

use_frameworks!

   target “Your Project” do
     pod 'Firebase/Core’
     pod 'Firebase/Database’
     pod 'Firebase/Auth’
end

但是,您只需要输入“import Firebase”,它就会涵盖与 Firebase 相关的所有 pod。并且不要忘记在 AppDelegate 的 didFinishLaunchingWithOptions 方法中配置 Firebase!

FIRApp.configure()

祝你好运!!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-08
    • 2017-06-03
    • 1970-01-01
    • 1970-01-01
    • 2019-01-17
    • 2020-12-15
    • 2018-07-16
    • 1970-01-01
    相关资源
    最近更新 更多