Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@
import Foundation
import GameKit

// TODO: Delete this when minimum iOS version passes 13.5.
/// WarningWorkaround is needed because playerID is deprecated in iOS 13.0 but still needed until
/// 13.5 when the fetchItems API was introduced.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
private protocol WarningWorkaround {
static func pre135Credential(localPlayer: GKLocalPlayer,
completion: @escaping (AuthCredential?, Error?) -> Void)
}

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
extension GameCenterAuthProvider: WarningWorkaround {}

/// A concrete implementation of `AuthProvider` for Game Center Sign In. Not available on watchOS.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRGameCenterAuthProvider) open class GameCenterAuthProvider: NSObject {
Expand All @@ -53,60 +41,23 @@
return
}

if #available(iOS 13.5, macOS 10.15.5, macCatalyst 13.5, tvOS 13.4.8, *) {
localPlayer.fetchItems { publicKeyURL, signature, salt, timestamp, error in
if let error = error {
completion(nil, error)
} else {
let credential = GameCenterAuthCredential(withPlayerID: "",
teamPlayerID: localPlayer.teamPlayerID,
gamePlayerID: localPlayer.gamePlayerID,
publicKeyURL: publicKeyURL,
signature: signature,
salt: salt,
timestamp: timestamp,
displayName: localPlayer.displayName)
completion(credential, nil)
}
localPlayer.fetchItems { publicKeyURL, signature, salt, timestamp, error in

Check failure on line 44 in FirebaseAuth/Sources/Swift/AuthProvider/GameCenterAuthProvider.swift

View workflow job for this annotation

GitHub Actions / spm / spm (macos-26, Xcode_26.4, macOS)

'fetchItems(forIdentityVerificationSignature:)' is only available in macOS 10.15.5 or newer

Check failure on line 44 in FirebaseAuth/Sources/Swift/AuthProvider/GameCenterAuthProvider.swift

View workflow job for this annotation

GitHub Actions / spm / spm (macos-26, Xcode_26.4, macOS)

'fetchItems(forIdentityVerificationSignature:)' is only available in macOS 10.15.5 or newer

Check failure on line 44 in FirebaseAuth/Sources/Swift/AuthProvider/GameCenterAuthProvider.swift

View workflow job for this annotation

GitHub Actions / spm / spm (macos-26, Xcode_26.4, macOS)

'fetchItems(forIdentityVerificationSignature:)' is only available in macOS 10.15.5 or newer

Check failure on line 44 in FirebaseAuth/Sources/Swift/AuthProvider/GameCenterAuthProvider.swift

View workflow job for this annotation

GitHub Actions / spm / spm (macos-15, Xcode_26.2, macOS)

'fetchItems(forIdentityVerificationSignature:)' is only available in macOS 10.15.5 or newer

Check failure on line 44 in FirebaseAuth/Sources/Swift/AuthProvider/GameCenterAuthProvider.swift

View workflow job for this annotation

GitHub Actions / spm / spm (macos-15, Xcode_26.2, macOS)

'fetchItems(forIdentityVerificationSignature:)' is only available in macOS 10.15.5 or newer

Check failure on line 44 in FirebaseAuth/Sources/Swift/AuthProvider/GameCenterAuthProvider.swift

View workflow job for this annotation

GitHub Actions / spm / spm (macos-15, Xcode_26.2, macOS)

'fetchItems(forIdentityVerificationSignature:)' is only available in macOS 10.15.5 or newer
if let error = error {
completion(nil, error)
} else {
let credential = GameCenterAuthCredential(withPlayerID: "",
teamPlayerID: localPlayer.teamPlayerID,
gamePlayerID: localPlayer.gamePlayerID,
publicKeyURL: publicKeyURL,
signature: signature,
salt: salt,
timestamp: timestamp,
displayName: localPlayer.displayName)
completion(credential, nil)
}
} else {
(GameCenterAuthProvider.self as WarningWorkaround.Type).pre135Credential(
localPlayer: localPlayer, completion: completion
)
}
}

@available(iOS, deprecated: 13.0)
@available(tvOS, deprecated: 13.0)
@available(macOS, deprecated: 10.15.0)
@available(macCatalyst, deprecated: 13.0)
fileprivate class func pre135Credential(localPlayer: GKLocalPlayer,
completion: @escaping (AuthCredential?, Error?)
-> Void) {
localPlayer
.generateIdentityVerificationSignature { publicKeyURL, signature, salt, timestamp, error in
if error != nil {
completion(nil, error)
} else {
/**
`localPlayer.alias` is actually the displayname needed, instead of
`localPlayer.displayname`. For more information, check
https://developer.apple.com/documentation/gamekit/gkplayer
**/
let displayName = localPlayer.alias
let credential = GameCenterAuthCredential(withPlayerID: localPlayer.playerID,
teamPlayerID: nil,
gamePlayerID: nil,
publicKeyURL: publicKeyURL,
signature: signature,
salt: salt,
timestamp: timestamp,
displayName: displayName)
completion(credential, nil)
}
}
}

/// Creates an `AuthCredential` for a Game Center sign in.
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 8, *)
open class func getCredential() async throws -> AuthCredential {
Expand All @@ -115,7 +66,7 @@
if let credential = credential {
continuation.resume(returning: credential)
} else {
continuation.resume(throwing: error!) // TODO: Change to ?? and generate unknown error
continuation.resume(throwing: error ?? AuthErrorUtils.error(code: .internalError))
}
}
}
Expand Down
Loading