File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed
Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -1605,7 +1605,6 @@ extension Auth: AuthInterop {
16051605 /// so the caller should ignore the URL from further processing, and `false` means the
16061606 /// the URL is for the app (or another library) so the caller should continue handling
16071607 /// this URL as usual.
1608- @discardableResult
16091608 @objc ( canHandleURL: ) open func canHandle( _ url: URL ) -> Bool {
16101609 kAuthGlobalWorkQueue. sync {
16111610 guard let authURLPresenter = self . authURLPresenter as? AuthURLPresenter else {
@@ -1614,6 +1613,25 @@ extension Auth: AuthInterop {
16141613 return authURLPresenter. canHandle ( url: url)
16151614 }
16161615 }
1616+
1617+ /// Handles the given URL if it is recognized by `Auth`.
1618+ ///
1619+ /// This method should be called when a URL is received by the scene delegate, ensuring that
1620+ /// authentication-related URLs are properly processed. It ensures that URLs passed from
1621+ /// `openURLContexts` are handled by the authentication system.
1622+ ///
1623+ /// - Note: This method is available on iOS only.
1624+ ///
1625+ /// - Parameter url: The URL received by the application delegate from any of the `openURL`
1626+ /// methods.
1627+ @objc open func handle( _ url: URL ) throws {
1628+ guard canHandle ( url) else {
1629+ throw AuthErrorUtils . error (
1630+ code: AuthErrorCode . internalError,
1631+ userInfo: [ NSLocalizedDescriptionKey: " The URL can't be handled " ]
1632+ )
1633+ }
1634+ }
16171635 #endif
16181636
16191637 /// The name of the `NSNotificationCenter` notification which is posted when the auth state
Original file line number Diff line number Diff line change @@ -2364,6 +2364,22 @@ class AuthTests: RPCBaseTests {
23642364 XCTAssertTrue ( auth. application ( UIApplication . shared, open: url, options: [ : ] ) )
23652365 XCTAssertTrue ( fakeURLPresenter. canHandled)
23662366 }
2367+
2368+ func testAppHandleURL_AuthPresenterHandleURL( ) throws {
2369+ class FakeURLPresenter : AuthURLPresenter {
2370+ var canHandled = false
2371+ override func canHandle( url: URL ) -> Bool {
2372+ canHandled = true
2373+ return true
2374+ }
2375+ }
2376+ let url = try XCTUnwrap ( URL ( string: " https://localhost " ) )
2377+ let fakeURLPresenter = FakeURLPresenter ( )
2378+ auth. authURLPresenter = fakeURLPresenter
2379+ XCTAssertFalse ( fakeURLPresenter. canHandled)
2380+ try auth. handle ( url)
2381+ XCTAssertTrue ( fakeURLPresenter. canHandled)
2382+ }
23672383 #endif // os(iOS)
23682384
23692385 // MARK: Interoperability Tests
You can’t perform that action at this time.
0 commit comments