title: Keep accelerometer running when for app to background IOS
body: <p>I am using the  accelerometer in IOS and I want it to run in background mode.</p>
  
  <p>I tried to use <code>CMMotionManager</code> like this but it didn't work:</p>
  
  <pre><code>CMMotionManager*manager= [[CMMotionManager alloc] init];
  if(!manager.accelerometerAvailable) {
      NSLog(@"Accelerometer not available");
  } else {
      manager.accelerometerUpdateInterval = 0.1;
      NSOperationQueue *motionQueue = [[NSOperationQueue alloc] init];
  
      [manager startAccelerometerUpdatesToQueue: motionQueue withHandler:
       ^(CMAccelerometerData *data, NSError *error) {
           NSLog(@"Accelerometer data: %@", [data description]);
       }
       ];
  }
  </code></pre>
  
  <p>How can I do this?</p>