Skip to content

Commit

Permalink
Merge pull request #153 from immutable/fix/custom-tabs-dismiss-before…
Browse files Browse the repository at this point in the history
…-redirect

[DX-2600] fix: custom tabs dismiss callback triggered before redirect
  • Loading branch information
nattb8 authored Jan 22, 2024
2 parents 58aee25 + ecbfeea commit 02a84ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,5 @@ src/Packages/Passport/Runtime/Assets/ImmutableAndroid.androidlib/**/*.meta

# WebView.bundle
src/Packages/Passport/Runtime/ThirdParty/Gree/Assets/Plugins/WebView.bundle/**/*.meta

*.idea
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -95,7 +97,17 @@ private void launchCustomTabs() {
@Override
public void onNavigationEvent(int navigationEvent, @Nullable Bundle extras) {
if (navigationEvent == CustomTabsCallback.TAB_HIDDEN && callbackInstance != null) {
callbackInstance.onCustomTabsDismissed(uri.toString());
// Adding some delay before calling onCustomTabsDismissed as sometimes this gets called
// before the PKCE deeplink is triggered (by 100ms). This means pkceCompletionSource will be
// set to null before the SDK can use it to notify the consumer of the PKCE result.
// See PassportImpl.OnLoginPKCEDismissed and PassportImpl.OnDeepLinkActivated
final Handler handler = new Handler(Looper.getMainLooper());
handler.postDelayed(new Runnable() {
@Override
public void run() {
callbackInstance.onCustomTabsDismissed(uri.toString());
}
}, 1000);
}
}
});
Expand Down

0 comments on commit 02a84ba

Please sign in to comment.