-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[sign_in_with_apple] Handle cancellation of chrome custom tab #88
[sign_in_with_apple] Handle cancellation of chrome custom tab #88
Conversation
if (requestCode == CUSTOM_TABS_REQUEST_CODE) { | ||
val _lastAuthorizationRequestResult = lastAuthorizationRequestResult | ||
|
||
if (_lastAuthorizationRequestResult != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this works from my testing on the simulator, I'm a bit worried about introducing a race condition here.
But maybe this activity result callback is only triggered after the deeplink is handled, e.g. triggering the main activity to hide the Custom Tab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, true, we don't want this to be triggered on "automatic" closes.
Have you looked into the resultCode
value? Is that any help?
Else I would hope there is some overall API docs on this that explains the order of method invocation.
I don't think SignInWithAppleCallback.onCreate
leaves any room for races here, as we explicitly first send the data to Flutter and null
the authorization result, and only then call triggerMainActivityToHideChromeCustomTab
, which causes the tab to close.
I checked the resultCode
and it was 0
(https://developer.android.com/reference/android/app/Activity#RESULT_CANCELED) both when manually closing as well as when it's triggered by this plugin.
…h-apple/handle-cancellation-of-chrome-custom-tab
Codecov Report
@@ Coverage Diff @@
## master #88 +/- ##
==========================================
- Coverage 62.34% 62.04% -0.31%
==========================================
Files 13 13
Lines 409 411 +2
==========================================
Hits 255 255
- Misses 154 156 +2
Continue to review full report at Codecov.
|
val notificationIntent = _activity.getPackageManager().getLaunchIntentForPackage(_activity.getPackageName()); | ||
lastAuthorizationRequestResult = result | ||
triggerMainActivityToHideChromeCustomTab = { | ||
val notificationIntent = _activity.packageManager.getLaunchIntentForPackage(_activity.packageName); | ||
notificationIntent.setPackage(null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
notificationIntent.setPackage(null) | |
notificationIntent.package = null |
Is this also an option then?
if (requestCode == CUSTOM_TABS_REQUEST_CODE) { | ||
val _lastAuthorizationRequestResult = lastAuthorizationRequestResult | ||
|
||
if (_lastAuthorizationRequestResult != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, true, we don't want this to be triggered on "automatic" closes.
Have you looked into the resultCode
value? Is that any help?
Else I would hope there is some overall API docs on this that explains the order of method invocation.
I don't think SignInWithAppleCallback.onCreate
leaves any room for races here, as we explicitly first send the data to Flutter and null
the authorization result, and only then call triggerMainActivityToHideChromeCustomTab
, which causes the tab to close.
I checked the resultCode
and it was 0
(https://developer.android.com/reference/android/app/Activity#RESULT_CANCELED) both when manually closing as well as when it's triggered by this plugin.
No description provided.