12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
- #import " Crashlytics/Crashlytics/Settings/FIRCLSSettingsOnboardingManager .h"
15
+ #import " Crashlytics/Crashlytics/Settings/FIRCLSSettingsManager .h"
16
16
17
17
#import " Crashlytics/Crashlytics/DataCollection/FIRCLSDataCollectionToken.h"
18
18
#import " Crashlytics/Crashlytics/Helpers/FIRCLSDefines.h"
22
22
#import " Crashlytics/Crashlytics/Models/FIRCLSSettings.h"
23
23
#import " Crashlytics/Crashlytics/Settings/Models/FIRCLSApplicationIdentifierModel.h"
24
24
#import " Crashlytics/Crashlytics/Settings/Operations/FIRCLSDownloadAndSaveSettingsOperation.h"
25
- #import " Crashlytics/Crashlytics/Settings/Operations/FIRCLSOnboardingOperation.h"
26
25
#import " Crashlytics/Shared/FIRCLSConstants.h"
27
26
#import " Crashlytics/Shared/FIRCLSNetworking/FIRCLSFABNetworkClient.h"
28
27
#import " Crashlytics/Shared/FIRCLSNetworking/FIRCLSURLBuilder.h"
29
28
30
- @interface FIRCLSSettingsOnboardingManager () <FIRCLSDownloadAndSaveSettingsOperationDelegate,
31
- FIRCLSOnboardingOperationDelegate>
29
+ @interface FIRCLSSettingsManager () <FIRCLSDownloadAndSaveSettingsOperationDelegate>
32
30
33
31
@property (nonatomic , strong ) FIRCLSApplicationIdentifierModel *appIDModel;
34
32
@property (nonatomic , strong ) FIRCLSInstallIdentifierModel *installIDModel;
35
33
36
34
@property (nonatomic , strong ) FIRCLSSettings *settings;
37
35
38
- @property (nonatomic , nullable , strong ) FIRCLSOnboardingOperation *onboardingOperation;
39
36
@property (nonatomic , strong ) FIRCLSFileManager *fileManager;
40
37
41
- // set to YES once onboarding call has been made.
42
- @property (nonatomic ) BOOL hasAttemptedAppConfigure;
43
-
44
38
@property (nonatomic ) NSDictionary *configuration;
45
39
@property (nonatomic ) NSDictionary *defaultConfiguration;
46
40
@property (nonatomic , copy ) NSString *googleAppID;
@@ -49,7 +43,7 @@ @interface FIRCLSSettingsOnboardingManager () <FIRCLSDownloadAndSaveSettingsOper
49
43
50
44
@end
51
45
52
- @implementation FIRCLSSettingsOnboardingManager
46
+ @implementation FIRCLSSettingsManager
53
47
54
48
- (instancetype )initWithAppIDModel : (FIRCLSApplicationIdentifierModel *)appIDModel
55
49
installIDModel : (FIRCLSInstallIdentifierModel *)installIDModel
@@ -72,9 +66,9 @@ - (instancetype)initWithAppIDModel:(FIRCLSApplicationIdentifierModel *)appIDMode
72
66
return self;
73
67
}
74
68
75
- - (void )beginSettingsAndOnboardingWithGoogleAppId : (NSString *)googleAppID
76
- token : (FIRCLSDataCollectionToken *)token
77
- waitForCompletion : (BOOL )waitForCompletion {
69
+ - (void )beginSettingsWithGoogleAppId : (NSString *)googleAppID
70
+ token : (FIRCLSDataCollectionToken *)token
71
+ waitForCompletion : (BOOL )waitForCompletion {
78
72
NSParameterAssert (googleAppID);
79
73
80
74
self.googleAppID = googleAppID;
@@ -93,10 +87,8 @@ - (void)beginSettingsAndOnboardingWithGoogleAppId:(NSString *)googleAppID
93
87
#pragma mark Helper methods
94
88
95
89
/* *
96
- * Makes a settings download request. If the request fails, the error is handled silently(with a log
97
- * statement). If the server response indicates onboarding is needed, an onboarding request is sent
98
- * to the server. If the onboarding request fails, the error is handled silently(with a log
99
- * statement).
90
+ * Makes a settings download request. If the request fails, the error is handled silently (with a
91
+ * log statement).
100
92
*/
101
93
- (void )beginSettingsDownload : (FIRCLSDataCollectionToken *)token
102
94
waitForCompletion : (BOOL )waitForCompletion {
@@ -126,56 +118,10 @@ - (void)beginSettingsDownload:(FIRCLSDataCollectionToken *)token
126
118
}
127
119
}
128
120
129
- - (void )beginOnboarding : (BOOL )appCreate
130
- endpointString : (NSString *)endpoint
131
- token : (FIRCLSDataCollectionToken *)token {
132
- [self .onboardingOperation cancel ];
133
-
134
- self.onboardingOperation =
135
- [[FIRCLSOnboardingOperation alloc ] initWithDelegate: self
136
- shouldCreate: appCreate
137
- googleAppID: self .googleAppID
138
- kitVersionsByKitBundleIdentifier: self .kitVersionsByKitBundleIdentifier
139
- appIdentifierModel: self .appIDModel
140
- endpointString: endpoint
141
- networkClient: self .networkClient
142
- token: token
143
- settings: self .settings];
144
-
145
- [self .onboardingOperation startWithToken: token];
146
- }
147
-
148
121
- (void )finishNetworkingSession {
149
122
[self .networkClient invalidateAndCancel ];
150
123
}
151
124
152
- #pragma mark FIRCLSOnboardingOperationDelegate methods
153
-
154
- - (void )onboardingOperation : (FIRCLSOnboardingOperation *)operation
155
- didCompleteAppCreationWithError : (nullable NSError *)error {
156
- if (error) {
157
- FIRCLSErrorLog (@" Unable to complete application configure: %@ " , error);
158
- [self finishNetworkingSession ];
159
- return ;
160
- }
161
- self.onboardingOperation = nil ;
162
- FIRCLSDebugLog (@" Completed configure" );
163
-
164
- // now, go get settings, as they can change (and it completes the onboarding process)
165
- [self beginSettingsDownload: operation.token waitForCompletion: NO ];
166
- }
167
-
168
- - (void )onboardingOperation : (FIRCLSOnboardingOperation *)operation
169
- didCompleteAppUpdateWithError : (nullable NSError *)error {
170
- [self finishNetworkingSession ];
171
- if (error) {
172
- FIRCLSErrorLog (@" Unable to complete application update: %@ " , error);
173
- return ;
174
- }
175
- self.onboardingOperation = nil ;
176
- FIRCLSDebugLog (@" Completed application update" );
177
- }
178
-
179
125
#pragma mark FIRCLSDownloadAndSaveSettingsOperationDelegate methods
180
126
181
127
- (void )operation : (FIRCLSDownloadAndSaveSettingsOperation *)operation
@@ -199,32 +145,6 @@ - (void)operation:(FIRCLSDownloadAndSaveSettingsOperation *)operation
199
145
NSTimeInterval currentTimestamp = [NSDate timeIntervalSinceReferenceDate ];
200
146
[self .settings cacheSettingsWithGoogleAppID: self .googleAppID currentTimestamp: currentTimestamp];
201
147
202
- // only try this once
203
- if (self.hasAttemptedAppConfigure ) {
204
- FIRCLSDebugLog (@" App already onboarded in this run of the app" );
205
- [self finishNetworkingSession ];
206
- return ;
207
- }
208
-
209
- // Onboarding is still needed in Firebase, here are the backend app states -
210
- // 1. When the app is created in the Firebase console, app state: built (client settings call
211
- // returns app status: new)
212
- // 2. After onboarding call is made, app state: build_configured
213
- // 3. Another settings call is triggered after onboarding, app state: activated
214
- if ([self .settings appNeedsOnboarding ]) {
215
- FIRCLSDebugLog (@" Starting onboarding with app create" );
216
- self.hasAttemptedAppConfigure = YES ;
217
- [self beginOnboarding: YES endpointString: FIRCLSConfigureEndpoint token: operation.token];
218
- return ;
219
- }
220
-
221
- if ([self .settings appUpdateRequired ]) {
222
- FIRCLSDebugLog (@" Starting onboarding with app update" );
223
- self.hasAttemptedAppConfigure = YES ;
224
- [self beginOnboarding: NO endpointString: FIRCLSConfigureEndpoint token: operation.token];
225
- return ;
226
- }
227
-
228
148
// we're all set!
229
149
[self finishNetworkingSession ];
230
150
}
0 commit comments