let database = FIRDatabase.database().reference()
database.child("Users").queryOrderedByKey().observe(.childAdded, with: { (snapshot) in
print(snapshot)
if let value = snapshot.value as? [String: AnyObject] {
let ui = value["id"] as! String
if ui != FIRAuth.auth()!.currentUser!.uid
{
var storyboard = UIStoryboard(name: "Main", bundle: nil)
if s == true
{
storyboard = UIStoryboard(name: "Main", bundle: nil)
}
else if p == true
{
storyboard = UIStoryboard(name: "big", bundle: nil)
}
else if se == true
{
storyboard = UIStoryboard(name: "se", bundle: nil)
}
else if os == true
{
storyboard = UIStoryboard(name: "4s", bundle: nil)
}
else if ip1 == true
{
storyboard = UIStoryboard(name: "ipad1", bundle: nil)
}
else if ipb == true
{
storyboard = UIStoryboard(name: "ipadbig", bundle: nil)
}
let naviVC = storyboard.instantiateViewController(withIdentifier: "eula")as! UIViewController
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.window?.rootViewController = naviVC
}
else
{
var storyboard = UIStoryboard(name: "Main", bundle: nil)
if s == true
{
storyboard = UIStoryboard(name: "Main", bundle: nil)
}
else if p == true{
storyboard = UIStoryboard(name: "big", bundle: nil)
}
else if se == true
{
storyboard = UIStoryboard(name: "se", bundle: nil)
}
else if os == true{
storyboard = UIStoryboard(name: "4s", bundle: nil)
}
else if ip1 == true
{
storyboard = UIStoryboard(name: "ipad1", bundle: nil)
}
else if ipb == true
{
storyboard = UIStoryboard(name: "ipadbig", bundle: nil)
}
let naviVC = storyboard.instantiateViewController(withIdentifier: "yo")as! UIViewController
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.window?.rootViewController = naviVC
}
}
})
I have a firebase app, and I want to check if a user exists in my databse, If the don't i want to display a licenses agreement, but if they do i don't have too. My current method only works if there are two users. Thank you for your help in advance.
I figured it out
let database = FIRDatabase.database().reference()
database.child("Users").observeSingleEvent(of: FIRDataEventType.value, with: { (snapshot) in
print(snapshot)
if snapshot.hasChild( FIRAuth.auth()!.currentUser!.uid)
{