MainViewController+Internal.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright 2019 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. #import "MainViewController.h"
  18. #import "FirebaseAuth.h"
  19. #import "UIViewController+Alerts.h"
  20. #import "AuthProviders.h"
  21. NS_ASSUME_NONNULL_BEGIN
  22. static NSString *const kSignedInAlertTitle = @"Signed In";
  23. static NSString *const kSignInErrorAlertTitle = @"Sign-In Error";
  24. /** @brief The request type for OOB action codes.
  25. */
  26. typedef enum {
  27. /** No action code settings. */
  28. ActionCodeRequestTypeEmail,
  29. /** With continue URL but not handled in-app. */
  30. ActionCodeRequestTypeContinue,
  31. /** Handled in-app. */
  32. ActionCodeRequestTypeInApp,
  33. } ActionCodeRequestType;
  34. typedef void (^TextInputCompletionBlock)(NSString *_Nullable userInput);
  35. typedef void (^TestAutomationCallback)(NSError *_Nullable error);
  36. @interface MainViewController ()
  37. @property(nonatomic) BOOL isNewUserToggleOn;
  38. @property(nonatomic) ActionCodeRequestType actionCodeRequestType;
  39. @property(nonatomic) NSURL *actionCodeContinueURL;
  40. @property(nonatomic) FIROAuthProvider *googleOAuthProvider;
  41. @property(nonatomic) FIROAuthProvider *microsoftOAuthProvider;
  42. @property(nonatomic) FIROAuthProvider *twitterOAuthProvider;
  43. @property(nonatomic) FIROAuthProvider *linkedinOAuthProvider;
  44. @property(nonatomic) FIROAuthProvider *yahooOAuthProvider;
  45. @property(nonatomic) FIROAuthProvider *gitHubOAuthProvider;
  46. @property(nonatomic) NSMutableArray<FIRAuthStateDidChangeListenerHandle> *authStateDidChangeListeners;
  47. @property(nonatomic) NSMutableArray<FIRAuthStateDidChangeListenerHandle> *IDTokenDidChangeListeners;
  48. - (void)updateTable;
  49. - (FIRUser *)user;
  50. - (void)signinWithProvider:(id<AuthProvider>)authProvider retrieveData:(BOOL)retrieveData;
  51. - (void)signInWithProvider:(nonnull id<AuthProvider>)provider callback:(void(^)(void))callback;
  52. - (void)linkWithAuthProvider:(id<AuthProvider>)authProvider retrieveData:(BOOL)retrieveData;
  53. - (void)unlinkFromProvider:(NSString *)provider
  54. completion:(nullable TestAutomationCallback)completion;
  55. - (void)reauthenticate:(id<AuthProvider>)authProvider retrieveData:(BOOL)retrieveData;
  56. - (void)log:(NSString *)string;
  57. - (void)logSuccess:(NSString *)string;
  58. - (void)logFailure:(NSString *)string error:(NSError * _Nullable) error;
  59. - (void)logFailedTest:(NSString *)reason;
  60. - (NSString *)stringWithAdditionalUserInfo:(nullable FIRAdditionalUserInfo *)additionalUserInfo;
  61. - (void)showTypicalUIForUserUpdateResultsWithTitle:(NSString *)resultsTitle
  62. error:(NSError * _Nullable)error;
  63. - (FIRActionCodeSettings *)actionCodeSettings;
  64. @end
  65. NS_ASSUME_NONNULL_END