diff --git a/APCAppCore/APCAppCore/Library/Permissions/APCPermissionsManager.h b/APCAppCore/APCAppCore/Library/Permissions/APCPermissionsManager.h index 0f1adc76..288dbd62 100644 --- a/APCAppCore/APCAppCore/Library/Permissions/APCPermissionsManager.h +++ b/APCAppCore/APCAppCore/Library/Permissions/APCPermissionsManager.h @@ -47,9 +47,18 @@ typedef NS_ENUM(NSUInteger, APCPermissionStatus) { @property (copy, nonatomic) NSArray *userInfoItemTypes; @property (copy, nonatomic) NSArray *signUpPermissionTypes; +/** + * Designated initializer. + * + * @param characteristicTypesToRead Array of strings defined as `HKCharacteristicTypeIdentifier*` constants + * @param quantityTypesToRead Array of strings defined as `HKQuantityTypeIdentifier*` constants or dictionaries encoding other types (TODO: improve and document) + * @param quantityTypesToWrite Array of strings defined as `HKQuantityTypeIdentifier*` constants or dictionaries encoding other types (TODO: improve and document) + * @param userInfoItemTypes Array of numbers representing `APCUserInfoItemType` types + * @param signUpPermissionTypes Array of numbers representing `APCSignUpPermissionsType` types + */ - (id)initWithHealthKitCharacteristicTypesToRead:(NSArray *)characteristicTypesToRead healthKitQuantityTypesToRead:(NSArray *)quantityTypesToRead - healthKitQuantityTypesToWrite:(NSArray *)QuantityTypesToWrite + healthKitQuantityTypesToWrite:(NSArray *)quantityTypesToWrite userInfoItemTypes:(NSArray *)userInfoItemTypes signUpPermissionTypes:(NSArray *)signUpPermissionTypes; diff --git a/APCAppCore/APCAppCore/Library/Permissions/APCPermissionsManager.m b/APCAppCore/APCAppCore/Library/Permissions/APCPermissionsManager.m index cd65c76f..a4531373 100644 --- a/APCAppCore/APCAppCore/Library/Permissions/APCPermissionsManager.m +++ b/APCAppCore/APCAppCore/Library/Permissions/APCPermissionsManager.m @@ -87,7 +87,7 @@ - (instancetype)init - (id)initWithHealthKitCharacteristicTypesToRead:(NSArray *)characteristicTypesToRead healthKitQuantityTypesToRead:(NSArray *)quantityTypesToRead - healthKitQuantityTypesToWrite:(NSArray *)QuantityTypesToWrite + healthKitQuantityTypesToWrite:(NSArray *)quantityTypesToWrite userInfoItemTypes:(NSArray *)userInfoItemTypes signUpPermissionTypes:(NSArray *)signUpPermissionTypes { @@ -96,7 +96,7 @@ - (id)initWithHealthKitCharacteristicTypesToRead:(NSArray *)characteristicTypesT if (self) { self.healthKitCharacteristicTypesToRead = characteristicTypesToRead; self.healthKitTypesToRead = quantityTypesToRead; - self.healthKitTypesToWrite = QuantityTypesToWrite; + self.healthKitTypesToWrite = quantityTypesToWrite; self.signUpPermissionTypes = signUpPermissionTypes; self.userInfoItemTypes = userInfoItemTypes; } diff --git a/APCAppCore/APCAppCore/UI/Model/APCOnboardingManager.h b/APCAppCore/APCAppCore/UI/Model/APCOnboardingManager.h index f74d7627..26ad0806 100644 --- a/APCAppCore/APCAppCore/UI/Model/APCOnboardingManager.h +++ b/APCAppCore/APCAppCore/UI/Model/APCOnboardingManager.h @@ -49,8 +49,10 @@ NS_ASSUME_NONNULL_BEGIN @required /** The onboarding manager for the app. */ - (APCOnboardingManager *)onboardingManager; + /** The permissions manager for the app. */ - (APCPermissionsManager *)permissionsManager; + @optional /** * Kept for backwards compatibility: return the inclusion criteria scene. @@ -92,6 +94,9 @@ NS_ASSUME_NONNULL_BEGIN - (void)instantiateOnboardingForType:(APCOnboardingTaskType)type; +/** Override point to create a custom permissions manager. By default returns the receiver provider's permission manager. */ +- (APCPermissionsManager *)createPermissionsManager; + #pragma mark Onboarding /** Called when the user has agreed to and completed all consenting steps. */ diff --git a/APCAppCore/APCAppCore/UI/Model/APCOnboardingManager.m b/APCAppCore/APCAppCore/UI/Model/APCOnboardingManager.m index d6aa1a6b..30fd21fe 100644 --- a/APCAppCore/APCAppCore/UI/Model/APCOnboardingManager.m +++ b/APCAppCore/APCAppCore/UI/Model/APCOnboardingManager.m @@ -122,11 +122,15 @@ - (void)completeOnboardingAsSignIn:(BOOL)wasSignIn { - (APCPermissionsManager *)permissionsManager { if (!_permissionsManager) { - _permissionsManager = [self.provider permissionsManager]; + _permissionsManager = [self createPermissionsManager]; } return _permissionsManager; } +- (APCPermissionsManager *)createPermissionsManager { + return [self.provider permissionsManager]; +} + #pragma mark - APCOnboardingDelegate - (APCScene *)onboarding:(APCOnboarding * __nonnull)onboarding sceneOfType:(NSString * __nonnull)type {