SBBUserManager Class Reference

Inherits from SBBBridgeAPIManager : NSObject
Conforms to SBBComponent
SBBUserManagerProtocol
Declared in SBBUserManager.h
SBBUserManager.m

Overview

This class handles communication with the Bridge users API.

– getUserProfileWithCompletion:

Fetch the UserProfile from the Bridge API.

- (NSURLSessionTask *)getUserProfileWithCompletion:(SBBUserManagerGetProfileCompletionBlock)completion

Parameters

completion

An SBBUserManagerGetProfileCompletionBlock to be called upon completion.

Return Value

An NSURLSessionTask object so you can cancel or suspend/resume the request.

Declared In

SBBUserManager.h

– updateUserProfileWithProfile:completion:

Update the UserProfile to the Bridge API.

- (NSURLSessionTask *)updateUserProfileWithProfile:(id)profile completion:(SBBUserManagerCompletionBlock)completion

Parameters

profile

A client object representing the UserProfile as it should be updated.

completion

An SBBUserManagerCompletionBlock to be called upon completion.

Return Value

An NSURLSessionTask object so you can cancel or suspend/resume the request.

Declared In

SBBUserManager.h

– addExternalIdentifier:completion:

Add an external identifier for a participant.

- (NSURLSessionTask *)addExternalIdentifier:(NSString *)externalID completion:(SBBUserManagerCompletionBlock)completion

Parameters

externalID

An external identifier to allow this participant to be tracked outside of the Bridge-specific study.

completion

An SBBUserManagerCompletionBlock to be called upon completion.

Return Value

An NSURLSessionTask object so you can cancel or suspend/resume the request.

Discussion

For research studies designed to enroll participants who are tracked outside of the Bridge-specific study, you can build your application to submit a unique external identifier to the Bridge Server for that user. This can happen any time after an email address has been validated. The identifier will be exported with research data, but not with exports that provide the identities of the people in the study (like the participant roster). The identifier should be unique for the user in this study, but this is not validated by the Bridge server. The identifier can be updated, but never deleted (if absolutely necessary, set it to a “deleted” value like “N/A”)

Declared In

SBBUserManager.h

– emailDataToUserFrom:to:completion:

Email the user’s study data in the specified date range to the email address associated with their account.

- (NSURLSessionTask *)emailDataToUserFrom:(NSDate *)startDate to:(NSDate *)endDate completion:(SBBUserManagerCompletionBlock)completion

Parameters

startDate

The starting date for the data to be sent.

endDate

The ending date for the data to be sent.

Return Value

An NSURLSessionTask object so you can cancel or suspend/resume the request.

Declared In

SBBUserManager.h

– dataSharing:completion:

Change the scope of data sharing for this user. This should only be done in response to an explicit choice on the part of the user to change the sharing scope.

- (NSURLSessionTask *)dataSharing:(SBBUserDataSharingScope)scope completion:(SBBUserManagerCompletionBlock)completion

Parameters

scope

The scope of data sharing to set for this user.

completion

An SBBUserManagerCompletionBlock to be called upon completion.

Return Value

An NSURLSessionTask object so you can cancel or suspend/resume the request.

Declared In

SBBUserManager.h

– getDataGroupsWithCompletion:

Fetch the data groups to which this user belongs from the Bridge API.

- (NSURLSessionTask *)getDataGroupsWithCompletion:(SBBUserManagerGetGroupsCompletionBlock)completion

Parameters

completion

An SBBUserManagerGetGroupsCompletionBlock to be called upon completion.

Return Value

An NSURLSessionTask object so you can cancel or suspend/resume the request.

Declared In

SBBUserManager.h

– updateDataGroupsWithGroups:completion:

Update the user’s dataGroups to the Bridge API.

- (NSURLSessionTask *)updateDataGroupsWithGroups:(id)dataGroups completion:(SBBUserManagerCompletionBlock)completion

Parameters

dataGroups

A client object representing the dataGroups as they should be updated.

completion

An SBBUserManagerCompletionBlock to be called upon completion.

Return Value

An NSURLSessionTask object so you can cancel or suspend/resume the request.

Discussion

Note: If using caching, be aware that calling this method (or any of the convenience methods which call it) will remove unexpired, unfinished scheduled activities from the cache. The next call to get scheduled activities will replace them with the correct schedule going forward for the new set of data groups.

Declared In

SBBUserManager.h

– addToDataGroups:completion:

Add the user to the specified data groups (tags).

- (void)addToDataGroups:(NSArray<NSString*> *)dataGroups completion:(SBBUserManagerCompletionBlock)completion

Parameters

dataGroups

The data groups to which to add the user. This is a convenience method which first calls getDataGroupsWithCompletion:, and in its completion handler, adds the specified groups to the returned dataGroups and posts the modified dataGroups back to the Bridge API via updateDataGroupWithGroups:completion:. If there is an error fetching the user’s existing dataGroups, that error will be passed to the completion handler. If an attempt is made to add a user to one or more data groups that haven’t first been defined in the study, the Bridge API will respond with 400 (Bad Request) with an error message detailing the problem in the body of the response.

completion

An SBBUserManagerCompletionBlock to be called upon completion.

Declared In

SBBUserManager.h

– removeFromDataGroups:completion:

Remove the user from the specified data groups (tags).

- (void)removeFromDataGroups:(NSArray<NSString*> *)dataGroups completion:(SBBUserManagerCompletionBlock)completion

Parameters

dataGroups

The data groups from which to remove the user. This is a convenience method which first calls getDataGroupsWithCompletion:, and in its completion handler, removes the specified groups from the returned dataGroups and posts the modified dataGroups back to the Bridge API via updateDataGroupWithGroups:completion:. If there is an error fetching the user’s existing dataGroups, that error will be passed to the completion handler. If the fetch succeeds but the user is not a member of one or more of these data groups, whether because they haven’t been added or because they don’t exist in the study, this method will complete without updating the user’s dataGroups and without an error.

completion

An SBBUserManagerCompletionBlock to be called upon completion.

Declared In

SBBUserManager.h