File tree 2 files changed +35
-1
lines changed
2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -1605,7 +1605,6 @@ extension Auth: AuthInterop {
1605
1605
/// so the caller should ignore the URL from further processing, and `false` means the
1606
1606
/// the URL is for the app (or another library) so the caller should continue handling
1607
1607
/// this URL as usual.
1608
- @discardableResult
1609
1608
@objc ( canHandleURL: ) open func canHandle( _ url: URL ) -> Bool {
1610
1609
kAuthGlobalWorkQueue. sync {
1611
1610
guard let authURLPresenter = self . authURLPresenter as? AuthURLPresenter else {
@@ -1614,6 +1613,25 @@ extension Auth: AuthInterop {
1614
1613
return authURLPresenter. canHandle ( url: url)
1615
1614
}
1616
1615
}
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
+ }
1617
1635
#endif
1618
1636
1619
1637
/// 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 {
2364
2364
XCTAssertTrue ( auth. application ( UIApplication . shared, open: url, options: [ : ] ) )
2365
2365
XCTAssertTrue ( fakeURLPresenter. canHandled)
2366
2366
}
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
+ }
2367
2383
#endif // os(iOS)
2368
2384
2369
2385
// MARK: Interoperability Tests
You can’t perform that action at this time.
0 commit comments