mirror of
https://github.com/OAuthSwift/OAuthSwift.git
synced 2026-04-27 05:05:51 +03:00
[GH-ISSUE #199] How to handle the user tapping Done on the SafariURLHandler? #117
Labels
No labels
bug
cocoapod
duplicate
enhancement
feature-request
help wanted
help wanted
invalid
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/OAuthSwift#117
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @dbmrq on GitHub (Feb 26, 2016).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/199
I'm using SafariURLHandler and then I do
authorizeWithCallbackURL… onsuccessI show an alert saying the authorization succeeded and onfailureI show an alert saying the authorization failed. But there is still the possibility that the user will tap "Done" without either authorizing or denying my app.Then I guess I should still present the failure alert, but neither the
successnor thefailureclosures get called in that case.Another possibility would be to check if I got the token and, if I didn't, present the alert, but
authorizeWithCallbackURLis an asynchronous function, so the alert would be presented before it's done.I could also wait for the function to return, but it seems it just doesn't return in that case.
So for now it looks like my only option is to wait an arbitrary amount of time and then decide if I should present the alert or not, which isn't very nice. I think there should be a better way to handle this… maybe the
failureclosure could also be called when the user taps done without authorizing, or something like that.@dbmrq commented on GitHub (Feb 26, 2016):
Ok, I figured this out by myself.
All I had to do was set the
SafariURLHandlerdelegate to my view controller and implementsafariViewControllerDidFinish:@imkashrao commented on GitHub (Oct 22, 2016):
Another way of dealing it with setting handler.delegate = self and implement the SafariURLHandlerDelegate methods. However, you will have to conform SFSafariViewControllerDelegate in your ViewController.