Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Pilgrim - swift feedback example
//
// UIAlertController+Feedback.swift
// Copyright © 2018 Foursquare. All rights reserved.
//
import Foundation
extension UIAlertController {
static func presentFeedbackAlertControllerForVisit(_ visit: FSQPVisit, controller: UIViewController, dismiss: (() -> Void)? = nil) {
let alertController = UIAlertController(title: "Provide feedback:", message: visit.description, preferredStyle: .actionSheet)
if let pilgrimVisitId = visit.pilgrimVisitId, let feedbackProvider = FSQPPilgrimManager.shared().feedbackProvider {
let correctAction = UIAlertAction(title: "Confirm", style: .default) { (action) -> Void in
feedbackProvider.provideFeedback(
forPVisit: pilgrimVisitId,
feedback: .confirm,
actualVenueId: nil,
completion: nil)
}
alertController.addAction(correctAction)
let falseStopAction = UIAlertAction(title: "False stop", style: .default) { (action) -> Void in
feedbackProvider.provideFeedback(
forPVisit: pilgrimVisitId,
feedback: .falseStop,
actualVenueId: nil,
completion: nil)
}
alertController.addAction(falseStopAction)
let wrongVenueAction = UIAlertAction(title: "Wrong venue", style: .default) { (action) -> Void in
// TODO: If selected, you should probably add an option for users to select the accurate venue
// and send in the actual venue ID.
feedbackProvider.provideFeedback(
forPVisit: pilgrimVisitId,
feedback: .wrongVenue,
actualVenueId: nil,
completion: nil)
}
alertController.addAction(wrongVenueAction)
let denyAction = UIAlertAction(title: "Deny", style: .default) { (action) -> Void in
feedbackProvider.provideFeedback(
forPVisit: pilgrimVisitId,
feedback: .deny,
actualVenueId: nil,
completion: nil)
}
alertController.addAction(denyAction)
}
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
alertController.addAction(cancelAction)
controller.present(alertController, animated: true, completion: dismiss)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.