You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.5 KiB

6 years ago
5 years ago
6 years ago
6 years ago
5 years ago
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <TargetConditionals.h>
  17. #if !TARGET_OS_OSX && !TARGET_OS_TV
  18. #import <Foundation/Foundation.h>
  19. NS_ASSUME_NONNULL_BEGIN
  20. @protocol FIRAuthUIDelegate;
  21. /** @typedef FIRAuthURLPresentationCompletion
  22. @brief The type of block invoked when the URLPresentation completes.
  23. @param callbackURL The callback URL if the presentation ends with a matching callback.
  24. @param error The error if the presentation fails to start or ends with an error.
  25. */
  26. typedef void (^FIRAuthURLPresentationCompletion)(NSURL *_Nullable callbackURL,
  27. NSError *_Nullable error);
  28. /** @typedef FIRAuthCallbackMatcher
  29. @brief The type of block invoked for checking whether a callback URL matches.
  30. @param callbackURL The callback URL to check for match.
  31. @return Whether or not the specific callback URL matches or not.
  32. */
  33. typedef BOOL (^FIRAuthURLCallbackMatcher)(NSURL * _Nullable callbackURL);
  34. /** @class FIRAuthURLPresenter
  35. @brief A Class responsible for presenting URL via SFSafariViewController or WKWebView.
  36. */
  37. @interface FIRAuthURLPresenter : NSObject
  38. /** @fn presentURL:UIDelegate:callbackMatcher:completion:
  39. @brief Presents an URL to interact with user.
  40. @param URL The URL to present.
  41. @param UIDelegate The UI delegate to present view controller.
  42. @param completion A block to be called either synchronously if the presentation fails to start,
  43. or asynchronously in future on an unspecified thread once the presentation finishes.
  44. */
  45. - (void)presentURL:(NSURL *)URL
  46. UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
  47. callbackMatcher:(FIRAuthURLCallbackMatcher)callbackMatcher
  48. completion:(FIRAuthURLPresentationCompletion)completion;
  49. /** @fn canHandleURL:
  50. @brief Determines if a URL was produced by the currently presented URL.
  51. @param URL The URL to handle.
  52. @return Whether the URL could be handled or not.
  53. */
  54. - (BOOL)canHandleURL:(NSURL *)URL;
  55. @end
  56. NS_ASSUME_NONNULL_END
  57. #endif