Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prompting permission for Motion & Fitness data

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?

like image 794
leonsas Avatar asked Oct 18 '15 21:10

leonsas


People also ask

Why doesn't my iPhone have motion and fitness?

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.

What is motion and fitness on iPhone?

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.


1 Answers

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.

like image 107
Sommm Avatar answered Oct 19 '22 23:10

Sommm