This repository was archived by the owner on Sep 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathBridgeSDK.h
354 lines (312 loc) · 15.6 KB
/
BridgeSDK.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
//
// BridgeSDK.h
// BridgeSDK
//
// Copyright (c) 2014-2021, Sage Bionetworks
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of Sage Bionetworks nor the names of BridgeSDk's
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL SAGE BIONETWORKS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#import <UIKit/UIKit.h>
#ifdef __cplusplus
extern "C" {
#endif
//! Project version number for BridgeSDK.
extern double BridgeSDKVersionNumber;
//! Project version string for BridgeSDK.
extern const unsigned char BridgeSDKVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <BridgeSDK/PublicHeader.h>
#import <BridgeSDK/SBBActivityEventManager.h>
#import <BridgeSDK/SBBActivityManager.h>
#import <BridgeSDK/SBBAuthManager.h>
#import <BridgeSDK/SBBBridgeNetworkManager.h>
#import <BridgeSDK/SBBBridgeAppDelegate.h>
#import <BridgeSDK/SBBBridgeErrorUIDelegate.h>
#import <BridgeSDK/SBBBridgeInfoProtocol.h>
#import <BridgeSDK/SBBBridgeInfo.h>
#import <BridgeSDK/SBBJSONValue.h>
#import <BridgeSDK/SBBComponent.h>
#import <BridgeSDK/SBBComponentManager.h>
#import <BridgeSDK/SBBConsentManager.h>
#import <BridgeSDK/SBBNotificationManager.h>
#import <BridgeSDK/SBBOAuthManager.h>
#import <BridgeSDK/SBBObjectManager.h>
#import <BridgeSDK/SBBParticipantManager.h>
#import <BridgeSDK/SBBScheduleManager.h>
#import <BridgeSDK/SBBStudyManager.h>
#import <BridgeSDK/SBBSurveyManager.h>
#import <BridgeSDK/SBBUploadManager.h>
#import <BridgeSDK/SBBUserManager.h>
#import <BridgeSDK/SBBNetworkManager.h>
#import <BridgeSDK/SBBErrors.h>
#import <BridgeSDK/SBBDataArchive.h>
#import <BridgeSDK/SBBBridgeObjects.h>
#import <BridgeSDK/NSData+SBBAdditions.h>
#import <BridgeSDK/NSDate+SBBAdditions.h>
#import <BridgeSDK/NSError+SBBAdditions.h>
#import <BridgeSDK/NSBundle+SBBAdditions.h>
#import <BridgeSDK/NSString+SBBAdditions.h>
#import <BridgeSDK/UIDevice+Hardware.h>
// This sets the default environment at app (not SDK) compile time to Staging for debug builds and Production for non-debug.
#if DEBUG
#define kDefaultEnvironment SBBEnvironmentStaging
#else
#define kDefaultEnvironment SBBEnvironmentProd
#endif
static SBBEnvironment gDefaultEnvironment = kDefaultEnvironment;
// The default number of days to cache
extern const NSInteger SBBDefaultCacheDaysAhead;
extern const NSInteger SBBDefaultCacheDaysBehind;
// The maximum number of days that are supported for caching.
extern const NSInteger SBBMaxSupportedCacheDays;
// The default NSUserDefaults suite to use if not otherwise specified at setup time
extern const NSString * _Nullable SBBDefaultUserDefaultsSuiteName;
extern NSNotificationName const _Nonnull kSBBAppConfigUpdatedNotification;
extern NSString * const _Nonnull kSBBAppConfigInfoKey;
@interface BridgeSDK : NSObject
/*!
* Set up the Bridge SDK based on settings passed in a configuration object.
*
* This is and setupWithBridgeInfo: are now the preferred methods for initializing the Bridge SDK.
* All other methods are deprecated.
*
* This method searches the main bundle for a plist resource with the filename `BridgeInfo.plist` and merges
* its contents with a second (optional) plist called `BridgeInfo-private.plist`. The resulting dictionary of
* settings is used to set up the SBBBridgeInfo shared object.
*
* See SBBBridgeInfoProtocol for a description of the keys and values for these plists. If not specified,
* `environment` defaults to SBBEnvironmentProd, and `cacheDaysAhead` and `cacheDaysBehind` default to 0
* (BridgeSDK caching disabled). You only need to specify `appGroupIdentifier` if you've set up an app group
* under your target's Capabilities in Xcode, and you want BridgeSDK to use that shared space.
*/
+ (void)setup;
/*!
* Set up the Bridge SDK based on settings passed in a configuration object.
*
* This is and setup are now the preferred methods for initializing the Bridge SDK.
* All other methods are deprecated.
*
* @param info An object of a class that conforms to SBBBridgeInfoProtocol containing the desired configuration settings.
* @see SBBBridgeInfoProtocol
* @see SBBBridgeInfo
*/
+ (void)setupWithBridgeInfo:(nonnull id<SBBBridgeInfoProtocol>)info;
/*!
* Get the UserDefaults suite being used by BridgeSDK. This will either be the suite with the appGroupIdentifier name,
* or if no appGroupIdentifier was specified in the setup info object, then this will be standardUserDefaults.
*/
+ (nonnull NSUserDefaults *)sharedUserDefaults;
/*
* Call this in your app delegate's application:handleEventsForBackgroundURLSession:completionHandler: method to
* ensure that uploads to Bridge can be completed when a network connection becomes available.
*
* If this method returns NO, the session didn't belong to BridgeSDK, so your app will be responsible for
* restoring it (or ignoring it, as the case may be).
*
* @param identifier The background session identifier passed to your app delegate.
* @param completionHandler The completion handler passed to your app delegate.
* @return YES if the session belonged to BridgeSDK and was restored by this method, NO otherwise.
*/
+ (BOOL)restoreBackgroundSession:(nonnull NSString *)identifier completionHandler:(nonnull void (^)(void))completionHandler;
/*!
* Get the AppConfig for this app/platform/version/etc. as retrieved from the Bridge study.
*
* When the Bridge study has been set up by calling setup or setupWithBridgeInfo:, the appropriate AppConfig will be retrieved
* from Bridge. Until that request has succeeded for the first time, this value will be nil. Once retrieved, it will be cached
* (in User Defaults if BridgeSDK is configured not to use caching) and the cached value will be used until the current value
* is retrieved from Bridge.
*/
+ (nullable SBBAppConfig *)appConfig;
/*!
* Set a delegate to handle presenting appropriate UI to the study participant in case of "not consented" (412) and "app version not supported" (410) error responses from Bridge.
*
* @param delegate An object that conforms to the SBBBridgeErrorUIDelegate protocol to handle UI for Bridge "not consented" (412) and "app version not supported" (410) error responses.
*/
+ (void)setErrorUIDelegate:(nullable id<SBBBridgeErrorUIDelegate>)delegate;
/*!
* Get the currently-registered activityManager.
*
* If no activityManager has been registered, this will register a default manager and return that.
*
* @see SBBActivityManagerProtocol
*/
@property (class, nonnull, nonatomic) id<SBBActivityManagerProtocol> activityManager;
/*!
* Get the currently-registered authManager.
*
* If no authManager has been registered, this will register a default manager and return that.
*
* @see SBBAuthManagerProtocol
*/
@property (class, nonnull, nonatomic) id<SBBAuthManagerProtocol> authManager;
/*!
* Get the shared BridgeInfo object.
*
* If BridgeSDK has not yet been set up, all the fields will be blank.
*
* @see SBBBridgeInfoProtocol
*/
@property (class, nonnull, nonatomic, readonly) id<SBBBridgeInfoProtocol> bridgeInfo;
/*!
* Get the currently-registered consentManager.
*
* If no consentManager has been registered, this will register a default manager and return that.
*
* @see SBBConsentManagerProtocol
*/
@property (class, nonnull, nonatomic) id<SBBConsentManagerProtocol> consentManager;
/*!
* Get the currently-registered notificationManager.
*
* If no notificationManager has been registered, this will register a default manager and return that.
*
* @see SBBNotificationManagerProtocol
*/
@property (class, nonnull, nonatomic) id<SBBNotificationManagerProtocol> notificationManager;
/*!
* Get the currently-registered OAuthManager.
*
* If no OAuthManager has been registered, this will register a default manager and return that.
*
* @see SBBOAuthManagerProtocol
*/
@property (class, nonnull, nonatomic) id<SBBOAuthManagerProtocol> OAuthManager;
/*!
* Get the currently-registered objectManager.
*
* If no objectManager has been registered, this will register a default manager and return that.
*
* @see SBBObjectManagerProtocol
*/
@property (class, nonnull, nonatomic) id<SBBObjectManagerProtocol> objectManager;
/*!
* Get the currently-registered participantManager.
*
* If no participantManager has been registered, this will register a default manager and return that.
*
* @see SBBParticipantManagerProtocol
*/
@property (class, nonnull, nonatomic) id<SBBParticipantManagerProtocol> participantManager;
/*!
* Get the currently-registered surveyManager.
*
* If no surveyManager has been registered, this will register a default manager and return that.
*
* @see SBBSurveyManagerProtocol
*/
@property (class, nonnull, nonatomic) id<SBBSurveyManagerProtocol> surveyManager;
/*!
* Get the currently-registered studyManager.
*
* If no studyManager has been registered, this will register a default manager and return that.
*
* @see SBBStudyManagerProtocol
*/
@property (class, nonnull, nonatomic) id<SBBStudyManagerProtocol> studyManager;
/*!
* Get the currently-registered uploadManager.
*
* If no uploadManager has been registered, this will register a default manager and return that.
*
* @see SBBUploadManagerProtocol
*/
@property (class, nonnull, nonatomic) id<SBBUploadManagerProtocol> uploadManager;
/*!
* This is a convenience method for setting the auth delegate on the default or currently-registered auth manager.
*
* @unavailable The authDelegate is no longer available. Subscribe to kSBBUserSessionUpdatedNotification notification instead.
*
* @param delegate An object that conforms to SBBAuthManagerDelegateProtocol to serve as the auth delegate for the default or currently-registered auth manager.
*/
+ (void)setAuthDelegate:(nullable id<SBBAuthManagerDelegateProtocol>)delegate __attribute__((unavailable("The authDelegate is no longer available. Subscribe to kSBBUserSessionUpdatedNotification notification instead.")));
/*!
* Set up the Bridge SDK for the given study and pointing at the production environment.
* Usually you would call this at the beginning of your AppDelegate's application:didFinishLaunchingWithOptions: method.
*
* This will register a default SBBNetworkManager instance configured correctly for the specified study and appropriate
* server environment. If you register a custom (or custom-configured) NetworkManager yourself, don't call this method.
*
* Caching is turned off if `cacheDaysAhead = 0` AND `cacheDaysBehind = 0`
*
* @param study A string identifier for your app's Bridge study, assigned to you by Sage Bionetworks.
* @param cacheDaysAhead Number of days ahead to cache.
* @param cacheDaysBehind Number of days behind to cache.
* @deprecated For backward compatibility only. Use setup: or setupWithBridgeInfo: instead.
*/
+ (void)setupWithStudy:(nonnull NSString *)study cacheDaysAhead:(NSInteger)cacheDaysAhead cacheDaysBehind:(NSInteger)cacheDaysBehind __attribute__((deprecated("use setup: or setupWithBridgeInfo: instead")));
/*!
* Convenience method for setting up the study with default caching for days ahead and days behind.
*
* If `useCache` is set to `YES` then this method sets up caching using `SBBDefaultCacheDaysAhead` and
* `SBBDefaultCacheDaysBehind`
*
* @param study A string identifier for your app's Bridge study, assigned to you by Sage Bionetworks.
* @param useCache A flag indicating whether to use the SDK's built-in persistent caching. Pass NO if you want to handle this yourself.
* @deprecated For backward compatibility only. Use setup: or setupWithBridgeInfo: instead.
*/
+ (void)setupWithStudy:(nonnull NSString *)study useCache:(BOOL)useCache __attribute__((deprecated("use setup: or setupWithBridgeInfo: instead")));
/*!
* Convenience method for setting up the study with caching turned off (default).
*
* @param study A string identifier for your app's Bridge study, assigned to you by Sage Bionetworks.
* @deprecated For backward compatibility only. Use setup: or setupWithBridgeInfo: instead.
*/
+ (void)setupWithStudy:(nonnull NSString *)study __attribute__((deprecated("use setup: or setupWithBridgeInfo: instead")));
/*!
* Set up the Bridge SDK for the given study and server environment. Usually you would only call this version
* of the method from test suites, or if you have a non-DEBUG build configuration that you don't want running against
* the production server environment. Otherwise call the version of the setupWithStudy: method that doesn't
* take an environment parameter, and let the SDK use the default environment.
*
* This will register a default SBBNetworkManager instance conigured correctly for the specified environment and study.
* If you register a custom (or custom-configured) NetworkManager yourself, don't call this method.
*
* Caching is turned off if `cacheDaysAhead = 0` AND `cacheDaysBehind = 0`
*
* @param study A string identifier for your app's Bridge study, assigned to you by Sage Bionetworks.
* @param cacheDaysAhead Number of days ahead to cache.
* @param cacheDaysBehind Number of days behind to cache.
* @param environment Which server environment to run against.
* @deprecated For backward compatibility only. Use setup: or setupWithBridgeInfo: instead.
*/
+ (void)setupWithStudy:(nonnull NSString *)study cacheDaysAhead:(NSInteger)cacheDaysAhead cacheDaysBehind:(NSInteger)cacheDaysBehind environment:(SBBEnvironment)environment __attribute__((deprecated("use setup: or setupWithBridgeInfo: instead")));
/*!
* @deprecated For backward compatibility only. Use setup: or setupWithBridgeInfo: instead.
*/
+ (void)setupWithStudy:(nonnull NSString *)study environment:(SBBEnvironment)environment __attribute__((deprecated("use setup: or setupWithBridgeInfo: instead")));
/*!
* @deprecated For backward compatibility only. Use setup: or setupWithBridgeInfo: instead.
*/
+ (void)setupWithStudy:(nonnull NSString *)study useCache:(BOOL)useCache environment:(SBBEnvironment)environment __attribute__((deprecated("use setup: or setupWithBridgeInfo: instead")));
/*!
* @deprecated For backward compatibility only. Use setup: or setupWithBridgeInfo: instead.
*/
+ (void)setupWithAppPrefix:(nonnull NSString *)appPrefix __attribute__((deprecated("use setup: or setupWithBridgeInfo: instead")));
/*!
* @deprecated For backward compatibility only. Use setup: or setupWithBridgeInfo: instead.
*/
+ (void)setupWithAppPrefix:(nonnull NSString *)appPrefix environment:(SBBEnvironment)environment __attribute__((deprecated("use setup: or setupWithBridgeInfo: instead")));
@end
#ifdef __cplusplus
}
#endif