Skip to content

Commit 20b609f

Browse files
committed
New feature flag for welcome discovery (WD)
1 parent d42772e commit 20b609f

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

libs/SalesforceSDK/src/com/salesforce/androidsdk/app/Features.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@ public class Features {
4444
public static final String FEATURE_BIOMETRIC_AUTH = "BA";
4545
public static final String FEATURE_NATIVE_LOGIN = "NL";
4646
public static final String FEATURE_QR_CODE_LOGIN = "QR";
47+
public static final String FEATURE_WELCOME_DISCOVERY_LOGIN = "WD";
4748
}

libs/SalesforceSDK/src/com/salesforce/androidsdk/ui/LoginActivity.kt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ import com.salesforce.androidsdk.R.string.sf__ssl_unknown_error
125125
import com.salesforce.androidsdk.R.string.sf__ssl_untrusted
126126
import com.salesforce.androidsdk.accounts.UserAccount
127127
import com.salesforce.androidsdk.app.Features.FEATURE_QR_CODE_LOGIN
128+
import com.salesforce.androidsdk.app.Features.FEATURE_WELCOME_DISCOVERY_LOGIN
128129
import com.salesforce.androidsdk.app.SalesforceSDKManager
129130
import com.salesforce.androidsdk.app.SalesforceSDKManager.Theme.DARK
130131
import com.salesforce.androidsdk.auth.HttpAccess
@@ -901,6 +902,20 @@ open class LoginActivity : FragmentActivity() {
901902
*/
902903
private fun applySalesforceWelcomeDiscoveryIntent(intent: Intent) {
903904

905+
// Set welcome discovery feature flag if applicable
906+
if (isLoginWithWelcomeDiscovery(intent)) {
907+
SalesforceSDKManager.getInstance()
908+
.registerUsedAppFeature(FEATURE_WELCOME_DISCOVERY_LOGIN);
909+
}
910+
else {
911+
SalesforceSDKManager.getInstance().unregisterUsedAppFeature(
912+
FEATURE_WELCOME_DISCOVERY_LOGIN
913+
);
914+
}
915+
916+
// Re-apply user agent to WebView
917+
webView.settings.userAgentString = SalesforceSDKManager.getInstance().userAgent
918+
904919
// Apply the intent extras' Salesforce Welcome Login hint and host for use in the OAuth authorize URL, if applicable.
905920
applySalesforceWelcomeLoginHintAndHost(intent)
906921

@@ -929,6 +944,19 @@ open class LoginActivity : FragmentActivity() {
929944
}
930945
}
931946

947+
/**
948+
* Returns true if intent is for a login with Welcome discovery
949+
* - either because the the login url is Welcome discovery (part 1 of the flow)
950+
* - there is a login hint (part 2 of the flow)
951+
*
952+
* @return true when the intent is for a login with Welcome discovery
953+
*/
954+
private fun isLoginWithWelcomeDiscovery(intent: Intent): Boolean {
955+
val isWelcomeDiscoveryUrl = intent.data?.let { isSalesforceWelcomeDiscoveryMobileUrl(it) } == true
956+
val hasLoginHint = intent.getStringExtra(EXTRA_KEY_LOGIN_HINT) != null
957+
return isWelcomeDiscoveryUrl || hasLoginHint
958+
}
959+
932960
/**
933961
* Creates a Salesforce Welcome Discovery mobile URL using the provided
934962
* Salesforce Welcome Discovery host and path URL.

0 commit comments

Comments
 (0)