FIRInstallationsItem.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 "FirebaseInstallations/Source/Library/InstallationsIDController/FIRInstallationsStatus.h"
  18. @class FIRInstallationsStoredItem;
  19. @class FIRInstallationsStoredAuthToken;
  20. @class FIRInstallationsStoredIIDCheckin;
  21. NS_ASSUME_NONNULL_BEGIN
  22. /**
  23. * The class represents the required installation ID and auth token data including possible states.
  24. * The data is stored to Keychain via `FIRInstallationsStoredItem` which has only the storage
  25. * relevant data and does not contain any logic. `FIRInstallationsItem` must be used on the logic
  26. * level (not `FIRInstallationsStoredItem`).
  27. */
  28. @interface FIRInstallationsItem : NSObject <NSCopying>
  29. /// A `FirebaseApp` identifier.
  30. @property(nonatomic, readonly) NSString *appID;
  31. /// A `FirebaseApp` name.
  32. @property(nonatomic, readonly) NSString *firebaseAppName;
  33. /// A stable identifier that uniquely identifies the app instance.
  34. @property(nonatomic, copy, nullable) NSString *firebaseInstallationID;
  35. /// The `refreshToken` is used to authorize the auth token requests.
  36. @property(nonatomic, copy, nullable) NSString *refreshToken;
  37. @property(nonatomic, nullable) FIRInstallationsStoredAuthToken *authToken;
  38. @property(nonatomic, assign) FIRInstallationsStatus registrationStatus;
  39. /// Instance ID default token imported from IID store as a part of IID migration.
  40. @property(nonatomic, nullable) NSString *IIDDefaultToken;
  41. - (instancetype)initWithAppID:(NSString *)appID firebaseAppName:(NSString *)firebaseAppName;
  42. /**
  43. * Populates `FIRInstallationsItem` properties with data from `FIRInstallationsStoredItem`.
  44. * @param item An instance of `FIRInstallationsStoredItem` to get data from.
  45. */
  46. - (void)updateWithStoredItem:(FIRInstallationsStoredItem *)item;
  47. /**
  48. * Creates a stored item with data from the object.
  49. * @return Returns a `FIRInstallationsStoredItem` instance with the data from the object.
  50. */
  51. - (FIRInstallationsStoredItem *)storedItem;
  52. /**
  53. * The installation identifier.
  54. * @return Returns a string uniquely identifying the installation.
  55. */
  56. - (NSString *)identifier;
  57. /** Validates if all the required item fields are populated and values don't explicitly conflict
  58. * with each other.
  59. * @param outError A reference to be populated with an error containing validation failure details.
  60. * @return `YES` if the item it valid, `NO` otherwise.
  61. */
  62. - (BOOL)isValid:(NSError *_Nullable *)outError;
  63. /**
  64. * The installation identifier.
  65. * @param appID A `FirebaseApp` identifier.
  66. * @param appName A `FirebaseApp` name.
  67. * @return Returns a string uniquely identifying the installation.
  68. */
  69. + (NSString *)identifierWithAppID:(NSString *)appID appName:(NSString *)appName;
  70. /**
  71. * Generate a new Firebase Installation Identifier.
  72. * @return Returns a 22 characters long globally unique string created based on UUID.
  73. */
  74. + (NSString *)generateFID;
  75. @end
  76. NS_ASSUME_NONNULL_END