Geen omschrijving

FIRInstanceIDCheckinStore.h 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. @class FIRInstanceIDAuthKeychain;
  18. @class FIRInstanceIDBackupExcludedPlist;
  19. @class FIRInstanceIDCheckinPreferences;
  20. // These values exposed for testing
  21. extern NSString *const kFIRInstanceIDCheckinKeychainService;
  22. extern NSString *const kFIRInstanceIDLegacyCheckinKeychainAccount;
  23. extern NSString *const kFIRInstanceIDLegacyCheckinKeychainService;
  24. /**
  25. * Checkin preferences backing store.
  26. */
  27. @interface FIRInstanceIDCheckinStore : NSObject
  28. /**
  29. * Designated Initializer. Initialize a checkin store with the given backup excluded
  30. * plist filename.
  31. *
  32. * @param checkinFilename The backup excluded plist filename to persist checkin
  33. * preferences.
  34. *
  35. * @param subDirectoryName Sub-directory in standard directory where we write
  36. * InstanceID plist.
  37. *
  38. * @return Store to persist checkin preferences.
  39. */
  40. - (instancetype)initWithCheckinPlistFileName:(NSString *)checkinFilename
  41. subDirectoryName:(NSString *)subDirectoryName;
  42. /**
  43. * Initialize a checkin store with the given backup excluded plist and keychain.
  44. *
  45. * @param plist The backup excluded plist to persist checkin preferences.
  46. * @param keychain The keychain used to persist checkin auth preferences.
  47. *
  48. * @return Store to persist checkin preferences.
  49. */
  50. - (instancetype)initWithCheckinPlist:(FIRInstanceIDBackupExcludedPlist *)plist
  51. keychain:(FIRInstanceIDAuthKeychain *)keychain;
  52. /**
  53. * Checks whether the backup excluded checkin preferences are present on the disk or not.
  54. *
  55. * @return YES if the backup excluded checkin plist exists on the disks else NO.
  56. */
  57. - (BOOL)hasCheckinPlist;
  58. #pragma mark - Save
  59. /**
  60. * Save the checkin preferences to backing store.
  61. *
  62. * @param preferences Checkin preferences to save.
  63. * @param handler The callback handler which is invoked when the operation is complete,
  64. * with an error if there is any.
  65. */
  66. - (void)saveCheckinPreferences:(FIRInstanceIDCheckinPreferences *)preferences
  67. handler:(void (^)(NSError *error))handler;
  68. #pragma mark - Delete
  69. /**
  70. * Remove the cached checkin preferences.
  71. *
  72. * @param handler The callback handler which is invoked when the operation is complete,
  73. * with an error if there is any.
  74. */
  75. - (void)removeCheckinPreferencesWithHandler:(void (^)(NSError *error))handler;
  76. #pragma mark - Get
  77. /**
  78. * Get the cached device secret. If we cannot access it for some reason we
  79. * return the appropriate error object.
  80. *
  81. * @return The cached checkin preferences if present else nil.
  82. */
  83. - (FIRInstanceIDCheckinPreferences *)cachedCheckinPreferences;
  84. /**
  85. * Migrate the checkin item from old service/account to the new one.
  86. * The new account is dynamic as it uses bundle ID.
  87. * This is to ensure checkin is not shared across apps, but still the same
  88. * if app has used GCM before.
  89. * This call should only happen once.
  90. *
  91. */
  92. - (void)migrateCheckinItemIfNeeded;
  93. @end