Swift - Access past steps counting

I have a background as a developer but I am new to Swift. I kindly ask for support, for technicalities and to do a reality check of my request.

I need to design an experiment in which my app is opened and the user taps on "start experiment".(the experiment lasts 5 days)

Once "start experiment" is tapped, every 30 min I want to check how many steps have been done the 30 min before. (For example, at 08:30am I want to know how many steps have been done from 8:00am to 8:30am).

If the number of steps is less than 200 then I send a notification to the user like "walk more".

For now, what I have is (ViewController.swift):

//    get pedometer data on a certain date
func queryPedometerData(from start: Date, to end: Date, withHandler handler: @escaping CMPedometerHandler)

In case you want to know, the aim of the experiment is to see if notifications increase physical activity.

This is all I need to do. Is it doable?