FIRHeartbeatLogger.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright 2021 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import <Foundation/Foundation.h>
  15. // TODO: Remove in future PR when `FIRHeartbeatInfo` symbol is removed.
  16. #import "FIRHeartbeatInfo.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. @class FIRHeartbeatsPayload;
  19. /// Returns a nullable string header value from a given heartbeats payload.
  20. ///
  21. /// This API returns `nil` when the given heartbeats payload is considered empty.
  22. ///
  23. /// @param heartbeatsPayload The heartbeats payload.
  24. NSString *_Nullable FIRHeaderValueFromHeartbeatsPayload(FIRHeartbeatsPayload *heartbeatsPayload);
  25. /// A thread safe, synchronized object that logs and flushes platform logging info.
  26. @interface FIRHeartbeatLogger : NSObject
  27. // TODO: Decide how clients get an instance.
  28. - (instancetype)initWithAppID:(NSString *)appID;
  29. /// Asynchronously logs a new heartbeat corresponding to the Firebase User Agent, if needed.
  30. ///
  31. /// @note This API is thread-safe.
  32. - (void)log;
  33. /// Flushes heartbeats from storage into a structured payload of heartbeats.
  34. ///
  35. /// This API is for clients using platform logging V2.
  36. ///
  37. /// @note This API is thread-safe.
  38. /// @return A payload of heartbeats.
  39. - (FIRHeartbeatsPayload *)flushHeartbeatsIntoPayload;
  40. /// Gets the corresponding heartbeat code for the current heartbeat storage state.
  41. ///
  42. /// This API is for clients using platform logging V1.
  43. ///
  44. /// @note This API is thread-safe.
  45. /// @return Heartbeat code indicating whether or not there is an unsent global heartbeat.
  46. - (FIRHeartbeatInfoCode)heartbeatCode;
  47. @end
  48. NS_ASSUME_NONNULL_END