Skip to content

Commit 02a84ba

Browse files
authored
Merge pull request #153 from immutable/fix/custom-tabs-dismiss-before-redirect
[DX-2600] fix: custom tabs dismiss callback triggered before redirect
2 parents 58aee25 + ecbfeea commit 02a84ba

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,5 @@ src/Packages/Passport/Runtime/Assets/ImmutableAndroid.androidlib/**/*.meta
8787

8888
# WebView.bundle
8989
src/Packages/Passport/Runtime/ThirdParty/Gree/Assets/Plugins/WebView.bundle/**/*.meta
90+
91+
*.idea

src/Packages/Passport/Runtime/Assets/ImmutableAndroid.androidlib/src/main/java/com/immutable/unity/ImmutableActivity.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import android.net.Uri;
77
import android.os.Build;
88
import android.os.Bundle;
9+
import android.os.Handler;
10+
import android.os.Looper;
911

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

0 commit comments

Comments
 (0)