Facebook integrated into new listing workflow, 3 more api's to go, still need to figure out uploading pictures in the same timeline post, but able to save post id to firebase

This commit is contained in:
Okechi Onyeje 2016-06-03 18:49:03 -04:00
parent ca5f0af92c
commit d0016c988b
5 changed files with 170 additions and 348 deletions

View File

@ -3,86 +3,6 @@
type = "0" type = "0"
version = "2.0"> version = "2.0">
<Breakpoints> <Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/ItemTableViewController.swift"
timestampString = "486660964.842819"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "81"
endingLineNumber = "81"
landmarkName = "tableView(_:cellForRowAtIndexPath:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/ItemTableViewController.swift"
timestampString = "486660964.842819"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "75"
endingLineNumber = "75"
landmarkName = "tableView(_:numberOfRowsInSection:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/ItemTableViewController.swift"
timestampString = "486659224.096197"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "32"
endingLineNumber = "32"
landmarkName = "viewDidLoad()"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/ItemTableViewController.swift"
timestampString = "486660964.842819"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "45"
endingLineNumber = "45"
landmarkName = "stopIndicator()"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/HomeViewController.swift"
timestampString = "486663712.161357"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "29"
endingLineNumber = "29"
landmarkName = "viewDidLoad()"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy <BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent <BreakpointContent
@ -90,11 +10,11 @@
ignoreCount = "0" ignoreCount = "0"
continueAfterRunningActions = "No" continueAfterRunningActions = "No"
filePath = "Vendoo/ListingPreviewViewController.swift" filePath = "Vendoo/ListingPreviewViewController.swift"
timestampString = "486667377.17358" timestampString = "486686708.22622"
startingColumnNumber = "9223372036854775807" startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "93" startingLineNumber = "155"
endingLineNumber = "93" endingLineNumber = "155"
landmarkName = "publishItem(_:)" landmarkName = "publishItem(_:)"
landmarkType = "5"> landmarkType = "5">
</BreakpointContent> </BreakpointContent>
@ -105,44 +25,107 @@
shouldBeEnabled = "Yes" shouldBeEnabled = "Yes"
ignoreCount = "0" ignoreCount = "0"
continueAfterRunningActions = "No" continueAfterRunningActions = "No"
filePath = "Vendoo/ListingPreviewViewController.swift" filePath = "Vendoo/FacebookGraphAPIManager.swift"
timestampString = "486667688.077144" timestampString = "486683097.861171"
startingColumnNumber = "9223372036854775807" startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "114" startingLineNumber = "174"
endingLineNumber = "114" endingLineNumber = "174"
landmarkName = "publishItem(_:)" landmarkName = "makePOSTResquest(_:params:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/FacebookGraphAPIManager.swift"
timestampString = "486685960.664377"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "188"
endingLineNumber = "188"
landmarkName = "makePOSTResquest(_:params:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/FacebookGraphAPIManager.swift"
timestampString = "486685960.664377"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "184"
endingLineNumber = "184"
landmarkName = "makePOSTResquest(_:params:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/ListingPreviewViewController.swift"
timestampString = "486685960.664377"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "94"
endingLineNumber = "94"
landmarkName = "listingUploadedFB(_:)"
landmarkType = "5"> landmarkType = "5">
<Locations> <Locations>
<Location <Location
shouldBeEnabled = "Yes" shouldBeEnabled = "Yes"
ignoreCount = "0" ignoreCount = "0"
continueAfterRunningActions = "No" continueAfterRunningActions = "No"
symbolName = "Vendoo.ListingPreviewViewController.publishItem (Swift.AnyObject) -&gt; ()" symbolName = "Vendoo.ListingPreviewViewController.listingUploadedFB (Swift.String) -&gt; ()"
moduleName = "Vendoo" moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes" usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/ListingPreviewViewController.swift" urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/ListingPreviewViewController.swift"
timestampString = "486668388.425523" timestampString = "486686709.393085"
startingColumnNumber = "9223372036854775807" startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "114" startingLineNumber = "96"
endingLineNumber = "114" endingLineNumber = "96"
offsetFromSymbolStart = "6347"> offsetFromSymbolStart = "27">
</Location> </Location>
<Location <Location
shouldBeEnabled = "Yes" shouldBeEnabled = "Yes"
ignoreCount = "0" ignoreCount = "0"
continueAfterRunningActions = "No" continueAfterRunningActions = "No"
symbolName = "Vendoo.ListingPreviewViewController.(publishItem (Swift.AnyObject) -&gt; ()).(closure #2)" symbolName = "protocol witness for Vendoo.FacebookGraphAPIManagerDelegate.listingUploadedFB (Swift.String) -&gt; () in conformance Vendoo.ListingPreviewViewController : Vendoo.FacebookGraphAPIManagerDelegate in Vendoo"
moduleName = "Vendoo" moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes" usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/ListingPreviewViewController.swift" urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/ListingPreviewViewController.swift"
timestampString = "486668388.42562" timestampString = "486686709.393207"
startingColumnNumber = "9223372036854775807" startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "116" startingLineNumber = "94"
endingLineNumber = "116" endingLineNumber = "94"
offsetFromSymbolStart = "27"> offsetFromSymbolStart = "4">
</Location>
<Location
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "dynamic Vendoo.ListingPreviewViewController.listingUploadedFB (Swift.String) -&gt; ()"
moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/ListingPreviewViewController.swift"
timestampString = "486686709.393305"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "94"
endingLineNumber = "94"
offsetFromSymbolStart = "4">
</Location> </Location>
</Locations> </Locations>
</BreakpointContent> </BreakpointContent>
@ -153,239 +136,15 @@
shouldBeEnabled = "Yes" shouldBeEnabled = "Yes"
ignoreCount = "0" ignoreCount = "0"
continueAfterRunningActions = "No" continueAfterRunningActions = "No"
filePath = "Vendoo/ListingPreviewViewController.swift" filePath = "Vendoo/FacebookGraphAPIManager.swift"
timestampString = "486667688.077144" timestampString = "486685960.664377"
startingColumnNumber = "9223372036854775807" startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "116" startingLineNumber = "187"
endingLineNumber = "116" endingLineNumber = "187"
landmarkName = "publishItem(_:)" landmarkName = "makePOSTResquest(_:params:)"
landmarkType = "5"> landmarkType = "5">
</BreakpointContent> </BreakpointContent>
</BreakpointProxy> </BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/ListingPreviewViewController.swift"
timestampString = "486667688.077144"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "123"
endingLineNumber = "123"
landmarkName = "publishItem(_:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/NetworksTableViewController.swift"
timestampString = "486667753.200944"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "194"
endingLineNumber = "194"
landmarkName = "draftItem(_:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/NetworksTableViewController.swift"
timestampString = "486667765.129109"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "205"
endingLineNumber = "205"
landmarkName = "draftItem(_:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/NetworksTableViewController.swift"
timestampString = "486667767.279182"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "217"
endingLineNumber = "217"
landmarkName = "draftItem(_:)"
landmarkType = "5">
<Locations>
<Location
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "Vendoo.NetworksTableViewController.draftItem (Swift.AnyObject) -&gt; ()"
moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/NetworksTableViewController.swift"
timestampString = "486668388.428422"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "217"
endingLineNumber = "217"
offsetFromSymbolStart = "6373">
</Location>
<Location
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "Vendoo.NetworksTableViewController.(draftItem (Swift.AnyObject) -&gt; ()).(closure #2)"
moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/NetworksTableViewController.swift"
timestampString = "486668388.428597"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "219"
endingLineNumber = "219"
offsetFromSymbolStart = "27">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/NetworksTableViewController.swift"
timestampString = "486667770.817087"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "224"
endingLineNumber = "224"
landmarkName = "draftItem(_:)"
landmarkType = "5">
<Locations>
<Location
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "Vendoo.NetworksTableViewController.(draftItem (Swift.AnyObject) -&gt; ()).(closure #2)"
moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/NetworksTableViewController.swift"
timestampString = "486668388.429243"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "225"
endingLineNumber = "225"
offsetFromSymbolStart = "1230">
</Location>
<Location
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "Vendoo.NetworksTableViewController.(draftItem (Swift.AnyObject) -&gt; ()).(closure #2)"
moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/NetworksTableViewController.swift"
timestampString = "486668388.429344"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "225"
endingLineNumber = "225"
offsetFromSymbolStart = "3095">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/NetworksTableViewController.swift"
timestampString = "486667830.848954"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "229"
endingLineNumber = "229"
landmarkName = "draftItem(_:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/NetworksTableViewController.swift"
timestampString = "486668074.57257"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "331"
endingLineNumber = "331"
landmarkName = "tableView(_:didSelectRowAtIndexPath:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/ItemTableViewController.swift"
timestampString = "486668654.124126"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "95"
endingLineNumber = "95"
landmarkName = "tableView(_:cellForRowAtIndexPath:)"
landmarkType = "5">
<Locations>
<Location
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "Vendoo.ItemTableViewController.tableView (__ObjC.UITableView, cellForRowAtIndexPath : __ObjC.NSIndexPath) -&gt; __ObjC.UITableViewCell"
moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/ItemTableViewController.swift"
timestampString = "486668654.127426"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "95"
endingLineNumber = "95"
offsetFromSymbolStart = "2618">
</Location>
<Location
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "Vendoo.ItemTableViewController.tableView (__ObjC.UITableView, cellForRowAtIndexPath : __ObjC.NSIndexPath) -&gt; __ObjC.UITableViewCell"
moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/ItemTableViewController.swift"
timestampString = "486668654.127626"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "95"
endingLineNumber = "95"
offsetFromSymbolStart = "8272">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
</Breakpoints> </Breakpoints>
</Bucket> </Bucket>

