Merged branch RDB-Delete-An-Account-Functionality into master

This commit is contained in:
Okechi Onyeje 2016-11-21 12:02:40 -05:00
commit 4d355b9d1e
4 changed files with 196 additions and 5 deletions

View File

@ -186,7 +186,7 @@
moduleName = "Vendoo" moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes" usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/CategoriesTableViewController.swift" urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/CategoriesTableViewController.swift"
timestampString = "501429659.558836" timestampString = "501438723.320631"
startingColumnNumber = "9223372036854775807" startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "570" startingLineNumber = "570"
@ -201,7 +201,7 @@
moduleName = "Vendoo" moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes" usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/CategoriesTableViewController.swift" urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/CategoriesTableViewController.swift"
timestampString = "501429659.559" timestampString = "501438723.320746"
startingColumnNumber = "9223372036854775807" startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "572" startingLineNumber = "572"
@ -689,5 +689,101 @@
landmarkType = "5"> landmarkType = "5">
</BreakpointContent> </BreakpointContent>
</BreakpointProxy> </BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/SettingsViewController.swift"
timestampString = "501431362.91266"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "196"
endingLineNumber = "196"
landmarkName = "tableView(_:didSelectRowAtIndexPath:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/SettingsViewController.swift"
timestampString = "501431365.398348"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "197"
endingLineNumber = "197"
landmarkName = "tableView(_:didSelectRowAtIndexPath:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/SettingsViewController.swift"
timestampString = "501431572.028953"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "194"
endingLineNumber = "194"
landmarkName = "tableView(_:didSelectRowAtIndexPath:)"
landmarkType = "5">
<Locations>
<Location
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "Vendoo.SettingsViewController.(tableView (__ObjC.UITableView, didSelectRowAtIndexPath : __ObjC.NSIndexPath) -&gt; ()).(closure #5)"
moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/SettingsViewController.swift"
timestampString = "501438723.339454"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "194"
endingLineNumber = "194"
offsetFromSymbolStart = "2591">
</Location>
<Location
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "Vendoo.SettingsViewController.(tableView (__ObjC.UITableView, didSelectRowAtIndexPath : __ObjC.NSIndexPath) -&gt; ()).(closure #5).(closure #1)"
moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/SettingsViewController.swift"
timestampString = "501438723.339576"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "197"
endingLineNumber = "197"
offsetFromSymbolStart = "34">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/HomeViewController.swift"
timestampString = "501438721.606962"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "172"
endingLineNumber = "172"
landmarkName = "viewDidLoad()"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints> </Breakpoints>
</Bucket> </Bucket>

View File

@ -41,8 +41,26 @@ class HomeViewController: UITabBarController {
if userDict!["notifications"] != nil { if userDict!["notifications"] != nil {
self.notifications = [] self.notifications = []
for (_, v) in userDict!["notifications"] as! [String : AnyObject] { for (_, v) in userDict!["notifications"] as! [String : AnyObject] {
if v["seen"] as! Bool == false { if v["seen"] as! Bool == false/*add network visibility as well*/{
self.notifications.append(v as! Dictionary<String, AnyObject>) var is_networkAuth = false
switch((v["network"] as! String)){
case "ebay":
is_networkAuth = NSUserDefaults.standardUserDefaults().boolForKey("ebayAuthorized")
break
case "etsy":
is_networkAuth = NSUserDefaults.standardUserDefaults().boolForKey("etsyAuthorized")
break
case "facebook" :
is_networkAuth = NSUserDefaults.standardUserDefaults().boolForKey("fbAuthorized")
break
case "amazon":
break
default:
break
}
if is_networkAuth {
self.notifications.append(v as! Dictionary<String, AnyObject>)
}
} }
} }
@ -151,6 +169,13 @@ class HomeViewController: UITabBarController {
NSNotificationCenter.defaultCenter().postNotificationName("finished_fetching_listings", object: nil) NSNotificationCenter.defaultCenter().postNotificationName("finished_fetching_listings", object: nil)
self.notificationsManager.setListings(self.userListings) self.notificationsManager.setListings(self.userListings)
self.notificationsManager.startServicePolling() self.notificationsManager.startServicePolling()
/*self.notificationsManager.startServicePolling({
(_,_) -> Void in
NSNotificationCenter.defaultCenter().postNotificationName("finished_fetching_listings", object: nil)
})*/
} }

View File

@ -9,13 +9,15 @@
import UIKit import UIKit
import Locksmith import Locksmith
import FirebaseAuth import FirebaseAuth
import FirebaseDatabase
import FirebaseStorage
class SettingsViewController: UIViewController { class SettingsViewController: UIViewController {
//IBOutlet //IBOutlet
@IBOutlet weak var closeButton: UIBarButtonItem! @IBOutlet weak var closeButton: UIBarButtonItem!
@IBOutlet weak var table: UITableView! @IBOutlet weak var table: UITableView!
var firbase = FirebaseManager()
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
@ -184,6 +186,74 @@ extension SettingsViewController: UITableViewDelegate {
//put in deletion code later //put in deletion code later
print("account deleted, add in deletion code as well as deauthorization code for any network currently authorized") print("account deleted, add in deletion code as well as deauthorization code for any network currently authorized")
//get all listing information for current user
print((NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)!)
self.firbase.ref.child("Users/\(self.firbase.user_email)").observeSingleEventOfType( .Value, withBlock: {
(snapshot) -> Void in
let userDict = snapshot.value as? [String : AnyObject]
let listingDict = userDict!["user_Listings"] as? [String : AnyObject]
if listingDict != nil {
for (key, values) in listingDict! {
self.firbase.ref.child("Global_listings").child(key).removeValue()
FIRStorage.storage().referenceForURL((userDict!["image_storage"] as? String)!).child("images/\(key)").deleteWithCompletion({
(error) -> Void in
})
}
}
self.firbase.ref.child("Users").child(self.firbase.user_email).removeValueWithCompletionBlock({
(error, ref) -> Void in
if error == nil {
FIRAuth.auth()?.currentUser?.deleteWithCompletion({
(profile) -> Void in
do{
try Locksmith.deleteDataForUserAccount((NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)!, inService: "vendoo")
do {
try Locksmith.deleteDataForUserAccount((NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)!, inService: "vendoo_oauth_ebay")
}catch {
(error)
print(error)
}
do {
try Locksmith.deleteDataForUserAccount((NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)!, inService: "vendoo_oauth_etsy")
}catch {
(error)
print(error)
}
do {
try Locksmith.deleteDataForUserAccount((NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)!, inService: "vendoo_oauth_amazon")
}catch {
(error)
print(error)
}
for key in Array(NSUserDefaults.standardUserDefaults().dictionaryRepresentation().keys) {
NSUserDefaults.standardUserDefaults().removeObjectForKey(key)
}
let vc = self.storyboard?.instantiateViewControllerWithIdentifier("SignInViewController")
self.presentViewController(vc!, animated: true, completion: nil)
}
catch{
(error)
print(error)
}
})
}
})
})
alert.dismissViewControllerAnimated(true, completion: nil) alert.dismissViewControllerAnimated(true, completion: nil)
}else{ }else{