FIRInstallationsItem.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. @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. /**
  58. * The installation identifier.
  59. * @param appID A `FirebaseApp` identifier.
  60. * @param appName A `FirebaseApp` name.
  61. * @return Returns a string uniquely identifying the installation.
  62. */
  63. + (NSString *)identifierWithAppID:(NSString *)appID appName:(NSString *)appName;
  64. /**
  65. * Generate a new Firebase Installation Identifier.
  66. * @return Returns a 22 characters long globally unique string created based on UUID.
  67. */
  68. + (NSString *)generateFID;
  69. @end
  70. NS_ASSUME_NONNULL_END