Fetch number of steps from HealthKit. Background mode issue

How can I get the number of steps per day from HealthKit at the end of the day if the app is not active, and then send a local push notification with a value?

I tried this example, but it didn’t work for me