Skip to content

Commit

Permalink
Merge pull request #8 from chrisinsfo/APCOnboardingManagerProvider
Browse files Browse the repository at this point in the history
Conform to updated APCOnboardingManagerProvider
  • Loading branch information
YuanZhu-apple committed Jul 28, 2015
2 parents 0ef7427 + 4ebfd4b commit 6d493bf
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 43 deletions.
108 changes: 66 additions & 42 deletions Parkinson/Startup/APHAppDelegate.m
Expand Up @@ -76,8 +76,8 @@ - (BOOL)application:(UIApplication*) __unused application willFinishLaunchingWit

- (void)enableBackgroundDeliveryForHealthKitTypes
{
NSArray* dataTypesWithReadPermission = self.initializationOptions[kHKReadPermissionsKey];

NSArray* dataTypesWithReadPermission = [self healthKitQuantityTypesToRead];
if (dataTypesWithReadPermission)
{
for (id dataType in dataTypesWithReadPermission)
Expand Down Expand Up @@ -128,14 +128,7 @@ - (void)enableBackgroundDeliveryForHealthKitTypes

- (void)setUpInitializationOptions
{
NSDictionary *permissionsDescriptions = @{
@(kAPCSignUpPermissionsTypeLocation) : NSLocalizedString(@"Using your GPS enables the app to accurately determine distances travelled. Your actual location will never be shared.", @""),
@(kAPCSignUpPermissionsTypeCoremotion) : NSLocalizedString(@"Using the motion co-processor allows the app to determine your activity, helping the study better understand how activity level may influence disease.", @""),
@(kAPCSignUpPermissionsTypeMicrophone) : NSLocalizedString(@"Access to microphone is required for your Voice Recording Activity.", @""),
@(kAPCSignUpPermissionsTypeLocalNotifications) : NSLocalizedString(@"Allowing notifications enables the app to show you reminders.", @""),
@(kAPCSignUpPermissionsTypeHealthKit) : NSLocalizedString(@"On the next screen, you will be prompted to grant mPower access to read and write some of your general and health information, such as height, weight and steps taken so you don't have to enter it again.", @""),
};


NSMutableDictionary * dictionary = [super defaultInitializationOptions];
#ifdef DEBUG
self.environment = SBBEnvironmentStaging;
Expand All @@ -148,34 +141,6 @@ - (void)setUpInitializationOptions
kStudyIdentifierKey : kStudyIdentifier,
kAppPrefixKey : kAppPrefix,
kBridgeEnvironmentKey : @(self.environment),
kHKReadPermissionsKey : @[
HKQuantityTypeIdentifierBodyMass,
HKQuantityTypeIdentifierHeight,
HKQuantityTypeIdentifierStepCount,
HKQuantityTypeIdentifierDistanceCycling,
HKQuantityTypeIdentifierDistanceWalkingRunning,
HKQuantityTypeIdentifierFlightsClimbed,
@{kHKWorkoutTypeKey : HKWorkoutTypeIdentifier},
@{kHKCategoryTypeKey : HKCategoryTypeIdentifierSleepAnalysis}
],
kHKWritePermissionsKey : @[
],
kAppServicesListRequiredKey : @[
@(kAPCSignUpPermissionsTypeLocation),
@(kAPCSignUpPermissionsTypeCoremotion),
@(kAPCSignUpPermissionsTypeMicrophone),
@(kAPCSignUpPermissionsTypeLocalNotifications)
],
kAppServicesDescriptionsKey : permissionsDescriptions,
kAppProfileElementsListKey : @[
@(kAPCUserInfoItemTypeEmail),
@(kAPCUserInfoItemTypeDateOfBirth),
@(kAPCUserInfoItemTypeBiologicalSex),
@(kAPCUserInfoItemTypeHeight),
@(kAPCUserInfoItemTypeWeight),
@(kAPCUserInfoItemTypeWakeUpTime),
@(kAPCUserInfoItemTypeSleepTime),
],
kShareMessageKey : NSLocalizedString(@"Please take a look at Parkinson mPower, a research study app about Parkinson Disease. Download it for iPhone at http://apple.co/1FO7Bsi", nil)
}];

Expand Down Expand Up @@ -563,9 +528,9 @@ - (void)configureObserverQueries
}
return stringToWrite;
};

NSArray* dataTypesWithReadPermission = self.initializationOptions[kHKReadPermissionsKey];

NSArray* dataTypesWithReadPermission = [self healthKitQuantityTypesToRead];
if (!self.passiveDataCollector)
{
self.passiveDataCollector = [[APCPassiveDataCollector alloc] init];
Expand Down Expand Up @@ -655,7 +620,7 @@ - (void)configureObserverQueries
}

/*********************************************************************************/
#pragma mark - APCOnboardingDelegate Methods
#pragma mark - APCOnboardingManagerProvider Methods
/*********************************************************************************/

- (APCScene *)inclusionCriteriaSceneForOnboarding:(APCOnboarding *) __unused onboarding
Expand All @@ -668,6 +633,65 @@ - (APCScene *)inclusionCriteriaSceneForOnboarding:(APCOnboarding *) __unused onb
return scene;
}

-(APCPermissionsManager * __nonnull)permissionsManager
{
return [[APCPermissionsManager alloc] initWithHealthKitCharacteristicTypesToRead:[self healthKitCharacteristicTypesToRead]
healthKitQuantityTypesToRead:[self healthKitQuantityTypesToRead]
healthKitQuantityTypesToWrite:[self healthKitQuantityTypesToWrite]
userInfoItemTypes:[self userInfoItemTypes]
signUpPermissionTypes:[self signUpPermissionsTypes]];
}

- (NSArray *)healthKitCharacteristicTypesToRead
{
return @[
HKCharacteristicTypeIdentifierBiologicalSex,
HKCharacteristicTypeIdentifierDateOfBirth
];
}

- (NSArray *)healthKitQuantityTypesToWrite
{
return @[];
}

- (NSArray *)healthKitQuantityTypesToRead
{
return @[
HKQuantityTypeIdentifierBodyMass,
HKQuantityTypeIdentifierHeight,
HKQuantityTypeIdentifierStepCount,
HKQuantityTypeIdentifierDistanceCycling,
HKQuantityTypeIdentifierDistanceWalkingRunning,
HKQuantityTypeIdentifierFlightsClimbed,
@{kHKWorkoutTypeKey : HKWorkoutTypeIdentifier},
@{kHKCategoryTypeKey : HKCategoryTypeIdentifierSleepAnalysis}
];
}

- (NSArray *)signUpPermissionsTypes
{
return @[
@(kAPCSignUpPermissionsTypeLocation),
@(kAPCSignUpPermissionsTypeCoremotion),
@(kAPCSignUpPermissionsTypeMicrophone),
@(kAPCSignUpPermissionsTypeLocalNotifications)
];
}

- (NSArray *)userInfoItemTypes
{
return @[
@(kAPCUserInfoItemTypeEmail),
@(kAPCUserInfoItemTypeDateOfBirth),
@(kAPCUserInfoItemTypeBiologicalSex),
@(kAPCUserInfoItemTypeHeight),
@(kAPCUserInfoItemTypeWeight),
@(kAPCUserInfoItemTypeWakeUpTime),
@(kAPCUserInfoItemTypeSleepTime),
];
}

/*********************************************************************************/
#pragma mark - Consent
/*********************************************************************************/
Expand Down

0 comments on commit 6d493bf

Please sign in to comment.