Commit 5ca567d5 by Anand.suthar

Add Firebase user presence

parent 3722fdfc
...@@ -58,12 +58,12 @@ ...@@ -58,12 +58,12 @@
moduleName = "Bhagyashree" moduleName = "Bhagyashree"
usesParentBreakpointCondition = "Yes" usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/sunarcmac/Documents/Futurecommerce/Fengshui-Seller-iOS/Bhagyashree/Sunarc/Controller/Me/CorporateCultureViewController.swift" urlString = "file:///Users/sunarcmac/Documents/Futurecommerce/Fengshui-Seller-iOS/Bhagyashree/Sunarc/Controller/Me/CorporateCultureViewController.swift"
timestampString = "555406002.442651" timestampString = "555413985.959007"
startingColumnNumber = "9223372036854775807" startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "22" startingLineNumber = "22"
endingLineNumber = "22" endingLineNumber = "22"
offsetFromSymbolStart = "104"> offsetFromSymbolStart = "109">
</Location> </Location>
<Location <Location
shouldBeEnabled = "Yes" shouldBeEnabled = "Yes"
...@@ -73,12 +73,12 @@ ...@@ -73,12 +73,12 @@
moduleName = "Bhagyashree" moduleName = "Bhagyashree"
usesParentBreakpointCondition = "Yes" usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/sunarcmac/Documents/Futurecommerce/Fengshui-Seller-iOS/Bhagyashree/Sunarc/Controller/Me/CorporateCultureViewController.swift" urlString = "file:///Users/sunarcmac/Documents/Futurecommerce/Fengshui-Seller-iOS/Bhagyashree/Sunarc/Controller/Me/CorporateCultureViewController.swift"
timestampString = "555406002.446547" timestampString = "555413985.963246"
startingColumnNumber = "9223372036854775807" startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "22" startingLineNumber = "22"
endingLineNumber = "22" endingLineNumber = "22"
offsetFromSymbolStart = "120"> offsetFromSymbolStart = "112">
</Location> </Location>
<Location <Location
shouldBeEnabled = "Yes" shouldBeEnabled = "Yes"
...@@ -88,12 +88,12 @@ ...@@ -88,12 +88,12 @@
moduleName = "Bhagyashree" moduleName = "Bhagyashree"
usesParentBreakpointCondition = "Yes" usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/sunarcmac/Documents/Futurecommerce/Fengshui-Seller-iOS/Bhagyashree/Sunarc/Controller/Me/CorporateCultureViewController.swift" urlString = "file:///Users/sunarcmac/Documents/Futurecommerce/Fengshui-Seller-iOS/Bhagyashree/Sunarc/Controller/Me/CorporateCultureViewController.swift"
timestampString = "555406002.451793" timestampString = "555413985.967458"
startingColumnNumber = "9223372036854775807" startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "22" startingLineNumber = "22"
endingLineNumber = "22" endingLineNumber = "22"
offsetFromSymbolStart = "424"> offsetFromSymbolStart = "607">
</Location> </Location>
<Location <Location
shouldBeEnabled = "Yes" shouldBeEnabled = "Yes"
...@@ -103,12 +103,12 @@ ...@@ -103,12 +103,12 @@
moduleName = "Bhagyashree" moduleName = "Bhagyashree"
usesParentBreakpointCondition = "Yes" usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/sunarcmac/Documents/Futurecommerce/Fengshui-Seller-iOS/Bhagyashree/Sunarc/Controller/Me/CorporateCultureViewController.swift" urlString = "file:///Users/sunarcmac/Documents/Futurecommerce/Fengshui-Seller-iOS/Bhagyashree/Sunarc/Controller/Me/CorporateCultureViewController.swift"
timestampString = "555406002.455837" timestampString = "555413985.971509"
startingColumnNumber = "9223372036854775807" startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "22" startingLineNumber = "22"
endingLineNumber = "22" endingLineNumber = "22"
offsetFromSymbolStart = "380"> offsetFromSymbolStart = "470">
</Location> </Location>
</Locations> </Locations>
</BreakpointContent> </BreakpointContent>
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
import UIKit import UIKit
import MJRefresh import MJRefresh
import Kingfisher import Kingfisher
import FirebaseDatabase
class HomePageViewController: BaseViewController { class HomePageViewController: BaseViewController {
...@@ -19,6 +20,22 @@ class HomePageViewController: BaseViewController { ...@@ -19,6 +20,22 @@ class HomePageViewController: BaseViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.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 { let headerForLoading = MJRefreshNormalHeader {
self.dashboard.getDashboardData(success: { self.dashboard.getDashboardData(success: {
self.tblSellerDashbord.reloadData() self.tblSellerDashbord.reloadData()
...@@ -152,23 +169,31 @@ class SellerProfileCell: UITableViewCell { ...@@ -152,23 +169,31 @@ class SellerProfileCell: UITableViewCell {
if statusSwitch.isOn == true { if statusSwitch.isOn == true {
Dashboard.goOnlineOffline(status: true, success: { Database.database().reference().child("sellers").setValue(["\(User.customerId)": "online"])
self.delegate.showToast(message: "You are now online") self.delegate.showToast(message: "You are now online")
self.lblStatus.text = "Online" self.lblStatus.text = "Online"
}) { (message) in
self.delegate.showToast(message: message) // Dashboard.goOnlineOffline(status: true, success: {
statusSwitch.setOn(false, animated: true) // 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 { } else {
Dashboard.goOnlineOffline(status: false, success: { Database.database().reference().child("sellers").setValue(["\(User.customerId)": "offline"])
self.delegate.showToast(message: "You are now offline") self.delegate.showToast(message: "You are now offline")
self.lblStatus.text = "Offline" self.lblStatus.text = "Offline"
}) { (message) in
self.delegate.showToast(message: message) // Dashboard.goOnlineOffline(status: false, success: {
statusSwitch.setOn(true, animated: true) // 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 { ...@@ -62,7 +62,7 @@ class Dashboard {
if let sellerData = response["seller_data"] as? [String: Any] { if let sellerData = response["seller_data"] as? [String: Any] {
User.profileImage = sellerData["seller_logo"] as? String 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 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