mirror of
https://github.com/OAuthSwift/OAuthSwift.git
synced 2026-04-26 12:45:52 +03:00
[GH-ISSUE #248] Can't seem to use SafariViewController #144
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#144
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 @tunds on GitHub (Jul 7, 2016).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/248
Seems like i've set everything right but when trying to access the SafariViewController using the following
if #available(iOS 9.0, *) { oauthswift.authorize_url_handler = SafariURLHandler(viewController: self) } else { oauthswift.authorize_url_handler = AuthWebViewController() }I get the following error in the console
2016-07-07 17:51:35.047 OAuthSwiftExample[402:76129] Warning: Attempt to present <SFSafariViewController: 0x14d49b10> on <OAuthSwiftExample.Auth: 0x14e39250> whose view is not in the window hierarchy!@phimage commented on GitHub (Jul 7, 2016):
I think that this error indicate that we try to present the safari controller using
selfas parent (the one passed intoSafariURLHandlerinit) but thisselfcontroller is not displayed (or not into hierarchy) when you doing authentificationMaybe I have a temporary fix that could work for you (even if I think you use the wrong controller when doing init)
Try to edit
SafariURLHandlerclass into OAuthSwiftURLHandlerType.swiftWhen
controlleris used, replace byUIViewController. topViewController(controller)orUIApplication.topViewController?@tunds commented on GitHub (Jul 7, 2016):
Hi there i'm not too sure i understand where to make the edits on which line in this class... Also the class that i'm calling this on is the rootviewcontroller as well reckon this could be the issue?
@phimage commented on GitHub (Jul 7, 2016):
yes the controller passed must be the one currently displayed when launching authentification
@tunds commented on GitHub (Jul 7, 2016):
Ahh right okay so could you possible hint at which line to change since i'm a bit confused as to what i have to edit in that class
@phimage commented on GitHub (Jul 7, 2016):
I talk first about a fix in oauthswift code and I think I say the file name and class
But to really fix your problem, it is in your code when you doing
oauthswift.authorize_url_handler = SafariURLHandler(viewController: self) }Do it into the view controller which launch the authentification, not appdeletage or something like that
@tunds commented on GitHub (Jul 7, 2016):
Hmmm see i've not done in the app delegate i've actually done it on the class which i want it do the app authentication on, as you can see below in my authentication class
` func doOAuthSoundCloud(consumerKey: String, consumerSecret: String) {
// if #available(iOS 9.0, *) {
//
// } else {
//
// }
and in my view controller when i want to login
`//
// ViewController.swift
// OAuthSwiftExample
//
// Created by Tunde Adegoroye on 07/07/2016.
// Copyright © 2016 Tunde Adegoroye. All rights reserved.
//
import UIKit
class ViewController: RootViewController {
}
`
@tunds commented on GitHub (Jul 8, 2016):
Move authentication to the correct class and it's now working.