Skip to content

Instantly share code, notes, and snippets.

@darthpelo
Last active September 26, 2018 13:43
Show Gist options
  • Save darthpelo/77ef2674b7d815819f4e16beee570670 to your computer and use it in GitHub Desktop.
Save darthpelo/77ef2674b7d815819f4e16beee570670 to your computer and use it in GitHub Desktop.
func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
return handle(userAcitivity: userActivity)
}
// MARK: - Private
private func handle(userAcitivity activity: NSUserActivity) -> Bool {
switch activity.activityType {
case "com.mobiquity.TakeUrPill.history":
UserDefaults.standard.userSession = UserSession.History.rawValue
let notificationName = Notification.Name(rawValue: "com.mobiquity.TakeUrPill.history")
NotificationCenter.default.post(name: notificationName, object: nil)
return true
default:()
}
return false
}
// Function associated to the notification "com.mobiquity.TakeUrPill.history"
// triggered from AppDelegate
@objc func checkUserSession() {
userSession()
}
// The presenter checks in which status the user is. If he is in the History, it's not
// neccesary to show the History
private func userSession() {
if let presenter = presenter, presenter.showUserHistory() {
showHistory()
}
}
// This function just triggers the Flow Controller, that will bring the user to the
// History section
private func showHistory() {
configure?.controller.show()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment