@@ -23,7 +23,6 @@ import com.schibsted.account.webflows.util.Either
23
23
import com.schibsted.account.webflows.util.Either.Left
24
24
import com.schibsted.account.webflows.util.Either.Right
25
25
import com.schibsted.account.webflows.util.Util
26
- import com.schibsted.account.webflows.util.Util.isCustomTabsSupported
27
26
import okhttp3.HttpUrl.Companion.toHttpUrl
28
27
import okhttp3.OkHttpClient
29
28
import org.json.JSONException
@@ -96,7 +95,7 @@ class Client {
96
95
@JvmOverloads
97
96
fun getAuthenticationIntent (context : Context , authRequest : AuthRequest = AuthRequest ()): Intent {
98
97
val loginUrl = generateLoginUrl(authRequest)
99
- val intent: Intent = if (isCustomTabsSupported(context)) {
98
+ val intent: Intent = if (this . isCustomTabsSupported(context)) {
100
99
buildCustomTabsIntent()
101
100
.apply {
102
101
intent.data = loginUrl
@@ -115,7 +114,7 @@ class Client {
115
114
@JvmOverloads
116
115
fun launchAuth (context : Context , authRequest : AuthRequest = AuthRequest ()) {
117
116
val loginUrl = generateLoginUrl(authRequest)
118
- if (isCustomTabsSupported(context)) {
117
+ if (this . isCustomTabsSupported(context)) {
119
118
buildCustomTabsIntent().launchUrl(context, loginUrl)
120
119
} else {
121
120
val intent = Intent (Intent .ACTION_VIEW , loginUrl).addCategory(Intent .CATEGORY_BROWSABLE )
@@ -134,6 +133,13 @@ class Client {
134
133
return Uri .parse(loginUrl)
135
134
}
136
135
136
+ private fun isCustomTabsSupported (context : Context ): Boolean {
137
+ val serviceIntent = Intent (CustomTabsService .ACTION_CUSTOM_TABS_CONNECTION )
138
+ val resolveInfos = context.packageManager.queryIntentServices(serviceIntent, 0 )
139
+
140
+ return ! resolveInfos.isEmpty()
141
+ }
142
+
137
143
/* *
138
144
* Call this with the intent received via deep link to complete the login flow.
139
145
*
0 commit comments