如何使用Swift将Firebase集成到ios应用中?

时间:2018-10-17 06:41:57

标签: ios swift firebase firebase-invites

我想通过firebase集成我的应用程序,我遵循以下步骤:https://firebase.google.com/docs/invites/ios,但它显示出用户必须登录的错误。

AppDeleget:

@available(iOS 9.0, *)
    func application(_ application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
        return self.application(application, open: url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String, annotation: "")
    }

    internal func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {


        if GIDSignIn.sharedInstance().handle(url, sourceApplication: sourceApplication, annotation: annotation) {
            return true
        }

        return Invites.handleUniversalLink(url) { invite, error in
            // ...
        }

         return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
    }

我的InviteVC

@IBAction func BtnActionInvtation(_ sender: Any) {

    if let invite = Invites.inviteDialog() {
        invite.setInviteDelegate(self)

        invite.setMessage("Try this app")
        // Title for the dialog, this is what the user sees before sending the invites.
        invite.setTitle("Invites Example")
        invite.setDeepLink("app_url")
        invite.setCallToActionText("Install!")
        invite.setCustomImage("https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png")
        invite.open()
    }

}

2 个答案:

答案 0 :(得分:2)

如果您不要求用户登录,请更改Firebase数据库规则中的规则

{
  "rules": {
    ".read": "true",
    ".write": "auth != null"
  }
}

答案 1 :(得分:0)

Firebase清楚地说明了将FirebaseInvites集成到iOS中的所有步骤。 https://firebase.google.com/docs/invites/

我认为您没有清楚阅读其文档。有人提到您必须使用Google帐户登录才能使用FirebaseInvites邀请您的朋友。

如果您需要任何帮助,请告诉我。

谢谢!