View File

@ -10,11 +10,15 @@ import Foundation
import OAuthSwift import OAuthSwift
import FBSDKCoreKit import FBSDKCoreKit
import FBSDKLoginKit import FBSDKLoginKit
import FBSDKShareKit
import AeroGearHttp import AeroGearHttp
import AeroGearOAuth2 import AeroGearOAuth2
import OAuthSwift import OAuthSwift
import Locksmith import Locksmith
protocol FacebookGraphAPIManagerDelegate {
func listingUploadedFB(fbID: String)
}
/* /*
NOTES: NOTES:
@ -33,6 +37,8 @@ class FacebookGraphAPIManager: NSObject {
private var userEmail:String = (NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)! private var userEmail:String = (NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)!
private let login: FBSDKLoginManager = FBSDKLoginManager() private let login: FBSDKLoginManager = FBSDKLoginManager()
var isAuthorized: Bool = NSUserDefaults.standardUserDefaults().boolForKey("fbAuthorized") var isAuthorized: Bool = NSUserDefaults.standardUserDefaults().boolForKey("fbAuthorized")
var listingID: String!
var delegate: FacebookGraphAPIManagerDelegate?
//---------------------------------------------// //---------------------------------------------//
override init(){ override init(){
@ -131,15 +137,25 @@ extension FacebookGraphAPIManager {
} }
//MARK: - request methods(GET, POST, DELETE) //MARK: - request methods(GET, POST, DELETE, SHARE)
extension FacebookGraphAPIManager { extension FacebookGraphAPIManager {
//share method
func makeSHARERequest(image: UIImage){
let photo : FBSDKSharePhoto = FBSDKSharePhoto()
photo.image = image
photo.userGenerated = true
let content : FBSDKSharePhotoContent = FBSDKSharePhotoContent()
content.photos = [photo]
}
//when making request make sure path starts with '/' //when making request make sure path starts with '/'
func makeGETRequest(requestPath: String!, params: [NSObject: AnyObject]!) -> Bool{ func makeGETRequest(requestPath: String!, params: [NSObject: AnyObject]!) -> Bool{
let graphRequest: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: requestPath, parameters: params) let graphRequest: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: requestPath, parameters: params)
var boolResult: Bool = false var boolResult: Bool = false
dispatch_async(dispatch_get_main_queue(), {
graphRequest.startWithCompletionHandler({ graphRequest.startWithCompletionHandler({
(id, result, error) -> Void in (id, result, error) -> Void in
@ -148,6 +164,7 @@ extension FacebookGraphAPIManager {
})
}) })
return boolResult return boolResult
@ -162,7 +179,18 @@ extension FacebookGraphAPIManager {
let graphRequest: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: requestPath, parameters: params, HTTPMethod: "POST") let graphRequest: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: requestPath, parameters: params, HTTPMethod: "POST")
graphRequest.startWithCompletionHandler({ graphRequest.startWithCompletionHandler({
(id, result, error) -> Void in (id, result, error) -> Void in
print(result)
if(error == nil){
print(result["id"])
self.delegate?.listingUploadedFB((result["id"] as? String)!)
print(result)
}
else{
}
//save id in firebase so retrieval can be done later //save id in firebase so retrieval can be done later
}) })
//} //}

View File

@ -106,19 +106,23 @@ extension ItemTableViewController: UITableViewDataSource{
if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["areNetworksChosen"])!){ if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["areNetworksChosen"])!){
cell.networks.hidden = true cell.networks.hidden = true
}else{ }else{
if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["ebay"])!){ dispatch_async(dispatch_get_main_queue(), {
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["ebay"])!){
} cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true
if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["amazon"])!){ }
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["amazon"])!){
} cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true
if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["etsy"])!){ }
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["etsy"])!){
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true
}
if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["facebook"])!){
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = true
}
})
}
if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["facebook"])!){
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = true
}
} }
return cell return cell
} }

View File

@ -31,7 +31,8 @@ class ListingPreviewViewController: UIViewController {
private var graphManager: FacebookGraphAPIManager! = nil private var graphManager: FacebookGraphAPIManager! = nil
private var firManager: FirebaseManager! = nil private var firManager: FirebaseManager! = nil
private var itemListingDictionary: Dictionary<String, AnyObject>! = Dictionary<String, AnyObject>() private var itemListingDictionary: Dictionary<String, AnyObject>! = Dictionary<String, AnyObject>()
private var alert = UIAlertController(title: "Listing Published", message: "Your listing has been published", preferredStyle: .Alert)
private var lastListingKey: String!
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
@ -42,6 +43,7 @@ class ListingPreviewViewController: UIViewController {
self.networks.delegate = self self.networks.delegate = self
self.networks.dataSource = self self.networks.dataSource = self
self.networks.backgroundView?.backgroundColor = UIColor.whiteColor() self.networks.backgroundView?.backgroundColor = UIColor.whiteColor()
self.graphManager.delegate = self
} }
override func viewDidAppear(animated: Bool) { override func viewDidAppear(animated: Bool) {
@ -86,6 +88,21 @@ class ListingPreviewViewController: UIViewController {
} }
//MARK: - FacebookGraphAPIManagerDelegate methods
extension ListingPreviewViewController: FacebookGraphAPIManagerDelegate {
func listingUploadedFB(fbID: String) {
var ref = self.firManager.ref.child("Users").child("\(self.firManager.user_email)").child("user_Listings").child(self.lastListingKey).updateChildValues(["network_listing_IDs":["fbID":fbID]])
self.alert.title = "Listing Published"
self.alert.message = "Your listing has been published to facebook"
self.presentViewController(self.alert, animated: true, completion: nil)
}
}
//MARK: - IBActions //MARK: - IBActions
extension ListingPreviewViewController { extension ListingPreviewViewController {
@ -122,19 +139,33 @@ extension ListingPreviewViewController {
newListingRef.setValue(listing) newListingRef.setValue(listing)
let alert = UIAlertController(title: "Listing Published", message: "Your listing has been published", preferredStyle: .Alert) self.alert.title = "Listing saved with error"
self.alert.message = "Your listing has been saved but something went wrong when trying to publish to facebook"
alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
self.presentViewController(alert, animated: true, completion: nil) //let alert = UIAlertController(title: "Listing Published", message: "Your listing has been published", preferredStyle: .Alert)
self.alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in self.alert.dismissViewControllerAnimated(true, completion: nil)}))
let parameters: Dictionary<String, AnyObject> = ["message":("**"+self.itemTitle.text!+"**\n\n"+"Price: "+self.itemPrice.text! + "\n\n"+self.itemDescription.text!)]
if(self.networksDictionary["facebook"]!){
//need to reverse process and upload to firebase last so that all network listing id's can be saved to firebase for notification access.
self.lastListingKey = newListingRef.key
self.graphManager.makePOSTResquest("me/feed", params: parameters)
}
//register new listing id in global path of firebase root'
self.firManager.ref.child("Global_listings").child(newListingRef.key).setValue(newListingRef.key)
}) })
//register new listing id in global path of firebase root'
self.firManager.ref.child("Global_listings").setValue(newListingRef.key)
}) })