Nessuna descrizione

FIRInstanceIDCheckinService.h 3.1KB

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