Commit 5ca567d5 by Anand.suthar

Add Firebase user presence

parent 3722fdfc
......@@ -58,12 +58,12 @@
moduleName = "Bhagyashree"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/sunarcmac/Documents/Futurecommerce/Fengshui-Seller-iOS/Bhagyashree/Sunarc/Controller/Me/CorporateCultureViewController.swift"
timestampString = "555406002.442651"
timestampString = "555413985.959007"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "22"
endingLineNumber = "22"
offsetFromSymbolStart = "104">
offsetFromSymbolStart = "109">
</Location>
<Location
shouldBeEnabled = "Yes"
......@@ -73,12 +73,12 @@
moduleName = "Bhagyashree"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/sunarcmac/Documents/Futurecommerce/Fengshui-Seller-iOS/Bhagyashree/Sunarc/Controller/Me/CorporateCultureViewController.swift"
timestampString = "555406002.446547"
timestampString = "555413985.963246"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "22"
endingLineNumber = "22"
offsetFromSymbolStart = "120">
offsetFromSymbolStart = "112">
</Location>
<Location
shouldBeEnabled = "Yes"
......@@ -88,12 +88,12 @@
moduleName = "Bhagyashree"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/sunarcmac/Documents/Futurecommerce/Fengshui-Seller-iOS/Bhagyashree/Sunarc/Controller/Me/CorporateCultureViewController.swift"
timestampString = "555406002.451793"
timestampString = "555413985.967458"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "22"
endingLineNumber = "22"
offsetFromSymbolStart = "424">
offsetFromSymbolStart = "607">
</Location>
<Location
shouldBeEnabled = "Yes"
......@@ -103,12 +103,12 @@
moduleName = "Bhagyashree"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/sunarcmac/Documents/Futurecommerce/Fengshui-Seller-iOS/Bhagyashree/Sunarc/Controller/Me/CorporateCultureViewController.swift"
timestampString = "555406002.455837"
timestampString = "555413985.971509"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "22"
endingLineNumber = "22"
offsetFromSymbolStart = "380">
offsetFromSymbolStart = "470">
</Location>
</Locations>
</BreakpointContent>
......
......@@ -9,6 +9,7 @@
import UIKit
import MJRefresh
import Kingfisher
import FirebaseDatabase
class HomePageViewController: BaseViewController {
......@@ -19,6 +20,22 @@ class HomePageViewController: BaseViewController {
override func viewDidLoad() {
super.viewDidLoad()
let ref = Database.database().reference().child("sellers")
ref.observe(DataEventType.value) { (snapshot) in
let postDict = snapshot.value as? [String : AnyObject] ?? [:]
if let status = postDict["\(User.customerId)"] as? String {
if status == "offline" {
User.isOnline = false
} else {
User.isOnline = true
}
self.tblSellerDashbord.reloadData()
}
}
Database.database().reference().child("sellers").onDisconnectSetValue(["\(User.customerId)": "offline"])
let headerForLoading = MJRefreshNormalHeader {
self.dashboard.getDashboardData(success: {
self.tblSellerDashbord.reloadData()
......@@ -152,23 +169,31 @@ class SellerProfileCell: UITableViewCell {
if statusSwitch.isOn == true {
Dashboard.goOnlineOffline(status: true, success: {
self.delegate.showToast(message: "You are now online")
self.lblStatus.text = "Online"
}) { (message) in
self.delegate.showToast(message: message)
statusSwitch.setOn(false, animated: true)
}
Database.database().reference().child("sellers").setValue(["\(User.customerId)": "online"])
self.delegate.showToast(message: "You are now online")
self.lblStatus.text = "Online"
// Dashboard.goOnlineOffline(status: true, success: {
// self.delegate.showToast(message: "You are now online")
// self.lblStatus.text = "Online"
// }) { (message) in
// self.delegate.showToast(message: message)
// statusSwitch.setOn(false, animated: true)
// }
} else {
Dashboard.goOnlineOffline(status: false, success: {
self.delegate.showToast(message: "You are now offline")
self.lblStatus.text = "Offline"
}) { (message) in
self.delegate.showToast(message: message)
statusSwitch.setOn(true, animated: true)
}
Database.database().reference().child("sellers").setValue(["\(User.customerId)": "offline"])
self.delegate.showToast(message: "You are now offline")
self.lblStatus.text = "Offline"
// Dashboard.goOnlineOffline(status: false, success: {
// self.delegate.showToast(message: "You are now offline")
// self.lblStatus.text = "Offline"
// }) { (message) in
// self.delegate.showToast(message: message)
// statusSwitch.setOn(true, animated: true)
// }
}
......
......@@ -62,7 +62,7 @@ class Dashboard {
if let sellerData = response["seller_data"] as? [String: Any] {
User.profileImage = sellerData["seller_logo"] as? String
User.isOnline = sellerData["active_seller_status"] as! Bool
// User.isOnline = sellerData["active_seller_status"] as! Bool
User.title = sellerData["title"] as? String
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment