FIRInstanceIDCheckinService.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 "FIRInstanceIDUtilities.h"
  18. NS_ASSUME_NONNULL_BEGIN
  19. // keys in Checkin preferences
  20. FOUNDATION_EXPORT NSString *const kFIRInstanceIDDeviceAuthIdKey;
  21. FOUNDATION_EXPORT NSString *const kFIRInstanceIDSecretTokenKey;
  22. FOUNDATION_EXPORT NSString *const kFIRInstanceIDDigestStringKey;
  23. FOUNDATION_EXPORT NSString *const kFIRInstanceIDLastCheckinTimeKey;
  24. FOUNDATION_EXPORT NSString *const kFIRInstanceIDVersionInfoStringKey;
  25. FOUNDATION_EXPORT NSString *const kFIRInstanceIDGServicesDictionaryKey;
  26. FOUNDATION_EXPORT NSString *const kFIRInstanceIDDeviceDataVersionKey;
  27. @class FIRInstanceIDCheckinPreferences;
  28. /**
  29. * @related FIRInstanceIDCheckinService
  30. *
  31. * The completion handler invoked once the fetch from Checkin server finishes.
  32. * For successful fetches we returned checkin information by the checkin service
  33. * and `nil` error, else we return the appropriate error object as reported by the
  34. * Checkin Service.
  35. *
  36. * @param checkinPreferences The checkin preferences as fetched from the server.
  37. * @param error The error object which fetching GServices data.
  38. */
  39. typedef void (^FIRInstanceIDDeviceCheckinCompletion)(
  40. FIRInstanceIDCheckinPreferences *_Nullable checkinPreferences, NSError *_Nullable error);
  41. /**
  42. * Register the device with Checkin Service and get back the `authID`, `secret
  43. * token` etc. for the client. Checkin results are cached in the
  44. * `FIRInstanceIDCache` and periodically refreshed to prevent them from being stale.
  45. * Each client needs to register with checkin before registering with InstanceID.
  46. */
  47. @interface FIRInstanceIDCheckinService : NSObject
  48. /**
  49. * Execute a device checkin request to obtain an deviceID, secret token,
  50. * gService data.
  51. *
  52. * @param existingCheckin An existing checkin preference object, if available.
  53. * @param completion Completion hander called on success or failure of device checkin.
  54. */
  55. - (void)checkinWithExistingCheckin:(nullable FIRInstanceIDCheckinPreferences *)existingCheckin
  56. completion:(FIRInstanceIDDeviceCheckinCompletion)completion;
  57. /**
  58. * This would stop any request that the service made to the checkin backend and also
  59. * release any callback handlers that it holds.
  60. */
  61. - (void)stopFetching;
  62. /**
  63. * Set test block for mock testing network requests.
  64. *
  65. * @param block The block to invoke as a mock response from the network.
  66. */
  67. + (void)setCheckinTestBlock:(nullable FIRInstanceIDURLRequestTestBlock)block;
  68. @end
  69. NS_ASSUME_NONNULL_END