Posts

Post not yet marked as solved
1 Replies
Update: So I have my Firebase real-time database populated with some data, and I have already integrated Firebase within my app, and the database's structure looks like this: myDatabase . . . . . Child/node . . . . . . Child with value of "url" How do I reference and read the value (the URL) from the database so that the following code uses that URL to open the SFSafariViewController? Here is the code I use to open the SFSafariViewController using a button tap: @IBAction func openSFWebView(_ sender: Any) {         guard let url = URL(string: "https://www.google.com")             else {return}         let safariViewController = SFSafariViewController (url: url)         self.present(safariViewController, animated: true, completion: nil)     } From what I could find online, it seems like I should use observeSingleEventType, but I do not want to have to/don't believe I need to authenticate the user or use the user's ID to access the URL. Below is from the Firebase documentation: let newID = Auth.auth().currentUser?.uid (I don't believe I need this.) ref.child("childName").child(userID!).observeSingleEvent(of: .value, with: { (snapshot) in   // Get user value   let value = snapshot.value as? NSDictionary   let username = value?["username"] as? String ?? ""   let user = User(username: username)   // ...   }) { (error) in     print(error.localizedDescription) } Again, I hope someone can help. Thank You!
Post marked as solved
2 Replies
Thank you for your help! I actually ended up goign with the SFSafariViewController suggestion. I just created an action for each button and used the following code:@IBAction func exampleSFWebView(_ sender: Any) { guard let url = URL(string: "https://www.google.com") else {return} let safariViewController = SFSafariViewController (url: url) self.present(safariViewController, animated: true, completion: nil) }I think it should work for me! This is so much easier than the custom WKWebView that I was using before. Haven't implemented it throughout my app yet, but I'll follow up if I end up with any issues.Thanks Again,