Geen omschrijving

FIRAuthURLPresenter.h 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 <Foundation/Foundation.h>
  17. NS_ASSUME_NONNULL_BEGIN
  18. @protocol FIRAuthUIDelegate;
  19. /** @typedef FIRAuthURLPresentationCompletion
  20. @brief The type of block invoked when the URLPresentation completes.
  21. @param callbackURL The callback URL if the presentation ends with a matching callback.
  22. @param error The error if the presentation fails to start or ends with an error.
  23. */
  24. typedef void (^FIRAuthURLPresentationCompletion)(NSURL *_Nullable callbackURL,
  25. NSError *_Nullable error);
  26. /** @typedef FIRAuthCallbackMatcher
  27. @brief The type of block invoked for checking whether a callback URL matches.
  28. @param callbackURL The callback URL to check for match.
  29. @return Whether or not the specific callback URL matches or not.
  30. */
  31. typedef BOOL (^FIRAuthURLCallbackMatcher)(NSURL * _Nullable callbackURL);
  32. /** @class FIRAuthURLPresenter
  33. @brief A Class responsible for presenting URL via SFSafariViewController or UIWebView.
  34. */
  35. @interface FIRAuthURLPresenter : NSObject
  36. /** @fn presentURL:UIDelegate:callbackMatcher:completion:
  37. @brief Presents an URL to interact with user.
  38. @param URL The URL to present.
  39. @param UIDelegate The UI delegate to present view controller.
  40. @param completion A block to be called either synchronously if the presentation fails to start,
  41. or asynchronously in future on an unspecified thread once the presentation finishes.
  42. */
  43. - (void)presentURL:(NSURL *)URL
  44. UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
  45. callbackMatcher:(FIRAuthURLCallbackMatcher)callbackMatcher
  46. completion:(FIRAuthURLPresentationCompletion)completion;
  47. /** @fn canHandleURL:
  48. @brief Determines if a URL was produced by the currently presented URL.
  49. @param URL The URL to handle.
  50. @return Whether the URL could be handled or not.
  51. */
  52. - (BOOL)canHandleURL:(NSURL *)URL;
  53. @end
  54. NS_ASSUME_NONNULL_END