FIRAppCheckComponent.m 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright 2023 Google LLC
  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 "FirebaseAppCheck/Sources/Core/FIRAppCheck+Internal.h"
  18. #import "FirebaseAppCheck/Sources/Public/FirebaseAppCheck/FIRAppCheck.h"
  19. #import "FirebaseAppCheck/Interop/FIRAppCheckInterop.h"
  20. #import "FirebaseCore/Extension/FirebaseCoreInternal.h"
  21. NS_ASSUME_NONNULL_BEGIN
  22. @interface FIRAppCheckComponent : NSObject <FIRLibrary>
  23. @end
  24. @implementation FIRAppCheckComponent
  25. + (void)load {
  26. [FIRApp registerInternalLibrary:(Class<FIRLibrary>)self withName:@"fire-app-check"];
  27. }
  28. + (NSArray<FIRComponent *> *)componentsToRegister {
  29. FIRComponentCreationBlock creationBlock =
  30. ^id _Nullable(FIRComponentContainer *container, BOOL *isCacheable) {
  31. *isCacheable = YES;
  32. return [[FIRAppCheck alloc] initWithApp:container.app];
  33. };
  34. // Use eager instantiation timing to give a chance for FAC token to be requested before it is
  35. // actually needed to avoid extra delaying dependent requests.
  36. FIRComponent *appCheckProvider =
  37. [FIRComponent componentWithProtocol:@protocol(FIRAppCheckInterop)
  38. instantiationTiming:FIRInstantiationTimingAlwaysEager
  39. dependencies:@[]
  40. creationBlock:creationBlock];
  41. return @[ appCheckProvider ];
  42. }
  43. @end
  44. NS_ASSUME_NONNULL_END