FUNFakeApp.m 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #import "FUNFakeApp.h"
  18. NS_ASSUME_NONNULL_BEGIN
  19. @interface FUNFakeOptions : NSObject
  20. @property(nonatomic, readonly, copy) NSString *projectID;
  21. - (id)init NS_UNAVAILABLE;
  22. - (instancetype)initWithProjectID:(NSString *)projectID NS_DESIGNATED_INITIALIZER;
  23. @end
  24. @implementation FUNFakeOptions
  25. - (instancetype)initWithProjectID:(NSString *)projectID {
  26. self = [super init];
  27. if (self) {
  28. self->_projectID = [projectID copy];
  29. }
  30. return self;
  31. }
  32. @end
  33. @interface FUNFakeApp () {
  34. NSString *_token;
  35. }
  36. @end
  37. @implementation FUNFakeApp
  38. - (instancetype)initWithProjectID:(NSString *)projectID {
  39. return [self initWithProjectID:projectID token:nil];
  40. }
  41. - (instancetype)initWithProjectID:(NSString *)projectID token:(NSString *_Nullable)token {
  42. self = [super init];
  43. if (self) {
  44. _options = [[FUNFakeOptions alloc] initWithProjectID:projectID];
  45. _token = [token copy];
  46. }
  47. return self;
  48. }
  49. - (void)getTokenForcingRefresh:(BOOL)forceRefresh
  50. withCallback:
  51. (void (^)(NSString *_Nullable token, NSError *_Nullable error))callback {
  52. callback(_token, nil);
  53. }
  54. @end
  55. NS_ASSUME_NONNULL_END