I want users to be prompted as soon as app launches for permission to access Motion & Fitness data (CoreMotion).
Right now I'm trying to do a "dummy" query for the data to prompt the permission on a application:didFinishLaunchingWithOptions
CMMotionActivityManager *motionActivityManager=[[CMMotionActivityManager alloc]init];
[motionActivityManager startActivityUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMMotionActivity *activity) {
NSLog(@"Dummy query to prompt permission from user");
}];
But what happens is the app launches and it hangs on the splash screen — if I press home button then the app tries closing and THEN the permission prompt pops in.
Any thought how to accomplish this?
An app must request an access to use Motion & Fitness before it will appear it under Settings > Privacy > Motion/Fitness. Check if app offers in-app settings menu and where to make changes for it.
Fitness and Motion is enabled by default and runs in the background, a fact which many users were unaware about. Running in the background allows your iPhone to keep track of all your motion without you needing to have a particular application open.
I researched on motion manager and tried to create a library for motion detection. From that, i got to know permission for motion detection will pop up when the below code will execute.
CMMotionActivityManager *motionActivityManager = [[CMMotionActivityManager alloc]init];
[motionActivityManager startActivityUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMMotionActivity *activity) {
NSLog(@"Motion...%@",activity);
}];
Hope this will help you. Thank you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With