Skip to content

Commit

Permalink
Add support to TWA (#747)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomferreira authored Sep 6, 2023
1 parent a01c5e1 commit 58c2e26
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion android/src/main/java/com/rnappauth/RNAppAuthModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import androidx.browser.customtabs.CustomTabsClient;
import androidx.browser.customtabs.CustomTabsServiceConnection;
import androidx.browser.customtabs.CustomTabsSession;
import androidx.browser.customtabs.CustomTabsIntent;
import androidx.browser.customtabs.TrustedWebUtils;

import com.facebook.react.bridge.ActivityEventListener;
import com.facebook.react.bridge.ReactApplicationContext;
Expand Down Expand Up @@ -712,7 +714,12 @@ private void authorizeWithConfiguration(

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
AuthorizationService authService = new AuthorizationService(context, appAuthConfiguration);
Intent authIntent = authService.getAuthorizationRequestIntent(authRequest);

CustomTabsIntent.Builder intentBuilder = authService.createCustomTabsIntentBuilder();
CustomTabsIntent customTabsIntent = intentBuilder.build();
customTabsIntent.intent.putExtra(TrustedWebUtils.EXTRA_LAUNCH_AS_TRUSTED_WEB_ACTIVITY, true);

Intent authIntent = authService.getAuthorizationRequestIntent(authRequest, customTabsIntent);

currentActivity.startActivityForResult(authIntent, 52);
} else {
Expand Down

0 comments on commit 58c2e26

Please sign in to comment.