Skip to content

Commit e190b48

Browse files
Merge pull request #692 from BranchMetrics/Staging
Merge Staging to Master for release v3.1.1
2 parents e8fa5f4 + 1139269 commit e190b48

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

Branch-SDK/src/io/branch/referral/Branch.java

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,10 @@ private enum INTENT_STATE {
338338
PENDING,
339339
READY
340340
}
341-
341+
342+
// INTENG-4676 Save the last callback
343+
private WeakReference<BranchReferralInitListener> deferredInitListener_;
344+
342345
private INTENT_STATE intentState_ = INTENT_STATE.PENDING;
343346
private boolean handleDelayedNewIntents_ = false;
344347

@@ -350,7 +353,7 @@ private enum INTENT_STATE {
350353

351354
/* The current activity instance for the application.*/
352355
WeakReference<Activity> currentActivityReference_;
353-
356+
354357
/* Specifies the choice of user for isReferrable setting. used to determine the link click is referrable or not. See getAutoSession for usage */
355358
private enum CUSTOM_REFERRABLE_SETTINGS {
356359
USE_DEFAULT, REFERRABLE, NON_REFERRABLE
@@ -1338,6 +1341,9 @@ private void initUserSessionInternal(BranchReferralInitListener callback, Activi
13381341
if (activity != null) {
13391342
currentActivityReference_ = new WeakReference<>(activity);
13401343
}
1344+
if (callback != null) {
1345+
deferredInitListener_ = new WeakReference<BranchReferralInitListener>(callback);
1346+
}
13411347
//If already initialised
13421348
if ((hasUser() && hasSession() && initState_ == SESSION_STATE.INITIALISED)) {
13431349
reportInitSession(callback);
@@ -2720,8 +2726,12 @@ private void startSession(Activity activity) {
27202726
if (activity.getIntent() != null) {
27212727
intentData = activity.getIntent().getData();
27222728
}
2729+
BranchReferralInitListener deferredCallback = null;
2730+
if (deferredInitListener_ != null) {
2731+
deferredCallback = deferredInitListener_.get();
2732+
}
27232733
isInitReportedThroughCallBack = false;
2724-
initSessionWithData(intentData, activity); // indicate starting of session.
2734+
initSession(deferredCallback, intentData, activity); // indicate starting of session.
27252735
}
27262736

27272737
/*
@@ -2738,12 +2748,17 @@ private boolean checkIntentForSessionRestart(Intent intent) {
27382748
boolean isRestartSessionRequested = false;
27392749
if (intent != null) {
27402750
try {
2741-
isRestartSessionRequested = intent.getBooleanExtra(Defines.Jsonkey.ForceNewBranchSession.getKey(), false);
2742-
} catch (Throwable ignore) {
2743-
}
2744-
if (isRestartSessionRequested) {
2745-
intent.putExtra(Defines.Jsonkey.ForceNewBranchSession.getKey(), false);
2746-
}
2751+
// Force new session parameters
2752+
if (intent.getBooleanExtra(Defines.Jsonkey.ForceNewBranchSession.getKey(), false)) {
2753+
isRestartSessionRequested = true;
2754+
intent.putExtra(Defines.Jsonkey.ForceNewBranchSession.getKey(), false);
2755+
// Also check if there is a new, unconsumed push notification intent which would indicate it's coming
2756+
// from foreground
2757+
} else if (intent.getStringExtra(Defines.Jsonkey.AndroidPushNotificationKey.getKey()) != null &&
2758+
!intent.getBooleanExtra(Defines.Jsonkey.BranchLinkUsed.getKey(), false)) {
2759+
isRestartSessionRequested = true;
2760+
}
2761+
} catch (Throwable ignore) { }
27472762
}
27482763
return isRestartSessionRequested;
27492764
}

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Branch Android SDK change log
2+
- v3.1.1
3+
* Added support for push notifications while the application is in the foreground
4+
25
- v3.1.0
36
* Fixed a synchronization issue around the event queue saving preferences while in a synchronized block.
47
* Added new standard events for parity with Tune.

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
VERSION_NAME=3.1.0
2-
VERSION_CODE=030100
1+
VERSION_NAME=3.1.1
2+
VERSION_CODE=030101
33
GROUP=io.branch.sdk.android
44

55
POM_DESCRIPTION=Use the Branch SDK (branch.io) to create and power the links that point back to your apps for all of these things and more. Branch makes it incredibly simple to create powerful deep links that can pass data across app install and open while handling all edge cases (using on desktop vs. mobile vs. already having the app installed, etc). Best of all, it is really simple to start using the links for your own app: only 2 lines of code to register the deep link router and one more line of code to create the links with custom data.

0 commit comments

Comments
 (0)