You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.4 KiB
Swift
50 lines
1.4 KiB
Swift
//
|
|
// ViewController.swift
|
|
// surveys-example
|
|
//
|
|
// Created by Juan David López Regalado on 12/06/24.
|
|
//
|
|
|
|
import UIKit
|
|
import ResearchKit
|
|
import ResearchKitUI
|
|
|
|
class ViewController: UIViewController, ORKTaskViewControllerDelegate {
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
// Do any additional setup after loading the view.
|
|
}
|
|
|
|
|
|
@IBAction func startSurveyTapped(_ sender: Any) {
|
|
let consentTask = ConsentManager.shared.createConsentTask()
|
|
let taskViewController = ORKTaskViewController(task: consentTask, taskRun: nil)
|
|
|
|
taskViewController.delegate = self
|
|
present(taskViewController,animated: true, completion: nil)
|
|
|
|
}
|
|
|
|
func taskViewController(_ taskViewController: ORKTaskViewController, didFinishWith reason: ORKTaskFinishReason, error: (any Error)?) {
|
|
taskViewController.dismiss(animated: true, completion: nil)
|
|
|
|
|
|
|
|
if reason == .completed {
|
|
startSurvey()
|
|
}
|
|
|
|
func startSurvey() {
|
|
let surveyTask = SurveyManager.shared.createSurveyTask()
|
|
let taskViewController = ORKTaskViewController(task: surveyTask, taskRun: nil)
|
|
|
|
taskViewController.delegate = self
|
|
present(taskViewController, animated: true, completion: nil)
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|