[PR #62] [MERGED] Add OSX, better way to present custom web controller, fix one bug #498

Closed
opened 2026-03-03 16:49:08 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/OAuthSwift/OAuthSwift/pull/62
Author: @phimage
Created: 5/11/2015
Status: Merged
Merged: 5/12/2015
Merged by: @dongri

Base: masterHead: master


📝 Commits (1)

  • ade2238 Remove references of UI objects in core framework classes and allow to present a web controller with segue or custom animation

📊 Changes

17 files changed (+1908 additions, -73 deletions)

View changed files

📝 OAuthSwift.podspec (+3 -2)
📝 OAuthSwift.xcodeproj/project.pbxproj (+337 -9)
📝 OAuthSwift.xcodeproj/xcshareddata/xcschemes/OAuthSwift.xcscheme (+0 -24)
📝 OAuthSwift/OAuth1Swift.swift (+13 -12)
📝 OAuthSwift/OAuth2Swift.swift (+3 -12)
📝 OAuthSwift/OAuthSwiftHTTPRequest.swift (+0 -2)
OAuthSwift/OAuthSwiftURLHandlerType.swift (+34 -0)
📝 OAuthSwift/OAuthWebViewController.swift (+38 -7)
📝 OAuthSwiftDemo/ViewController.swift (+4 -3)
📝 OAuthSwiftDemo/WebViewController.swift (+3 -2)
OAuthSwiftOSX/Info.plist (+28 -0)
OAuthSwiftOSX/OAuthSwiftOSX.h (+19 -0)
OAuthSwiftOSXDemo/AppDelegate.swift (+54 -0)
OAuthSwiftOSXDemo/Base.lproj/Main.storyboard (+764 -0)
OAuthSwiftOSXDemo/Info.plist (+43 -0)
OAuthSwiftOSXDemo/ViewController.swift (+499 -0)
OAuthSwiftOSXDemo/WebViewController.swift (+66 -0)

📄 Description

1 / Fix OAuth1 if callback url returned by service has no query (only fragment)

2 / Add compatibility with OSX, add demo project inspired from iOS one (many code to factorise)

3/ Normally a controller is not responsible to choose its parent controller as you do with the code

UIApplication.sharedApplication().keyWindow?.rootViewController?.presentViewController(
                        self.webViewController!, animated: true, completion: nil)

A parent controller, not only the root one, could do it (moreover this root controller doesn't exist in OSX)
Maybe the web view controller could be in a storyboard, a segue must be performed to show it (with maybe a custom animation)
Maybe a web view is already present in the application, and no web view must be shown, only and url update of the current one

That's why

  • I rename the protocol WebViewProtocol to OAuthSwiftURLHandlerType, move to its own file,
  • Replace in OAuth objects the property webViewController by an authorize_url_handler: OAuthSwiftURLHandlerType
  • Make a default implementation to open URL externally has you do if there is no webViewController assigned to the OAuth object

In consequence, no more UIKit(or AppKit for OSX) reference to the core framework
Users of framework can make their own code to show the web view which handle the url
OAuthWebViewController can always be extended with default behaviour (this object could be excluded from core framework and be part of a submodule in podspec)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/OAuthSwift/OAuthSwift/pull/62 **Author:** [@phimage](https://github.com/phimage) **Created:** 5/11/2015 **Status:** ✅ Merged **Merged:** 5/12/2015 **Merged by:** [@dongri](https://github.com/dongri) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (1) - [`ade2238`](https://github.com/OAuthSwift/OAuthSwift/commit/ade22389dbd549c74f9e5495933f8ef167fc6c84) Remove references of UI objects in core framework classes and allow to present a web controller with segue or custom animation ### 📊 Changes **17 files changed** (+1908 additions, -73 deletions) <details> <summary>View changed files</summary> 📝 `OAuthSwift.podspec` (+3 -2) 📝 `OAuthSwift.xcodeproj/project.pbxproj` (+337 -9) 📝 `OAuthSwift.xcodeproj/xcshareddata/xcschemes/OAuthSwift.xcscheme` (+0 -24) 📝 `OAuthSwift/OAuth1Swift.swift` (+13 -12) 📝 `OAuthSwift/OAuth2Swift.swift` (+3 -12) 📝 `OAuthSwift/OAuthSwiftHTTPRequest.swift` (+0 -2) ➕ `OAuthSwift/OAuthSwiftURLHandlerType.swift` (+34 -0) 📝 `OAuthSwift/OAuthWebViewController.swift` (+38 -7) 📝 `OAuthSwiftDemo/ViewController.swift` (+4 -3) 📝 `OAuthSwiftDemo/WebViewController.swift` (+3 -2) ➕ `OAuthSwiftOSX/Info.plist` (+28 -0) ➕ `OAuthSwiftOSX/OAuthSwiftOSX.h` (+19 -0) ➕ `OAuthSwiftOSXDemo/AppDelegate.swift` (+54 -0) ➕ `OAuthSwiftOSXDemo/Base.lproj/Main.storyboard` (+764 -0) ➕ `OAuthSwiftOSXDemo/Info.plist` (+43 -0) ➕ `OAuthSwiftOSXDemo/ViewController.swift` (+499 -0) ➕ `OAuthSwiftOSXDemo/WebViewController.swift` (+66 -0) </details> ### 📄 Description 1 / Fix OAuth1 if callback url returned by service has no query (only fragment) 2 / Add compatibility with OSX, add demo project inspired from iOS one (many code to factorise) 3/ Normally a controller is not responsible to choose its parent controller as you do with the code ``` swift UIApplication.sharedApplication().keyWindow?.rootViewController?.presentViewController( self.webViewController!, animated: true, completion: nil) ``` A parent controller, not only the root one, could do it (moreover this root controller doesn't exist in OSX) Maybe the web view controller could be in a storyboard, a segue must be performed to show it (with maybe a custom animation) Maybe a web view is already present in the application, and no web view must be shown, only and url update of the current one That's why - I rename the protocol WebViewProtocol to OAuthSwiftURLHandlerType, move to its own file, - Replace in OAuth objects the property webViewController by an authorize_url_handler: OAuthSwiftURLHandlerType - Make a default implementation to open URL externally has you do if there is no webViewController assigned to the OAuth object In consequence, no more UIKit(or AppKit for OSX) reference to the core framework Users of framework can make their own code to show the web view which handle the url OAuthWebViewController can always be extended with default behaviour (this object could be excluded from core framework and be part of a submodule in podspec) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-03 16:49:08 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/OAuthSwift#498
No description provided.