[GH-ISSUE #356] How can I get callback that authorization process has been finished? #227

Closed
opened 2026-03-03 16:46:51 +03:00 by kerem · 4 comments
Owner

Originally created by @hiragram on GitHub (Apr 4, 2017).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/356

Description:

I am using my custom webview controller, and I want to dismiss the vc when authorization has succeeded.
I have looked into implementation of SafariURLHandler and found it uses OAuthSwift.CallbackNotification.notificationName but CallbackNotification is internal struct so I cannot use.
Are there any way to receive callback like that?

OAuth Provider (Twitter, Github, ..):

OAuth Version:

  • Version 1
  • Version 2

OS (Please fill the version) :

  • iOS :
  • OSX :
  • TVOS :
  • WatchOS :

Installation method:

  • Carthage
  • CocoaPods
  • Manually

Library version:

  • head
  • v1.0.0
  • v0.6
  • other: (Please fill in the version you are using.)

Xcode version:

  • 8.0 (Swift 3.0)

  • 8.0 (Swift 2.3)

  • 7.3.1

  • other: (Please fill in the version you are using.)

  • objective c

Originally created by @hiragram on GitHub (Apr 4, 2017). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/356 ### Description: I am using my custom webview controller, and I want to dismiss the vc when authorization has succeeded. I have looked into implementation of `SafariURLHandler` and found it uses `OAuthSwift.CallbackNotification.notificationName` but `CallbackNotification` is internal struct so I cannot use. Are there any way to receive callback like that? ### OAuth Provider (Twitter, Github, ..): ### OAuth Version: - [ ] Version 1 - [ ] Version 2 ### OS (Please fill the version) : - [x] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [x] Carthage - [ ] CocoaPods - [ ] Manually ### Library version: - [ ] head - [x] v1.0.0 - [ ] v0.6 - [ ] other: (Please fill in the version you are using.) ### Xcode version: - [x] 8.0 (Swift 3.0) - [ ] 8.0 (Swift 2.3) - [ ] 7.3.1 - [ ] other: (Please fill in the version you are using.) - [ ] objective c
kerem closed this issue 2026-03-03 16:46:51 +03:00
Author
Owner

@phimage commented on GitHub (Apr 4, 2017):

You can look at demo app
github.com/OAuthSwift/OAuthSwift@0296377d14/Demo/Common/WebViewController.swift
Using the delegate of web view you could know when your url is open and so you can dismiss immediately or launch a task using DispatchQueue

<!-- gh-comment-id:291408156 --> @phimage commented on GitHub (Apr 4, 2017): You can look at demo app https://github.com/OAuthSwift/OAuthSwift/blob/0296377d14b27d89113afbf15fc0f01f7f06f304/Demo/Common/WebViewController.swift Using the delegate of web view you could know when your url is open and so you can dismiss immediately or launch a task using DispatchQueue
Author
Owner

@hiragram commented on GitHub (Apr 4, 2017):

@phimage
Thanks for quick reply.
I understand your suggestion. But my webview controller is used in whole app so I don't want to write OAuth-specific code in the webview controller class. If I could receive notification in my custom OAuthSwiftURLHandlerType such as SafariURLHandler , that sounds more better to me.
How do you think about making CallbackNotification type public?

<!-- gh-comment-id:291409869 --> @hiragram commented on GitHub (Apr 4, 2017): @phimage Thanks for quick reply. I understand your suggestion. But my webview controller is used in whole app so I don't want to write OAuth-specific code in the webview controller class. If I could receive notification in my custom `OAuthSwiftURLHandlerType` such as `SafariURLHandler` , that sounds more better to me. How do you think about making `CallbackNotification` type public?
Author
Owner

@phimage commented on GitHub (Apr 4, 2017):

why not, but the code is not clean

For instance I think instead of

 struct CallbackNotification {
        static let notificationName = Notification.Name(rawValue: "OAuthSwiftCallbackNotificationName")
    }

we must have

extension Notification.Name {
    public static var OAuthSwiftHandleCallbackURL: Notification.Name = .init("OAuthSwiftCallbackNotificationName")
}

If you do the PR I will merge

<!-- gh-comment-id:291411790 --> @phimage commented on GitHub (Apr 4, 2017): why not, but the code is not clean For instance I think instead of ```swift struct CallbackNotification { static let notificationName = Notification.Name(rawValue: "OAuthSwiftCallbackNotificationName") } ``` we must have ```swift extension Notification.Name { public static var OAuthSwiftHandleCallbackURL: Notification.Name = .init("OAuthSwiftCallbackNotificationName") } ``` If you do the PR I will merge
Author
Owner

@hiragram commented on GitHub (Apr 4, 2017):

@phimage
Sounds cool. I will do that on my fork and create PR.

<!-- gh-comment-id:291414769 --> @hiragram commented on GitHub (Apr 4, 2017): @phimage Sounds cool. I will do that on my fork and create PR.
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#227
No description provided.