No Description

FIRInstanceIDTokenInfo.h 3.3KB

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 "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. */
  68. - (BOOL)isFresh;
  69. @end
  70. NS_ASSUME_NONNULL_END