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"
version = "2.0">
<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
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
@ -90,11 +10,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/ListingPreviewViewController.swift"
timestampString = "486667377.17358"
timestampString = "486686708.22622"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "93"
endingLineNumber = "93"
startingLineNumber = "155"
endingLineNumber = "155"
landmarkName = "publishItem(_:)"
landmarkType = "5">
</BreakpointContent>
@ -105,44 +25,107 @@
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/ListingPreviewViewController.swift"
timestampString = "486667688.077144"
filePath = "Vendoo/FacebookGraphAPIManager.swift"
timestampString = "486683097.861171"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "114"
endingLineNumber = "114"
landmarkName = "publishItem(_:)"
startingLineNumber = "174"
endingLineNumber = "174"
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">
<Locations>
<Location
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "Vendoo.ListingPreviewViewController.publishItem (Swift.AnyObject) -&gt; ()"
symbolName = "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 = "486668388.425523"
timestampString = "486686709.393085"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "114"
endingLineNumber = "114"
offsetFromSymbolStart = "6347">
startingLineNumber = "96"
endingLineNumber = "96"
offsetFromSymbolStart = "27">
</Location>
<Location
shouldBeEnabled = "Yes"
ignoreCount = "0"
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"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/ListingPreviewViewController.swift"
timestampString = "486668388.42562"
timestampString = "486686709.393207"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "116"
endingLineNumber = "116"
offsetFromSymbolStart = "27">
startingLineNumber = "94"
endingLineNumber = "94"
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>
</Locations>
</BreakpointContent>
@ -153,239 +136,15 @@
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/ListingPreviewViewController.swift"
timestampString = "486667688.077144"
filePath = "Vendoo/FacebookGraphAPIManager.swift"
timestampString = "486685960.664377"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "116"
endingLineNumber = "116"
landmarkName = "publishItem(_:)"
startingLineNumber = "187"
endingLineNumber = "187"
landmarkName = "makePOSTResquest(_:params:)"
landmarkType = "5">
</BreakpointContent>
</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>
</Bucket>

View File

@ -10,11 +10,15 @@ import Foundation
import OAuthSwift
import FBSDKCoreKit
import FBSDKLoginKit
import FBSDKShareKit
import AeroGearHttp
import AeroGearOAuth2
import OAuthSwift
import Locksmith
protocol FacebookGraphAPIManagerDelegate {
func listingUploadedFB(fbID: String)
}
/*
NOTES:
@ -33,6 +37,8 @@ class FacebookGraphAPIManager: NSObject {
private var userEmail:String = (NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)!
private let login: FBSDKLoginManager = FBSDKLoginManager()
var isAuthorized: Bool = NSUserDefaults.standardUserDefaults().boolForKey("fbAuthorized")
var listingID: String!
var delegate: FacebookGraphAPIManagerDelegate?
//---------------------------------------------//
override init(){
@ -131,15 +137,25 @@ extension FacebookGraphAPIManager {
}
//MARK: - request methods(GET, POST, DELETE)
//MARK: - request methods(GET, POST, DELETE, SHARE)
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 '/'
func makeGETRequest(requestPath: String!, params: [NSObject: AnyObject]!) -> Bool{
let graphRequest: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: requestPath, parameters: params)
var boolResult: Bool = false
dispatch_async(dispatch_get_main_queue(), {
graphRequest.startWithCompletionHandler({
(id, result, error) -> Void in
@ -148,6 +164,7 @@ extension FacebookGraphAPIManager {
})
})
return boolResult
@ -162,7 +179,18 @@ extension FacebookGraphAPIManager {
let graphRequest: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: requestPath, parameters: params, HTTPMethod: "POST")
graphRequest.startWithCompletionHandler({
(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
})
//}

View File

@ -106,19 +106,23 @@ extension ItemTableViewController: UITableViewDataSource{
if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["areNetworksChosen"])!){
cell.networks.hidden = true
}else{
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["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
}
dispatch_async(dispatch_get_main_queue(), {
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["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
}
})
}
return cell
}

View File

@ -31,7 +31,8 @@ class ListingPreviewViewController: UIViewController {
private var graphManager: FacebookGraphAPIManager! = nil
private var firManager: FirebaseManager! = nil
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() {
super.viewDidLoad()
@ -42,6 +43,7 @@ class ListingPreviewViewController: UIViewController {
self.networks.delegate = self
self.networks.dataSource = self
self.networks.backgroundView?.backgroundColor = UIColor.whiteColor()
self.graphManager.delegate = self
}
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
extension ListingPreviewViewController {
@ -122,19 +139,33 @@ extension ListingPreviewViewController {
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)
})