[GH-ISSUE #166] tvOS support doesn't work #99

Closed
opened 2026-03-03 16:45:39 +03:00 by kerem · 1 comment
Owner

Originally created by @sjorsvb on GitHub (Dec 27, 2015).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/166

Hi,

I was looking into writing an app requiring OAuth for Apple TV. However, this will not work in most (or all) cases, because tvOS simply has no browser to show the custom authentication webpage. So for example, in this snippet:

@objc public func handle(url: NSURL) {
    #if os(iOS) || os(tvOS)
        #if !OAUTH_APP_EXTENSIONS
            UIApplication.sharedApplication().openURL(url)
        #endif
    #elseif os(watchOS)
    // WATCHOS: not implemented
    #elseif os(OSX)
        NSWorkspace.sharedWorkspace().openURL(url)
    #endif
}

tvOS will try to open a custom web page (i.e. http://www.tumblr.com...), not being able to find a fitting URL scheme and give up. The OAuth methods will not get a callback because of this failure, and hence there is no error message.

I presume the same goes for watchOS, but that is clearly not implemented in this code. Maybe it's nice for you to point out these shortcomings (of OAuth, your framework is nice) on the README, because it cost me a few hours.

Thanks!

Sjors

Originally created by @sjorsvb on GitHub (Dec 27, 2015). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/166 Hi, I was looking into writing an app requiring OAuth for Apple TV. However, this will not work in most (or all) cases, because tvOS simply has no browser to show the custom authentication webpage. So for example, in this snippet: ``` @objc public func handle(url: NSURL) { #if os(iOS) || os(tvOS) #if !OAUTH_APP_EXTENSIONS UIApplication.sharedApplication().openURL(url) #endif #elseif os(watchOS) // WATCHOS: not implemented #elseif os(OSX) NSWorkspace.sharedWorkspace().openURL(url) #endif } ``` tvOS will try to open a custom web page (i.e. http://www.tumblr.com...), not being able to find a fitting URL scheme and give up. The OAuth methods will not get a callback because of this failure, and hence there is no error message. I presume the same goes for watchOS, but that is clearly not implemented in this code. Maybe it's nice for you to point out these shortcomings (of OAuth, your framework is nice) on the README, because it cost me a few hours. Thanks! Sjors
kerem closed this issue 2026-03-03 16:45:40 +03:00
Author
Owner

@phimage commented on GitHub (Dec 27, 2015):

Ok you are right I will add something into readme to alert about that, if I find the good word (my english can be poor sometimes)

The 0.5.0 has been created yesterday with fixed tvos target, I have not yet draft the release with explanation, I can add it also here, and I will edit previous release.
Readme do not advertise about TVOS. Only roadmap (and maybe shell.io badge)

I don't know anythings about TVOS and WatchOS and just looking now on internet show me that webview is not supported or don't want to be supported.
https://medium.com/bpxl-craft/apple-tv-a-world-without-webkit-5c428a64a6dd#.nmjezv38w

Goodbye, OAuth (woah). For now, anyway.

http://thenextweb.com/apple/2015/09/14/apples-made-it-difficult-to-build-tvos-apps-and-thats-good-for-users/

The code you point out is the default handler for authorisation URL, I don't use it, I use mine each times, I have my own web view embedded, I don't try to open externally link (it's bad I think).

The demo app show that, the documentation talk about that (Handle authorize URL)
iOS application on the store do not allow to use this default handler with a page open into the web browser.
You must open into an embedded webview or the new safari controller that I add into the framework.

For TVOS if you want to make an application that are not supposed to go in the app store, I think it's possible because code is shared with iOS. Just need some trick like NSClassFromString("UIWebView")!.

But do not loose time with this ;)
Maybe one day apple will think about oauth and let an application like twitter or facebook handle the url and return token to our application...maybe I am dreaming...

<!-- gh-comment-id:167415530 --> @phimage commented on GitHub (Dec 27, 2015): Ok you are right I will add something into readme to alert about that, if I find the good word (my english can be poor sometimes) The 0.5.0 has been created yesterday with fixed tvos target, I have not yet draft the release with explanation, I can add it also here, and I will edit previous release. Readme do not advertise about TVOS. Only roadmap (and maybe shell.io badge) I don't know anythings about TVOS and WatchOS and just looking now on internet show me that webview is not supported or don't want to be supported. https://medium.com/bpxl-craft/apple-tv-a-world-without-webkit-5c428a64a6dd#.nmjezv38w ``` Goodbye, OAuth (woah). For now, anyway. ``` http://thenextweb.com/apple/2015/09/14/apples-made-it-difficult-to-build-tvos-apps-and-thats-good-for-users/ The code you point out is the default handler for authorisation URL, I don't use it, I use mine each times, I have my own web view embedded, I don't try to open externally link (it's bad I think). The demo app show that, the documentation talk about that (Handle authorize URL) iOS application on the store do not allow to use this default handler with a page open into the web browser. You must open into an embedded webview or the new safari controller that I add into the framework. For TVOS if you want to make an application that are not supposed to go in the app store, I think it's possible because code is shared with iOS. Just need some trick like `NSClassFromString("UIWebView")!`. But do not loose time with this ;) Maybe one day apple will think about oauth and let an application like twitter or facebook handle the url and return token to our application...maybe I am dreaming...
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#99
No description provided.