Hi All,
I have been doing some search on how this can be done and it seems that current apps use the following key in info.plist to let it run in the background:
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
Then I have started CoreMotion.StartAccelerometerUpdates
on AppDelegate's DidEnterBackground method like this:
`public override void DidEnterBackground (UIApplication application) { Console.WriteLine ("App entering background state."); cm = new CMMotionManager (); int taskID = UIApplication.SharedApplication.BeginBackgroundTask ( () => {});
Thread task = new Thread (new ThreadStart ( () => {
cm.StartAccelerometerUpdates (NSOperationQueue.MainQueue, (data, error) =>
{
Console.WriteLine ("Motion: " + data.Acceleration.X.ToString("0.000000000"));
});
}));
task.Start ();
}`
Now this works great... up to around 9 to 10 minute mark at which point it terminates. What am I doing wrong here?