mirror of
https://github.com/OAuthSwift/OAuthSwift.git
synced 2026-04-26 12:45:52 +03:00
[GH-ISSUE #167] Example usage for OAuthWebViewController #101
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#101
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 @aozbayra on GitHub (Dec 27, 2015).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/167
Like everyone else I am trying to open the sign in process through a web view instead of Safari. This is the piece of code I have:
SafariURLHandler works fine but the OAuthWebViewController does not work I need to present the webvViewController both from the root view controller and some other view controller.
What is the proper implementation of OAuthWebViewController in my case? Thank you in advance.
@phimage commented on GitHub (Dec 27, 2015):
version used?
message, log, error ? maybe #154
Did you try breakpoint into OAuthWebViewController, doHandle method ?
Before 0.5.0 only root view controller was used, now there is a code which try to get current controller, see UIApplication.topViewController (could be bugged in specific view controller hierachy)
demo show example of OAuthWebViewController subclass
https://github.com/OAuthSwift/OAuthSwift/blob/master/OAuthSwiftDemo/WebViewController.swift
@aozbayra commented on GitHub (Dec 28, 2015):
Ok yeah I know about that recursive code I used it before. I have the above lines on two places on of them being the root view controller. When I try it on the root view controller I am getting the black screen so maybe I am not adding the view to the hierarchy but I thought that was being done inside doHandle on this line:
UIApplication.sharedApplication().keyWindow?.rootViewController?.presentViewController(
self, animated: true, completion: nil)
I pulled the code through cocoaPods and oauthswift.version.shortVersion gives me 2.0. What else would you recommend me to add into this piece of code?
if #available(iOS 9.0, *) {
oauthswift.authorize_url_handler = SafariURLHandler(viewController: self)
}
else {
let webView = OAuthWebViewController()
oauthswift.authorize_url_handler = webView
}
@phimage commented on GitHub (Dec 28, 2015):
There is no version 2.0, see https://github.com/OAuthSwift/OAuthSwift/releases
If you use cocoapod there is a PodFile.lock near PodFile with version used
Please update because that following code is old, previous 0.5.0
UIApplication.sharedApplication().keyWindow?.rootViewController?.presentViewController(now as I say we try to get current top view controller
and yes the code according to ios version is good, except that instead of using
OAuthWebViewControlleryou can make your own class with an embeded webview@aozbayra commented on GitHub (Dec 28, 2015):
As per your advice, I used my own class like in the demo and I have updated my version to 0.5. It is working fine right now, thank you for your help.