Rotating or normalizing CMAcceleration data

I'm trying to use CMAcceleration data in my app to detect when the user is doing certain kinds of activities.

The problem I'm having is that the acceleration data for the same user motions is different depending on how they are holding their phone. I don't care about the orientation of the phone, I just care about the overall motion of the person holding it.

I've researched and tried a whole bunch of ways to correct the data for phone orientation, such as rotating the acceleration using the CMAttitude rotation matrix, removing the effect of gravity with a series of calculations, and doing both of these in both orders. I can't seem to come up with something that works.

I think there has to be some solution since iOS can do things like step counting which I assume doesn't depend on the orientation of the phone.

Thanks, Frank

Rotating or normalizing CMAcceleration data
 
 
Q