FIRInstallationsItem.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 FIRInstallationsStoredRegistrationError;
  21. @class FIRInstallationsStoredRegistrationParameters;
  22. NS_ASSUME_NONNULL_BEGIN
  23. /**
  24. * The class represents the required installation ID and auth token data including possible states.
  25. * The data is stored to Keychain via `FIRInstallationsStoredItem` which has only the storage
  26. * relevant data and does not contain any logic. `FIRInstallationsItem` must be used on the logic
  27. * level (not `FIRInstallationsStoredItem`).
  28. */
  29. @interface FIRInstallationsItem : NSObject <NSCopying>
  30. /// A `FirebaseApp` identifier.
  31. @property(nonatomic, readonly) NSString *appID;
  32. /// A `FirebaseApp` name.
  33. @property(nonatomic, readonly) NSString *firebaseAppName;
  34. /// A stable identifier that uniquely identifies the app instance.
  35. @property(nonatomic, copy, nullable) NSString *firebaseInstallationID;
  36. /// The `refreshToken` is used to authorize the auth token requests.
  37. @property(nonatomic, copy, nullable) NSString *refreshToken;
  38. @property(nonatomic, nullable) FIRInstallationsStoredAuthToken *authToken;
  39. @property(nonatomic, assign) FIRInstallationsStatus registrationStatus;
  40. @property(nonatomic, nullable) FIRInstallationsStoredRegistrationError *registrationError;
  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. /**
  70. * Updates `registrationStatus` and `registrationError` accordingly.
  71. * @param error The error for the Installation Registration API request.
  72. * @param date The date when the error occurred.
  73. * @param registrationParameters The parameters used for the Installation Registration API request.
  74. */
  75. - (void)updateWithRegistrationError:(NSError *)error
  76. date:(NSDate *)date
  77. registrationParameters:
  78. (FIRInstallationsStoredRegistrationParameters *)registrationParameters;
  79. @end
  80. NS_ASSUME_NONNULL_END