Skip to content

Commit

Permalink
Remove optional protocol method, mark sync headerValue unavailable in…
Browse files Browse the repository at this point in the history
… Swift
  • Loading branch information
ncooke3 committed Oct 9, 2024
1 parent a44d799 commit d2b64ab
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion FirebaseAuth/Sources/Swift/Backend/AuthBackend.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class AuthBackend {
contentType: String,
requestConfiguration: AuthRequestConfiguration) async -> URLRequest {
// Kick off tasks for the async header values.
async let heartbeatsHeaderValue = requestConfiguration.heartbeatLogger?.asyncHeaderValue!()
async let heartbeatsHeaderValue = requestConfiguration.heartbeatLogger?.asyncHeaderValue()
async let appCheckTokenHeaderValue = requestConfiguration.appCheck?
.getToken(forcingRefresh: true)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,10 +535,6 @@ class AuthBackendRPCImplementationTests: RPCBaseTests {
#if COCOAPODS || SWIFT_PACKAGE
private class FakeHeartbeatLogger: NSObject, FIRHeartbeatLoggerProtocol {
func asyncHeaderValue() async -> String? {
headerValue()
}

func headerValue() -> String? {
let payload = flushHeartbeatsIntoPayload()
guard !payload.isEmpty else {
return nil
Expand Down
8 changes: 4 additions & 4 deletions FirebaseCore/Extension/FIRHeartbeatLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ typedef NS_ENUM(NSInteger, FIRDailyHeartbeatCode) {
- (FIRDailyHeartbeatCode)heartbeatCodeForToday;

#ifndef FIREBASE_BUILD_CMAKE
/// Return the header value for the heartbeat logger.
- (NSString *_Nullable)headerValue;

@optional
/// Returns the header value for the heartbeat logger via the given completion handler..
- (void)asyncHeaderValueWithCompletionHandler:(void (^)(NSString *_Nullable))completionHandler
API_AVAILABLE(ios(13.0), macosx(10.15), macCatalyst(13.0), tvos(13.0), watchos(6.0));

/// Return the header value for the heartbeat logger.
- (NSString *_Nullable)
headerValue NS_SWIFT_UNAVAILABLE("Use `asyncHeaderValue() async -> String?` instead.");
#endif // FIREBASE_BUILD_CMAKE

@end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ - (NSString *_Nullable)headerValue {
return FIRHeaderValueFromHeartbeatsPayload([self flushHeartbeatsIntoPayload]);
}

- (void)asyncHeaderValueWithCompletionHandler:
(nonnull void (^)(NSString *_Nullable))completionHandler {
[self doesNotRecognizeSelector:_cmd];
}

@end

#pragma mark - FIRInstallationsAPIService + Internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ - (NSString *_Nullable)headerValue {
return @"unimplemented";
}

- (void)asyncHeaderValueWithCompletionHandler:
(nonnull void (^)(NSString *_Nullable))completionHandler {
[self doesNotRecognizeSelector:_cmd];
}

@end

#pragma mark - FIRMessagingTokenOperationsTest
Expand Down

0 comments on commit d2b64ab

Please sign in to comment.