diff --git a/.DS_Store b/.DS_Store index 59fbdbd..7492825 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Vendoo.xcodeproj/project.pbxproj b/Vendoo.xcodeproj/project.pbxproj index a00d28c..e5b1b72 100644 --- a/Vendoo.xcodeproj/project.pbxproj +++ b/Vendoo.xcodeproj/project.pbxproj @@ -41,6 +41,8 @@ 3EC3252F1CF894E500626C48 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3EC3252E1CF894E500626C48 /* AVFoundation.framework */; }; 3ECEDB871CF9C722003566B3 /* ListingPreviewViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3ECEDB861CF9C722003566B3 /* ListingPreviewViewController.swift */; }; 3EDE75AE1D67B92F00BC3472 /* CategoryPopUpController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EDE75AD1D67B92F00BC3472 /* CategoryPopUpController.swift */; }; + 3EE734E61DCD34AE00F771AE /* NotificationsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EE734E51DCD34AE00F771AE /* NotificationsViewController.swift */; }; + 3EE734E81DCD34B900F771AE /* NotificationTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EE734E71DCD34B900F771AE /* NotificationTableViewCell.swift */; }; 3EF422B21D73262000B9A3EB /* UserCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EF422B11D73262000B9A3EB /* UserCell.swift */; }; 3EFB0E331D0B968300A05D7A /* SideMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EFB0E321D0B968300A05D7A /* SideMenuView.swift */; }; 3F8E0464700649BDD8B552B1 /* Pods_Vendoo_VendooTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B876489113F498AF1D2FD7E9 /* Pods_Vendoo_VendooTests.framework */; }; @@ -108,6 +110,8 @@ 3EC3252E1CF894E500626C48 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; 3ECEDB861CF9C722003566B3 /* ListingPreviewViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListingPreviewViewController.swift; sourceTree = ""; }; 3EDE75AD1D67B92F00BC3472 /* CategoryPopUpController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CategoryPopUpController.swift; sourceTree = ""; }; + 3EE734E51DCD34AE00F771AE /* NotificationsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationsViewController.swift; sourceTree = ""; }; + 3EE734E71DCD34B900F771AE /* NotificationTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationTableViewCell.swift; sourceTree = ""; }; 3EF422B11D73262000B9A3EB /* UserCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserCell.swift; sourceTree = ""; }; 3EFB0E321D0B968300A05D7A /* SideMenuView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SideMenuView.swift; sourceTree = ""; }; 7D1FC6F6278B48A7BA9A9E03 /* Pods_Vendoo_VendooUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Vendoo_VendooUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -173,11 +177,11 @@ 3E4897CE1D0062860069F742 /* Services */ = { isa = PBXGroup; children = ( + 3E3A00491D76680E00A3A5B6 /* ServiceNotificationManager.swift */, 3EA668941D026E2A00EE57A8 /* EbayServices */, 3E4897CF1D00629B0069F742 /* FirebaseServices */, 3E7CF3FF1CF6363200F486B2 /* EtsyServices */, 3EC325241CF7E6B300626C48 /* FacebookServices */, - 3E3A00491D76680E00A3A5B6 /* ServiceNotificationManager.swift */, ); name = Services; sourceTree = ""; @@ -327,9 +331,19 @@ name = NewItemPostingSession; sourceTree = ""; }; + 3EE734E41DCD347900F771AE /* Notifications */ = { + isa = PBXGroup; + children = ( + 3EE734E71DCD34B900F771AE /* NotificationTableViewCell.swift */, + 3EE734E51DCD34AE00F771AE /* NotificationsViewController.swift */, + ); + name = Notifications; + sourceTree = ""; + }; 3EFB0E2F1D0B95B200A05D7A /* Menu */ = { isa = PBXGroup; children = ( + 3EE734E41DCD347900F771AE /* Notifications */, 3E1AA4331D0DD0B2005FCCBB /* Settings */, 3EFB0E321D0B968300A05D7A /* SideMenuView.swift */, 3E1AA4311D0DA071005FCCBB /* MenuPanelViewController.swift */, @@ -744,6 +758,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 3EE734E81DCD34B900F771AE /* NotificationTableViewCell.swift in Sources */, 3E6CC35B1CF2A94B00E00A70 /* SignUpViewController.swift in Sources */, 3E1AA4321D0DA071005FCCBB /* MenuPanelViewController.swift in Sources */, 3E4897D11D0067030069F742 /* FirebaseManager.swift in Sources */, @@ -762,6 +777,7 @@ 3ECEDB871CF9C722003566B3 /* ListingPreviewViewController.swift in Sources */, 3E1B1F0B1D2493EE00DBCF08 /* EtsySettingsViewController.swift in Sources */, 3EC325231CF7DA5500626C48 /* HomeViewController.swift in Sources */, + 3EE734E61DCD34AE00F771AE /* NotificationsViewController.swift in Sources */, 3EC3252D1CF894C400626C48 /* ItemImagePickerViewController.swift in Sources */, 3E1DC3CD1D4232490091BC60 /* CategoriesTableViewController.swift in Sources */, 3E7CF4011CF6366300F486B2 /* EtsyRESTAPIManager.swift in Sources */, diff --git a/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate index 8169c3e..d191c9f 100644 Binary files a/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate and b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 533f5c9..d3ff26d 100644 --- a/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -10,11 +10,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Vendoo/HomeViewController.swift" - timestampString = "497362780.635053" + timestampString = "500473804.952967" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "232" - endingLineNumber = "232" + startingLineNumber = "286" + endingLineNumber = "286" landmarkName = "listingHasEnded(_:ebayInfo:amazonInfo:etsyInfo:)" landmarkType = "5"> @@ -26,11 +26,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Vendoo/HomeViewController.swift" - timestampString = "497362780.635053" + timestampString = "500473804.952967" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "238" - endingLineNumber = "238" + startingLineNumber = "293" + endingLineNumber = "293" landmarkName = "listingHasEnded(_:ebayInfo:amazonInfo:etsyInfo:)" landmarkType = "5"> @@ -90,11 +90,183 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Vendoo/ServiceNotificationManager.swift" - timestampString = "498402552.569625" + timestampString = "500473804.952967" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "124" - endingLineNumber = "124" + startingLineNumber = "236" + endingLineNumber = "236"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -106,12 +278,248 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Vendoo/HomeViewController.swift" - timestampString = "499579562.452493" + timestampString = "500475450.307316" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "256" - endingLineNumber = "256" - landmarkName = "listingHasEnded(_:ebayInfo:amazonInfo:etsyInfo:)" + startingLineNumber = "403" + endingLineNumber = "403"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -122,12 +530,44 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Vendoo/HomeViewController.swift" - timestampString = "499579731.915475" + timestampString = "500473804.952967" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "273" - endingLineNumber = "273" - landmarkName = "listingHasEnded(_:ebayInfo:amazonInfo:etsyInfo:)" + startingLineNumber = "151" + endingLineNumber = "151" + landmarkName = "viewDidLoad()" + landmarkType = "5"> + + + + + + + + @@ -138,12 +578,203 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Vendoo/HomeViewController.swift" - timestampString = "499579805.922963" + timestampString = "500473804.952967" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "275" - endingLineNumber = "275" - landmarkName = "listingHasEnded(_:ebayInfo:amazonInfo:etsyInfo:)" + startingLineNumber = "310" + endingLineNumber = "310" + landmarkName = "listingHasNewNotifications(_:ebayInfo:amazonInfo:etsyInfo:)" + landmarkType = "5"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Vendoo/.DS_Store b/Vendoo/.DS_Store index 0929a6a..2f7f955 100644 Binary files a/Vendoo/.DS_Store and b/Vendoo/.DS_Store differ diff --git a/Vendoo/FacebookGraphAPIManager.swift b/Vendoo/FacebookGraphAPIManager.swift index d86b931..2948775 100644 --- a/Vendoo/FacebookGraphAPIManager.swift +++ b/Vendoo/FacebookGraphAPIManager.swift @@ -238,4 +238,18 @@ extension FacebookGraphAPIManager { return boolResult } + func getListingInfo(requestPath: String!, onCompletion: ServiceResponse!){ + let graphRequest:FBSDKGraphRequest = FBSDKGraphRequest(graphPath: requestPath, parameters: nil, HTTPMethod: "GET") + dispatch_async(dispatch_get_main_queue(), { + graphRequest.startWithCompletionHandler({ + (id, result, error) -> Void in + if error == nil { + onCompletion((result as! [String : AnyObject])["data"] as! [[String:AnyObject]],nil) + } + + + }) + }) + } + } diff --git a/Vendoo/HomeViewController.swift b/Vendoo/HomeViewController.swift index 4d3c1a3..f296422 100644 --- a/Vendoo/HomeViewController.swift +++ b/Vendoo/HomeViewController.swift @@ -19,7 +19,7 @@ class HomeViewController: UITabBarController { var endedListings: [Listing] = [] var soldListings: [Listing] = [] var notificationsManager = ServiceNotificationManager() - var notifications: [Dictionary] = (NSUserDefaults.standardUserDefaults().objectForKey("notifications") == nil ? [] : (NSUserDefaults.standardUserDefaults().objectForKey("notifications") as! [Dictionary])) + var notifications: [Dictionary] = (NSUserDefaults.standardUserDefaults().objectForKey("notifications") == nil ? [] : (NSUserDefaults.standardUserDefaults().objectForKey("notifications") as! [Dictionary])) override func viewDidLoad() { @@ -37,6 +37,18 @@ class HomeViewController: UITabBarController { let listingDict = userDict!["user_Listings"] as? [String : AnyObject] + //sync notifications + /*if userDict!["notifications"] != nil { + self.notifications = [] + for (_, v) in userDict!["notifications"] as! [String : AnyObject] { + if v["seen"] as! Bool == false { + self.notifications.append(v as! Dictionary) + } + } + + NSUserDefaults.standardUserDefaults().setObject(self.notifications, forKey: "notifications") + }*/ + NSUserDefaults.standardUserDefaults().setObject(userDict!["name"] as? String, forKey: "name") if listingDict != nil { @@ -204,12 +216,15 @@ extension HomeViewController: ServiceNotificationManagerDelegate { } func listingHasEnded(fbInfo: AnyObject?, ebayInfo: AnyObject?, amazonInfo: AnyObject?, etsyInfo: AnyObject?) { + var notificationArray: [[String: AnyObject]] = self.notifications + if (fbInfo != nil) { - self.notifications.append( + notificationArray.append( [ "network": "facebook", "message": (ebayInfo as! [String : AnyObject])["notification"] as! String, "type": "ended", + "seen":false, "key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String, "UUID": NSUUID().UUIDString ] @@ -217,11 +232,12 @@ extension HomeViewController: ServiceNotificationManagerDelegate { } if (ebayInfo != nil) { - self.notifications.append( + notificationArray.append( [ "network": "ebay", "message": (ebayInfo as! [String : AnyObject])["notification"] as! String, "type": (ebayInfo as! [String : AnyObject])["type"] as! String, + "seen":false, "key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String, "UUID": NSUUID().UUIDString ] @@ -242,11 +258,12 @@ extension HomeViewController: ServiceNotificationManagerDelegate { } if (amazonInfo != nil) { - self.notifications.append( + notificationArray.append( [ "network": "amazon", "message": (ebayInfo as! [String : AnyObject])["notification"] as! String, "type": (ebayInfo as! [String : AnyObject])["type"] as! String, + "seen":false, "key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String, "UUID": NSUUID().UUIDString ] @@ -254,11 +271,12 @@ extension HomeViewController: ServiceNotificationManagerDelegate { } if (etsyInfo != nil) { - self.notifications.append( + notificationArray.append( [ "network": "etsy", "message": (etsyInfo as! [String : AnyObject])["notification"] as! String, "type": "ended", + "seen":false, "key": (etsyInfo as! [String : AnyObject])["listingKey"] as! String, "UUID": NSUUID().UUIDString ] @@ -274,6 +292,10 @@ extension HomeViewController: ServiceNotificationManagerDelegate { listingDict!["listingStatus"] = "Ended" self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)/user_Listings/\(((etsyInfo as! [String : AnyObject])["listingKey"] as! String))").setValue(listingDict) + + + //reload data for notifications + NSUserDefaults.standardUserDefaults().setObject(notificationArray, forKey: "notifications") itemsView.itemTable.reloadData() }) } @@ -282,21 +304,47 @@ extension HomeViewController: ServiceNotificationManagerDelegate { func listingHasNewNotifications(fbInfo: AnyObject?, ebayInfo: AnyObject?, amazonInfo: AnyObject?, etsyInfo: AnyObject?) { + var notificationArray: [Dictionary] = self.notifications if (fbInfo != nil) { - self.notifications.append( - [ - "network": "facebook", - "message": (ebayInfo as! [String : AnyObject])["notification"] as! String, - "type": (ebayInfo as! [String : AnyObject])["type"] as! String, - "key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String, - "UUID": NSUUID().UUIDString - ] - ) + notificationArray.append(fbInfo as! [String : AnyObject]) + + self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)").observeSingleEventOfType(.Value, withBlock: { + (snapshot) -> Void in + + var userDict = snapshot.value as? [String : AnyObject] + + if (userDict!["notifications"] != nil) { + var notificationsFir = userDict!["notifications"] as! [String : AnyObject] + notificationsFir[fbInfo!["UUID"] as! String] = fbInfo + + self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)/notifications").setValue(notificationsFir, withCompletionBlock: { + (error, reference) -> Void in + + if error == nil { + NSUserDefaults.standardUserDefaults().setObject(notificationArray, forKey: "notifications") + } + + }) + }else { + let id = (fbInfo!["UUID"] as! String) + print(id) + userDict!["notifications"] = ([ id : fbInfo as! [String:AnyObject]]) + self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)").setValue(userDict, withCompletionBlock: { + (error, reference) -> Void in + + if error == nil { + NSUserDefaults.standardUserDefaults().setObject(notificationArray, forKey: "notifications") + } + }) + } + }) + + } if (ebayInfo != nil) { - self.notifications.append( + notificationArray.append( [ "network": "ebay", "message": (ebayInfo as! [String : AnyObject])["notification"] as! String, @@ -308,7 +356,7 @@ extension HomeViewController: ServiceNotificationManagerDelegate { } if (amazonInfo != nil) { - self.notifications.append( + notificationArray.append( [ "network": "amazon", "message": (ebayInfo as! [String : AnyObject])["notification"] as! String, @@ -320,7 +368,7 @@ extension HomeViewController: ServiceNotificationManagerDelegate { } if (etsyInfo != nil) { - self.notifications.append( + notificationArray.append( [ "network": "etsy", "message": (etsyInfo as! [String : AnyObject])["notification"] as! String, @@ -332,6 +380,7 @@ extension HomeViewController: ServiceNotificationManagerDelegate { } //@TODO: add firbase logic to add notifications and delete already viewed notifications - + //reload data for notifications + } } diff --git a/Vendoo/Main.storyboard b/Vendoo/Main.storyboard index a2f6b1f..b105bf2 100755 --- a/Vendoo/Main.storyboard +++ b/Vendoo/Main.storyboard @@ -1641,49 +1641,40 @@ - + - + - - + + - + - - - - - - - - - - - - + + + + + + + + + + + + @@ -1691,9 +1682,16 @@ - + + + + + + + + @@ -1730,7 +1728,7 @@ - + @@ -1747,7 +1745,7 @@ - + diff --git a/Vendoo/NotificationTableViewCell.swift b/Vendoo/NotificationTableViewCell.swift index 05e6389..9a02e29 100644 --- a/Vendoo/NotificationTableViewCell.swift +++ b/Vendoo/NotificationTableViewCell.swift @@ -10,6 +10,8 @@ import UIKit class NotificationTableViewCell: UITableViewCell { + @IBOutlet weak var message: UITextView! + @IBOutlet weak var network: UIImageView! override func awakeFromNib() { super.awakeFromNib() // Initialization code diff --git a/Vendoo/NotificationsViewController.swift b/Vendoo/NotificationsViewController.swift index 3dbecdb..2f14ca2 100644 --- a/Vendoo/NotificationsViewController.swift +++ b/Vendoo/NotificationsViewController.swift @@ -9,9 +9,15 @@ import UIKit class NotificationsViewController: UIViewController { - + var notifications: [Dictionary]! = (NSUserDefaults.standardUserDefaults().objectForKey("notifications") == nil ? [] : (NSUserDefaults.standardUserDefaults().objectForKey("notifications") as! [Dictionary])) + var fireBase = FirebaseManager() + + @IBOutlet weak var notificationTable: UITableView! + override func viewDidLoad() { super.viewDidLoad() + self.notificationTable.dataSource = self + self.notificationTable.delegate = self // Do any additional setup after loading the view. } @@ -33,3 +39,86 @@ class NotificationsViewController: UIViewController { */ } + +extension NotificationsViewController: UITableViewDelegate { + func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { + var notification = self.notifications[indexPath.row] + + switch ( notification["network"] as! String) { + case "facebook": + let alert = UIAlertController(title: "New Comment from \(notification["senderName"] as! String)", message: (notification["commentMessage"] as! String), preferredStyle: .Alert) + alert.addAction(UIAlertAction(title: "Mark as Dismissed", style: .Default, handler: { + (action) -> Void in + + notification["seen"] = true + self.notifications[indexPath.row] = notification + self.fireBase.ref.child("Users/\(self.fireBase.user_email)/notifications/\(notification["UUID"] as! String)").setValue(notification, withCompletionBlock: { + (error, reference) -> Void in + + if error == nil { + self.notifications = self.notifications.filter({$0["seen"] as! Bool == false}) + NSUserDefaults.standardUserDefaults().setObject(self.notifications, forKey: "notifications") + self.notificationTable.reloadData() + alert.dismissViewControllerAnimated(true, completion: nil) + } + }) + + })) + alert.addAction(UIAlertAction(title: "OK", style: .Cancel, handler: {(action) -> Void in})) + self.presentViewController(alert, animated: true, completion: nil) + break + case "ebay": + break + case "etsy": + break + case "amazon": + break + + default: + break + } + } +} + +extension NotificationsViewController: UITableViewDataSource { + + func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + let cell: NotificationTableViewCell! = self.notificationTable.dequeueReusableCellWithIdentifier("notification_cell") as! NotificationTableViewCell + let notification = self.notifications[indexPath.row] + cell.message.text = notification["notification"] as! String + + switch ( notification["network"] as! String) { + case "facebook": + cell.network.image = UIImage(named: "facebook_icon") + break + case "ebay": + cell.network.image = UIImage(named: "ebay_icon") + break + case "etsy": + cell.network.image = UIImage(named: "etsy_icon") + break + case "amazon": + break + + default: + break + } + + + + return cell + } + + func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return self.notifications.count + } + +} + +extension NotificationsViewController /*IBoutlets*/ { + @IBAction func dismissNotifications(sender: AnyObject){ + let vc = self.storyboard?.instantiateViewControllerWithIdentifier("Reveal View Controller") + + self.presentViewController(vc!, animated: false, completion: nil) + } +} diff --git a/Vendoo/ServiceNotificationManager.swift b/Vendoo/ServiceNotificationManager.swift index a59fee3..8e94bd3 100644 --- a/Vendoo/ServiceNotificationManager.swift +++ b/Vendoo/ServiceNotificationManager.swift @@ -111,7 +111,59 @@ class ServiceNotificationManager: NSObject { } } if(facebookID != nil){ - + if(self.fbGraphManager.isAuthorized) { + self.fbGraphManager.getListingInfo ("/\(facebookID!)/comments", onCompletion: { + (listingNotificationInfo, error) -> Void in + + dispatch_async(dispatch_get_main_queue(), { + self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)").observeEventType(.Value, withBlock: { + (snapshot) -> Void in + + let notifications = ((snapshot.value as? [String : AnyObject])!["notifications"]) as? [String : AnyObject] + + + for commentInfo in (listingNotificationInfo as! [[String: AnyObject]]) { + let fromInfo = commentInfo["from"] as! [String : AnyObject] + if notifications != nil { + if notifications![(commentInfo["id"] as! String)] == nil { + let commentDict = [ + "UUID":(commentInfo["id"] as! String), + "commentMessage":(commentInfo["message"] as! String), + "network":"facebook", + "notification": "Your item \"\(listingDict!["listingTitle"] as! String)\" has a new comment.", + "key": listing.key, + "seen":false, + "senderID":(fromInfo["id"]! as! String), + "senderName":(fromInfo["name"]! as! String), + "type":"FBComment" + ] + ServiceNotificationManager.delegate?.listingHasNewNotifications(commentDict, ebayInfo: nil, amazonInfo: nil, etsyInfo: nil) + } + + }else{ + let commentDict = [ + "UUID":(commentInfo["id"] as! String), + "commentMessage":(commentInfo["message"] as! String), + "network":"facebook", + "notification": "Your item \"\(listingDict!["listingTitle"] as! String)\" has a new comment.", + "key": listing.key, + "seen":false, + "senderID":(fromInfo["id"]! as! String), + "senderName":(fromInfo["name"]! as! String), + "type":"FBComment" + ] + ServiceNotificationManager.delegate?.listingHasNewNotifications(commentDict, ebayInfo: nil, amazonInfo: nil, etsyInfo: nil) + } + + } + + + }) + }) + + }) + + } } if(etsyID != nil){ if (self.etsyManager.isAuthorized) {