Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func listenForFirebaseConnection(callback: @escaping () -> Void) {
- FireDataUtil().getBase().child(".info/connected").observeSingleEvent(of: .value, with: { (snapshot) in
- if snapshot.exists() {
- let isConnected = snapshot.value as! Bool?
- if isConnected != nil && isConnected == false {
- let view = MessageView.viewFromNib(layout: .MessageView)
- view.button?.isHidden = false
- // Theme message elements with the warning style.
- view.configureTheme(.error)
- // Add a drop shadow.
- view.configureDropShadow()
- // Set message title, body, and icon. Here, we're overriding the default warning
- // image with an emoji character.
- view.configureContent(title: "Network Issue", body: "It looks like your network connection is either slow or disconnected")
- view.button?.setTitle("Reload", for: .normal)
- view.button?.addTarget(self, action: #selector(callback), for: .touchUpInside)
- var config = SwiftMessages.Config()
- config.presentationContext = .window(windowLevel: UIWindowLevelStatusBar)
- config.presentationStyle = .bottom
- config.duration = .seconds(seconds: 5)
- // Show the message.
- SwiftMessages.show(config: config, view: view)
- }
- }
- })
- }
- #selector(ViewController.callback)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement