Няма описание

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 "FIRInstanceIDCheckinService.h"
  18. @class FIRInstanceIDCheckinPreferences;
  19. @class FIRInstanceIDStore;
  20. /**
  21. * FIRInstanceIDAuthService is responsible for retrieving, caching, and supplying checkin info
  22. * for the rest of Instance ID. A checkin can be scheduled, meaning that it will keep retrying the
  23. * checkin request until it is successful. A checkin can also be requested directly, with a
  24. * completion handler.
  25. */
  26. @interface FIRInstanceIDAuthService : NSObject
  27. /**
  28. * Used only for testing. In addition to taking a store (for locally caching the checkin info), it
  29. * also takes a checkinService.
  30. */
  31. - (instancetype)initWithCheckinService:(FIRInstanceIDCheckinService *)checkinService
  32. store:(FIRInstanceIDStore *)store;
  33. /**
  34. * Initializes the auth service given a store (which provides the local caching of checkin info).
  35. * This initializer will create its own instance of FIRInstanceIDCheckinService.
  36. */
  37. - (instancetype)initWithStore:(FIRInstanceIDStore *)store;
  38. #pragma mark - Checkin Service
  39. /**
  40. * Checks if the current deviceID and secret are valid or not.
  41. *
  42. * @return YES if the checkin credentials are valid else NO.
  43. */
  44. - (BOOL)hasValidCheckinInfo;
  45. /**
  46. * Fetch checkin info from the server. This would usually refresh the existing
  47. * checkin credentials for the current app.
  48. *
  49. * @param handler The completion handler to invoke once the checkin info has been
  50. * refreshed.
  51. */
  52. - (void)fetchCheckinInfoWithHandler:(FIRInstanceIDDeviceCheckinCompletion)handler;
  53. /**
  54. * Schedule checkin. Will hit the network only if the currently loaded checkin
  55. * preferences are stale.
  56. *
  57. * @param immediately YES if we want it to be scheduled immediately else NO.
  58. */
  59. - (void)scheduleCheckin:(BOOL)immediately;
  60. /**
  61. * Returns the checkin preferences currently loaded in memory. The Checkin preferences
  62. * can be either valid or invalid.
  63. *
  64. * @return The checkin preferences loaded in memory.
  65. */
  66. - (FIRInstanceIDCheckinPreferences *)checkinPreferences;
  67. /**
  68. * Cancels any ongoing checkin fetch, if any.
  69. */
  70. - (void)stopCheckinRequest;
  71. /**
  72. * Resets the checkin information.
  73. *
  74. * @param handler The callback handler which is invoked when checkin reset is complete,
  75. * with an error if there is any.
  76. */
  77. - (void)resetCheckinWithHandler:(void (^)(NSError *error))handler;
  78. @end