Skip to content

Commit 3259da3

Browse files
committed
Revert lifecycle change in 0.12.18
1 parent 2d96159 commit 3259da3

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Branch-SDK/Branch-SDK/Branch.m

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ @interface Branch() <BranchDeepLinkingControllerCompletionDelegate, FABKit>
7373

7474
@property (strong, nonatomic) BNCServerInterface *bServerInterface;
7575
@property (strong, nonatomic) BNCServerRequestQueue *requestQueue;
76+
@property (strong, nonatomic) NSTimer *sessionTimer;
7677
@property (strong, nonatomic) dispatch_semaphore_t processing_sema;
7778
@property (copy, nonatomic) callbackWithParams sessionInitWithParamsCallback;
7879
@property (copy, nonatomic) callbackWithBranchUniversalObject sessionInitWithBranchUniversalObjectCallback;
@@ -93,7 +94,6 @@ @interface Branch() <BranchDeepLinkingControllerCompletionDelegate, FABKit>
9394
@property (assign, nonatomic) BOOL delayForAppleAds;
9495
@property (assign, nonatomic) BOOL searchAdsDebugMode;
9596
@property (strong, nonatomic) NSMutableArray *whiteListedSchemeList;
96-
@property (assign, nonatomic) BOOL appIsInBackground;
9797
@end
9898

9999
@implementation Branch
@@ -1164,15 +1164,15 @@ - (void)registerViewWithParams:(NSDictionary *)params andCallback:(callbackWithP
11641164
#pragma mark - Application State Change methods
11651165

11661166
- (void)applicationDidBecomeActive {
1167-
self.appIsInBackground = NO;
1167+
[self clearTimer];
11681168
if (!self.isInitialized && !self.preferenceHelper.shouldWaitForInit && ![self.requestQueue containsInstallOrOpen]) {
11691169
[self initUserSessionAndCallCallback:YES];
11701170
}
11711171
}
11721172

11731173
- (void)applicationWillResignActive {
1174-
self.appIsInBackground = YES;
1175-
[self callClose];
1174+
[self clearTimer];
1175+
self.sessionTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(callClose) userInfo:nil repeats:NO];
11761176
[self.requestQueue persistImmediately];
11771177
}
11781178

@@ -1194,6 +1194,9 @@ - (void)callClose {
11941194
}
11951195
}
11961196

1197+
- (void)clearTimer {
1198+
[self.sessionTimer invalidate];
1199+
}
11971200

11981201
#pragma mark - Queue management
11991202

@@ -1264,6 +1267,10 @@ - (void)processNextQueueItem {
12641267
[req processResponse:nil error:[NSError errorWithDomain:BNCErrorDomain code:BNCInitError userInfo:@{ NSLocalizedDescriptionKey: @"Branch User Session has not been initialized" }]];
12651268
return;
12661269
}
1270+
1271+
if (![req isKindOfClass:[BranchCloseRequest class]]) {
1272+
[self clearTimer];
1273+
}
12671274

12681275
[req makeRequest:self.bServerInterface key:self.branchKey callback:callback];
12691276
}
@@ -1339,8 +1346,7 @@ - (void)registerInstallOrOpen:(Class)clazz {
13391346
}
13401347

13411348
- (void)handleInitSuccess {
1342-
if (!self.appIsInBackground)
1343-
self.isInitialized = YES;
1349+
self.isInitialized = YES;
13441350

13451351
NSDictionary *latestReferringParams = [self getLatestReferringParams];
13461352
if (self.shouldCallSessionInitCallback) {

0 commit comments

Comments
 (0)