No Description

FIRInstanceIDTokenInfo.h 3.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 "FIRInstanceIDAPNSInfo.h"
  18. NS_ASSUME_NONNULL_BEGIN
  19. /**
  20. * Represents an Instance ID token, and all of the relevant information
  21. * associated with it. It can read from and write to an NSDictionary object, for
  22. * simple serialization.
  23. */
  24. @interface FIRInstanceIDTokenInfo : NSObject <NSCoding>
  25. /// The authorized entity (also known as Sender ID), associated with the token.
  26. @property(nonatomic, readonly, copy) NSString *authorizedEntity;
  27. /// The scope associated with the token. This is an arbitrary string, typically "*".
  28. @property(nonatomic, readonly, copy) NSString *scope;
  29. /// The token value itself, with which all other properties are associated.
  30. @property(nonatomic, readonly, copy) NSString *token;
  31. // These properties are nullable because they might not exist for tokens fetched from
  32. // legacy storage formats.
  33. /// The app version that this token represents.
  34. @property(nonatomic, readonly, copy, nullable) NSString *appVersion;
  35. /// The Firebase app ID (also known as GMP App ID), that this token is associated with.
  36. @property(nonatomic, readonly, copy, nullable) NSString *firebaseAppID;
  37. /// Tokens may not always be associated with an APNs token, and may be associated after
  38. /// being created.
  39. @property(nonatomic, strong, nullable) FIRInstanceIDAPNSInfo *APNSInfo;
  40. /// The time that this token info was updated. The cache time is writeable, since in
  41. /// some cases the token info may be refreshed from the server. In those situations,
  42. /// the cacheTime would be updated.
  43. @property(nonatomic, copy, nullable) NSDate *cacheTime;
  44. /**
  45. * Initializes a FIRInstanceIDTokenInfo object with the required parameters. These
  46. * parameters represent all the relevant associated data with a token.
  47. *
  48. * @param authorizedEntity The authorized entity (also known as Sender ID).
  49. * @param scope The scope of the token, typically "*" meaning
  50. * it's a "default scope".
  51. * @param token The token value itself.
  52. * @param appVersion The application version that this token is associated with.
  53. * @param firebaseAppID The Firebase app ID which this token is associated with.
  54. * @return An instance of FIRInstanceIDTokenInfo.
  55. */
  56. - (instancetype)initWithAuthorizedEntity:(NSString *)authorizedEntity
  57. scope:(NSString *)scope
  58. token:(NSString *)token
  59. appVersion:(nullable NSString *)appVersion
  60. firebaseAppID:(nullable NSString *)firebaseAppID;
  61. /**
  62. * Check whether the token is still fresh based on:
  63. * 1. Last fetch token is within the 7 days.
  64. * 2. Language setting is not changed.
  65. * 3. App version is current.
  66. * 4. GMP App ID is current.
  67. * 5. token is consistent with the current IID.
  68. * 6. APNS info has changed.
  69. * @param IID The app identifiier that is used to check if token is prefixed with.
  70. * @return If token is fresh.
  71. *
  72. */
  73. - (BOOL)isFreshWithIID:(NSString *)IID;
  74. /*
  75. * Check whether the token is default token.
  76. */
  77. - (BOOL)isDefaultToken;
  78. @end
  79. NS_ASSUME_NONNULL_END