FIRAuthURLPresenter.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #import <TargetConditionals.h>
  17. #if TARGET_OS_IOS
  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. This
  44. completion block always executes on the main thread regardless of the callbackQueue set in
  45. FIRAuth.
  46. */
  47. - (void)presentURL:(NSURL *)URL
  48. UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
  49. callbackMatcher:(FIRAuthURLCallbackMatcher)callbackMatcher
  50. completion:(FIRAuthURLPresentationCompletion)completion;
  51. /** @fn canHandleURL:
  52. @brief Determines if a URL was produced by the currently presented URL.
  53. @param URL The URL to handle.
  54. @return Whether the URL could be handled or not.
  55. */
  56. - (BOOL)canHandleURL:(NSURL *)URL;
  57. @end
  58. NS_ASSUME_NONNULL_END
  59. #endif