4646#import " LPAppIconManager.h"
4747#import " LPUIEditorWrapper.h"
4848#import " LPRequestFactory.h"
49+ #import " LPRequestManager.h"
50+ #import " LPAPIConfig.h"
4951
5052static NSString *leanplum_deviceId = nil ;
5153static NSString *registrationEmail = nil ;
@@ -255,7 +257,8 @@ + (void)setAppId:(NSString *)appId withDevelopmentKey:(NSString *)accessKey
255257
256258 LP_TRY
257259 [LPConstantsState sharedState ].isDevelopmentModeEnabled = YES ;
258- [LeanplumRequest setAppId: appId withAccessKey: accessKey];
260+ [[LPAPIConfig sharedConfig ] setAppId: appId withAccessKey: accessKey];
261+ [LeanplumRequest initializeStaticVars ];
259262 LP_END_TRY
260263}
261264
@@ -280,7 +283,8 @@ + (void)setAppId:(NSString *)appId withProductionKey:(NSString *)accessKey
280283
281284 LP_TRY
282285 [LPConstantsState sharedState ].isDevelopmentModeEnabled = NO ;
283- [LeanplumRequest setAppId: appId withAccessKey: accessKey];
286+ [[LPAPIConfig sharedConfig ] setAppId: appId withAccessKey: accessKey];
287+ [LeanplumRequest initializeStaticVars ];
284288 LP_END_TRY
285289}
286290
@@ -374,7 +378,7 @@ + (void)synchronizeDefaults
374378+ (NSString *)pushTokenKey
375379{
376380 return [NSString stringWithFormat: LEANPLUM_DEFAULTS_PUSH_TOKEN_KEY,
377- LeanplumRequest .appId, LeanplumRequest .userId, LeanplumRequest .deviceId];
381+ [LPAPIConfig sharedConfig ] .appId, [LPAPIConfig sharedConfig ] .userId, [LPAPIConfig sharedConfig ] .deviceId];
378382}
379383
380384+ (void )start
@@ -669,7 +673,7 @@ + (void)startWithUserId:(NSString *)userId
669673 userAttributes : (NSDictionary *)attributes
670674 responseHandler : (LeanplumStartBlock)startResponse
671675{
672- if ([LeanplumRequest appId ] == nil ) {
676+ if ([LPAPIConfig sharedConfig ]. appId == nil ) {
673677 [self throwError: @" Please provide your app ID using one of the [Leanplum setAppId:] "
674678 @" methods." ];
675679 return ;
@@ -732,7 +736,7 @@ + (void)startWithUserId:(NSString *)userId
732736 });
733737 state.actionManager = [LPActionManager sharedManager ];
734738
735- [LeanplumRequest loadToken ];
739+ [[LPAPIConfig sharedConfig ] loadToken ];
736740 [[LPVarCache sharedCache ] setSilent: YES ];
737741 [[LPVarCache sharedCache ] loadDiffs ];
738742 [[LPVarCache sharedCache ] setSilent: NO ];
@@ -757,7 +761,7 @@ + (void)startWithUserId:(NSString *)userId
757761 }];
758762
759763 // Set device ID.
760- NSString *deviceId = [LeanplumRequest deviceId ] ;
764+ NSString *deviceId = [LPAPIConfig sharedConfig ]. deviceId ;
761765 // This is the device ID set when the MAC address is used on iOS 7.
762766 // This is to allow apps who upgrade to the new ID to forget the old one.
763767 if ([deviceId isEqualToString: @" 0f607264fc6318a92b9e13c65db7cd3c" ]) {
@@ -776,17 +780,17 @@ + (void)startWithUserId:(NSString *)userId
776780 if (!deviceId) {
777781 deviceId = [[UIDevice currentDevice ] leanplum_uniqueGlobalDeviceIdentifier ];
778782 }
779- [LeanplumRequest setDeviceId: deviceId];
783+ [[LPAPIConfig sharedConfig ] setDeviceId: deviceId];
780784 }
781785
782786 // Set user ID.
783787 if (!userId) {
784- userId = [LeanplumRequest userId ] ;
788+ userId = [LPAPIConfig sharedConfig ]. userId ;
785789 if (!userId) {
786- userId = [LeanplumRequest deviceId ] ;
790+ userId = [LPAPIConfig sharedConfig ]. deviceId ;
787791 }
788792 }
789- [LeanplumRequest setUserId: userId];
793+ [[LPAPIConfig sharedConfig ] setUserId: userId];
790794
791795 // Setup parameters.
792796 NSString *versionName = [LPInternalState sharedState ].appVersion ;
@@ -875,8 +879,8 @@ + (void)startWithUserId:(NSString *)userId
875879 NSDictionary *variantDebugInfo = [self parseVariantDebugInfoFromResponse: response];
876880 [[LPVarCache sharedCache ] setVariantDebugInfo: variantDebugInfo];
877881
878- [LeanplumRequest setToken: token];
879- [LeanplumRequest saveToken ];
882+ [[LPAPIConfig sharedConfig ] setToken: token];
883+ [[LPAPIConfig sharedConfig ] saveToken ];
880884 [[LPVarCache sharedCache ] applyVariableDiffs: values
881885 messages: messages
882886 updateRules: updateRules
@@ -930,8 +934,8 @@ + (void)startWithUserId:(NSString *)userId
930934 [[LPVarCache sharedCache ] setDevModeValuesFromServer: valuesFromCode
931935 fileAttributes: fileAttributes
932936 actionDefinitions: actionDefinitions];
933- [[LeanplumSocket sharedSocket ] connectToAppId: LeanplumRequest .appId
934- deviceId: LeanplumRequest .deviceId];
937+ [[LeanplumSocket sharedSocket ] connectToAppId: [LPAPIConfig sharedConfig ] .appId
938+ deviceId: [LPAPIConfig sharedConfig ] .deviceId];
935939 if ([response[LP_KEY_IS_REGISTERED] boolValue ]) {
936940 [Leanplum onHasStartedAndRegisteredAsDeveloper ];
937941 }
@@ -2044,7 +2048,7 @@ + (void)setUserIdInternal:(NSString *)userId withAttributes:(NSDictionary *)attr
20442048 [req send ];
20452049
20462050 if (userId.length ) {
2047- [LeanplumRequest setUserId: userId];
2051+ [[LPAPIConfig sharedConfig ] setUserId: userId];
20482052 if ([LPInternalState sharedState ].hasStarted ) {
20492053 [[LPVarCache sharedCache ] saveDiffs ];
20502054 }
@@ -2441,7 +2445,7 @@ + (NSString *)deviceId
24412445 [self throwError: @" [Leanplum start] must be called before calling deviceId" ];
24422446 return nil ;
24432447 }
2444- return [LeanplumRequest deviceId ] ;
2448+ return [LPAPIConfig sharedConfig ]. deviceId ;
24452449 LP_END_TRY
24462450 return nil ;
24472451}
@@ -2453,7 +2457,7 @@ + (NSString *)userId
24532457 [self throwError: @" [Leanplum start] must be called before calling userId" ];
24542458 return nil ;
24552459 }
2456- return [LeanplumRequest userId ] ;
2460+ return [LPAPIConfig sharedConfig ]. userId ;
24572461 LP_END_TRY
24582462 return nil ;
24592463}
0 commit comments