FIRMessagingAuthService.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 "FirebaseMessaging/Sources/Token/FIRMessagingCheckinService.h"
  18. NS_ASSUME_NONNULL_BEGIN
  19. @class FIRMessagingCheckinPreferences;
  20. /**
  21. * @related FIRInstanceIDCheckinService
  22. *
  23. * The completion handler invoked once the fetch from Checkin server finishes.
  24. * For successful fetches we returned checkin information by the checkin service
  25. * and `nil` error, else we return the appropriate error object as reported by the
  26. * Checkin Service.
  27. *
  28. * @param checkinPreferences The checkin preferences as fetched from the server.
  29. * @param error The error object which fetching GServices data.
  30. */
  31. typedef void (^FIRMessagingDeviceCheckinCompletion)(
  32. FIRMessagingCheckinPreferences *_Nullable checkinPreferences, NSError *_Nullable error);
  33. /**
  34. * FIRMessagingAuthService is responsible for retrieving, caching, and supplying checkin info
  35. * for the rest of Instance ID. A checkin can be scheduled, meaning that it will keep retrying the
  36. * checkin request until it is successful. A checkin can also be requested directly, with a
  37. * completion handler.
  38. */
  39. @interface FIRMessagingAuthService : NSObject
  40. #pragma mark - Checkin Service
  41. - (BOOL)hasCheckinPlist;
  42. /**
  43. * Checks if the current deviceID and secret are valid or not.
  44. *
  45. * @return YES if the checkin credentials are valid else NO.
  46. */
  47. - (BOOL)hasValidCheckinInfo;
  48. /**
  49. * Fetch checkin info from the server. This would usually refresh the existing
  50. * checkin credentials for the current app.
  51. *
  52. * @param handler The completion handler to invoke once the checkin info has been
  53. * refreshed.
  54. */
  55. - (void)fetchCheckinInfoWithHandler:(nullable FIRMessagingDeviceCheckinCompletion)handler;
  56. /**
  57. * Schedule checkin. Will hit the network only if the currently loaded checkin
  58. * preferences are stale.
  59. *
  60. * @param immediately YES if we want it to be scheduled immediately else NO.
  61. */
  62. - (void)scheduleCheckin:(BOOL)immediately;
  63. /**
  64. * Returns the checkin preferences currently loaded in memory. The Checkin preferences
  65. * can be either valid or invalid.
  66. *
  67. * @return The checkin preferences loaded in memory.
  68. */
  69. - (FIRMessagingCheckinPreferences *)checkinPreferences;
  70. /**
  71. * Cancels any ongoing checkin fetch, if any.
  72. */
  73. - (void)stopCheckinRequest;
  74. /**
  75. * Resets the checkin information.
  76. *
  77. * @param handler The callback handler which is invoked when checkin reset is complete,
  78. * with an error if there is any.
  79. */
  80. - (void)resetCheckinWithHandler:(void (^)(NSError *error))handler;
  81. @end
  82. NS_ASSUME_NONNULL_END