Skip to content

Commit 58c2e26

Browse files
authored
Add support to TWA (#747)
1 parent a01c5e1 commit 58c2e26

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

android/src/main/java/com/rnappauth/RNAppAuthModule.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import androidx.browser.customtabs.CustomTabsClient;
1414
import androidx.browser.customtabs.CustomTabsServiceConnection;
1515
import androidx.browser.customtabs.CustomTabsSession;
16+
import androidx.browser.customtabs.CustomTabsIntent;
17+
import androidx.browser.customtabs.TrustedWebUtils;
1618

1719
import com.facebook.react.bridge.ActivityEventListener;
1820
import com.facebook.react.bridge.ReactApplicationContext;
@@ -712,7 +714,12 @@ private void authorizeWithConfiguration(
712714

713715
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
714716
AuthorizationService authService = new AuthorizationService(context, appAuthConfiguration);
715-
Intent authIntent = authService.getAuthorizationRequestIntent(authRequest);
717+
718+
CustomTabsIntent.Builder intentBuilder = authService.createCustomTabsIntentBuilder();
719+
CustomTabsIntent customTabsIntent = intentBuilder.build();
720+
customTabsIntent.intent.putExtra(TrustedWebUtils.EXTRA_LAUNCH_AS_TRUSTED_WEB_ACTIVITY, true);
721+
722+
Intent authIntent = authService.getAuthorizationRequestIntent(authRequest, customTabsIntent);
716723

717724
currentActivity.startActivityForResult(authIntent, 52);
718725
} else {

0 commit comments

Comments
 (0)