FIRMockInstanceID.m 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2019 Google
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import "FIRMockInstanceID.h"
  15. #import <Foundation/Foundation.h>
  16. #import <FirebaseInstanceID/FIRInstanceID_Private.h>
  17. @interface FIRMockInstanceID ()
  18. @property(nonatomic, copy) NSString *instanceID;
  19. @property(nonatomic, strong) NSError *error;
  20. @end
  21. @implementation FIRMockInstanceID
  22. - (instancetype)initWithIID:(NSString *)token {
  23. self = [super initPrivately];
  24. if (!self) {
  25. return self;
  26. }
  27. _instanceID = [token copy];
  28. _error = nil;
  29. return self;
  30. }
  31. - (instancetype)initWithError:(NSError *)error {
  32. self = [super initPrivately];
  33. if (!self) {
  34. return self;
  35. }
  36. _instanceID = nil;
  37. _error = error;
  38. return self;
  39. }
  40. - (void)getIDWithHandler:(FIRInstanceIDHandler)handler {
  41. handler(_instanceID, _error);
  42. }
  43. @end