Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add override point to create custom permissions manager #128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
}
Expand Down
5 changes: 5 additions & 0 deletions APCAppCore/APCAppCore/UI/Model/APCOnboardingManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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. */
Expand Down
6 changes: 5 additions & 1 deletion APCAppCore/APCAppCore/UI/Model/APCOnboardingManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down