objective c - Prompt the user to authorise the application to share types in HealthKit -
when first calling requestauthorizationtosharetypes:readtypes:completion:
of hkhealthstore
set of hkquantitytype
want permissions to, can see modal view requesting authorization user read , share every type of object application may require access.
i'm trying figure out if there way prompt user modal view, besides first time i'm calling: requestauthorizationtosharetypes:readtypes:completion:
.
i tried calling requestauthorizationtosharetypes:readtypes:completion:
every time same set after first call not prompting anymore. when trying change set new type wasn't there before can prompt screen, don't think calling method each time new hkquantitytype
in set right way (as there limit amount of types exists).
is possible?
thanks whatsoever.
update
i'll add code snippet of call:
[self.healthstore requestauthorizationtosharetypes:writedatatypes readtypes:readdatatypes completion:^(bool success, nserror *error) { if (!success) { nslog(@"you didn't allow healthkit access these read/write data types. error was: %@.", error); return; } dispatch_async(dispatch_get_main_queue(), ^{ // update user interface based on current user's health information. }); }];
where writedatatypesz
, readdatatypes
nsset
returned following methods:
// returns types of data want write healthkit. - (nsset *)datatypestowrite { hkquantitytype *heighttype = [hkquantitytype quantitytypeforidentifier:hkquantitytypeidentifierheight]; hkquantitytype *weighttype = [hkquantitytype quantitytypeforidentifier:hkquantitytypeidentifierbodymass]; return [nsset setwithobjects: heighttype, weighttype, nil]; } // returns types of data want read healthkit. - (nsset *)datatypestoread { hkquantitytype *heighttype = [hkquantitytype quantitytypeforidentifier:hkquantitytypeidentifierheight]; hkquantitytype *weighttype = [hkquantitytype quantitytypeforidentifier:hkquantitytypeidentifierbodymass]; hkcharacteristictype *birthdaytype = [hkcharacteristictype characteristictypeforidentifier:hkcharacteristictypeidentifierdateofbirth]; hkcharacteristictype *biologicalsex = [hkcharacteristictype characteristictypeforidentifier:hkcharacteristictypeidentifierbiologicalsex]; return [nsset setwithobjects:heighttype,weighttype,birthdaytype,biologicalsex, nil]; }
changing set include new types each time call requestauthorizationtosharetypes:readtypes:completion:
results in opening view types ever asked permissions (not in specific call):
by design, not possible re-prompt user authorization. if user consider changing authorizations app, ask them go settings or health app so.
Comments
Post a Comment