FIRInstallationsItem.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 "FIRInstallationsStatus.h"
  18. @class FIRInstallationsStoredItem;
  19. @class FIRInstallationsStoredAuthToken;
  20. NS_ASSUME_NONNULL_BEGIN
  21. /**
  22. * The class represents the required installation ID and auth token data including possible states.
  23. * The data is stored to Keychain via `FIRInstallationsStoredItem` which has only the storage
  24. * relevant data and does not contain any logic. `FIRInstallationsItem` must be used on the logic
  25. * level (not `FIRInstallationsStoredItem`).
  26. */
  27. @interface FIRInstallationsItem : NSObject <NSCopying>
  28. /// A `FirebaseApp` identifier.
  29. @property(nonatomic, readonly) NSString *appID;
  30. /// A `FirebaseApp` name.
  31. @property(nonatomic, readonly) NSString *firebaseAppName;
  32. /// A stable identifier that uniquely identifies the app instance.
  33. @property(nonatomic, copy, nullable) NSString *firebaseInstallationID;
  34. /// The `refreshToken` is used to authorize the auth token requests.
  35. @property(nonatomic, copy, nullable) NSString *refreshToken;
  36. @property(nonatomic, nullable) FIRInstallationsStoredAuthToken *authToken;
  37. @property(nonatomic, assign) FIRInstallationsStatus registrationStatus;
  38. - (instancetype)initWithAppID:(NSString *)appID firebaseAppName:(NSString *)firebaseAppName;
  39. /**
  40. * Populates `FIRInstallationsItem` properties with data from `FIRInstallationsStoredItem`.
  41. * @param item An instance of `FIRInstallationsStoredItem` to get data from.
  42. */
  43. - (void)updateWithStoredItem:(FIRInstallationsStoredItem *)item;
  44. /**
  45. * Creates a stored item with data from the object.
  46. * @return Returns a `FIRInstallationsStoredItem` instance with the data from the object.
  47. */
  48. - (FIRInstallationsStoredItem *)storedItem;
  49. /**
  50. * The installation identifier.
  51. * @return Returns a string uniquely identifying the installation.
  52. */
  53. - (NSString *)identifier;
  54. /**
  55. * The installation identifier.
  56. * @param appID A `FirebaseApp` identifier.
  57. * @param appName A `FirebaseApp` name.
  58. * @return Returns a string uniquely identifying the installation.
  59. */
  60. + (NSString *)identifierWithAppID:(NSString *)appID appName:(NSString *)appName;
  61. /**
  62. * Generate a new Firebase Installation Identifier.
  63. * @return Returns a 22 characters long globally unique string created based on UUID.
  64. */
  65. + (NSString *)generateFID;
  66. @end
  67. NS_ASSUME_NONNULL_END