I have been looking around for a solution and found only specific apps have background capabilities i.e. locational data and playing music. Assuming we have this permission, is there any way to record the swipe amount from all other apps and home screen, etc? The end goal is to record (in total) how far a user has scrolled using Swift.
So far, I have tested in app and can record a running total. However, is it possible to achieve this even when the app is inactive?
import UIKit
//test variable for storing scoll amount
var counter2 : Int = 0;
class ViewController: UIViewController {
@IBOutlet weak var sCounter: UILabel!
@IBOutlet weak var sMeasure: UILabel!
@IBOutlet var scrollMeasuer: UIPanGestureRecognizer!
@IBAction func scrollCounter (recognizer : UIPanGestureRecognizer) {
//var counter : Int = 0
let translation = recognizer.translationInView(self.view)
sMeasure.text = "\(translation)"
counter2 = abs(Int(abs(translation.x) + abs(translation.y)) + counter2)
sCounter.text = "\(counter2)"
}
}