Firebase 和 Xcode12 API 已弃用,使用 fetchItemsForIdentityVerificationSignature:
Firebase and Xcode12 API deprecated, Use fetchItemsForIdentityVerificationSignature:
我尝试将 Firebase 与 Xcode 12 一起使用,但在安装和 运行 项目后我遇到了这个警告。
'generateIdentityVerificationSignatureWithCompletionHandler:' 已弃用:首先在 iOS 13.5 中弃用 - API 已弃用。使用 fetchItemsForIdentityVerificationSignature: 和 teamPlayerID 值来验证用户身份。
知道如何解决这个问题吗?
这里是代码:
+ (void)getCredentialWithCompletion:(FIRGameCenterCredentialCallback)completion {
/**
Linking GameKit.framework without using it on macOS results in App Store rejection.
Thus we don't link GameKit.framework to our SDK directly. `optionalLocalPlayer` is used for
checking whether the APP that consuming our SDK has linked GameKit.framework. If not, a
`GameKitNotLinkedError` will be raised.
**/
GKLocalPlayer *_Nullable optionalLocalPlayer = [[NSClassFromString(@"GKLocalPlayer") alloc] init];
if (!optionalLocalPlayer) {
if (completion) {
completion(nil, [FIRAuthErrorUtils gameKitNotLinkedError]);
}
return;
}
__weak GKLocalPlayer *localPlayer = [[optionalLocalPlayer class] localPlayer];
if (!localPlayer.isAuthenticated) {
if (completion) {
completion(nil, [FIRAuthErrorUtils localPlayerNotAuthenticatedError]);
}
return;
}
[localPlayer generateIdentityVerificationSignatureWithCompletionHandler:^(
NSURL *publicKeyURL, NSData *signature, NSData *salt, uint64_t timestamp,
NSError *error) {
if (error) {
if (completion) {
completion(nil, error);
}
} else {
if (completion) {
/**
@c `localPlayer.alias` is actually the displayname needed, instead of
`localPlayer.displayname`. For more information, check
https://developer.apple.com/documentation/gamekit/gkplayer
**/
NSString *displayName = localPlayer.alias;
// iOS 13 deprecation
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
FIRGameCenterAuthCredential *credential =
[[FIRGameCenterAuthCredential alloc] initWithPlayerID:localPlayer.playerID
publicKeyURL:publicKeyURL
signature:signature
salt:salt
timestamp:timestamp
displayName:displayName];
#pragma clang diagnostic pop
completion(credential, nil);
}
}
}];
}
我目前也在一个使用 firebase 并使用类似代码的项目中。由于 swift 5.3 刚刚发布,API 也需要一段时间才能更新。如果您的项目 运行 符合预期,请不要担心警告,因为您的代码仍会编译并希望 运行。您可以在 https://firebase.google.com/support/release-notes/ios 处检查 API 的更新,一旦它在终端中更新 运行 “pod update”(就像您安装它们时一样),它就会解决问题。这是更新 swift 时发生的问题。
这是为我做的:)
[localPlayer
fetchItemsForIdentityVerificationSignature:^(NSURL *publicKeyURL, NSData *signature, NSData *salt, uint64_t timestamp, NSError *error) {
if (error) {
if (completion) {
completion(nil, error);
}
} else {
if (completion) {
/**
@c `localPlayer.alias` is actually the displayname needed, instead of
`localPlayer.displayname`. For more information, check
https://developer.apple.com/documentation/gamekit/gkplayer
**/
NSString *displayName = localPlayer.alias;
// iOS 13 deprecation
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
FIRGameCenterAuthCredential *credential =
[[FIRGameCenterAuthCredential alloc] initWithPlayerID:localPlayer.playerID
publicKeyURL:publicKeyURL
signature:signature
salt:salt
timestamp:timestamp
displayName:displayName];
#pragma clang diagnostic pop
completion(credential, nil);
}
}
}];
}
我尝试将 Firebase 与 Xcode 12 一起使用,但在安装和 运行 项目后我遇到了这个警告。
'generateIdentityVerificationSignatureWithCompletionHandler:' 已弃用:首先在 iOS 13.5 中弃用 - API 已弃用。使用 fetchItemsForIdentityVerificationSignature: 和 teamPlayerID 值来验证用户身份。
知道如何解决这个问题吗?
这里是代码:
+ (void)getCredentialWithCompletion:(FIRGameCenterCredentialCallback)completion {
/**
Linking GameKit.framework without using it on macOS results in App Store rejection.
Thus we don't link GameKit.framework to our SDK directly. `optionalLocalPlayer` is used for
checking whether the APP that consuming our SDK has linked GameKit.framework. If not, a
`GameKitNotLinkedError` will be raised.
**/
GKLocalPlayer *_Nullable optionalLocalPlayer = [[NSClassFromString(@"GKLocalPlayer") alloc] init];
if (!optionalLocalPlayer) {
if (completion) {
completion(nil, [FIRAuthErrorUtils gameKitNotLinkedError]);
}
return;
}
__weak GKLocalPlayer *localPlayer = [[optionalLocalPlayer class] localPlayer];
if (!localPlayer.isAuthenticated) {
if (completion) {
completion(nil, [FIRAuthErrorUtils localPlayerNotAuthenticatedError]);
}
return;
}
[localPlayer generateIdentityVerificationSignatureWithCompletionHandler:^(
NSURL *publicKeyURL, NSData *signature, NSData *salt, uint64_t timestamp,
NSError *error) {
if (error) {
if (completion) {
completion(nil, error);
}
} else {
if (completion) {
/**
@c `localPlayer.alias` is actually the displayname needed, instead of
`localPlayer.displayname`. For more information, check
https://developer.apple.com/documentation/gamekit/gkplayer
**/
NSString *displayName = localPlayer.alias;
// iOS 13 deprecation
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
FIRGameCenterAuthCredential *credential =
[[FIRGameCenterAuthCredential alloc] initWithPlayerID:localPlayer.playerID
publicKeyURL:publicKeyURL
signature:signature
salt:salt
timestamp:timestamp
displayName:displayName];
#pragma clang diagnostic pop
completion(credential, nil);
}
}
}];
}
我目前也在一个使用 firebase 并使用类似代码的项目中。由于 swift 5.3 刚刚发布,API 也需要一段时间才能更新。如果您的项目 运行 符合预期,请不要担心警告,因为您的代码仍会编译并希望 运行。您可以在 https://firebase.google.com/support/release-notes/ios 处检查 API 的更新,一旦它在终端中更新 运行 “pod update”(就像您安装它们时一样),它就会解决问题。这是更新 swift 时发生的问题。
这是为我做的:)
[localPlayer
fetchItemsForIdentityVerificationSignature:^(NSURL *publicKeyURL, NSData *signature, NSData *salt, uint64_t timestamp, NSError *error) {
if (error) {
if (completion) {
completion(nil, error);
}
} else {
if (completion) {
/**
@c `localPlayer.alias` is actually the displayname needed, instead of
`localPlayer.displayname`. For more information, check
https://developer.apple.com/documentation/gamekit/gkplayer
**/
NSString *displayName = localPlayer.alias;
// iOS 13 deprecation
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
FIRGameCenterAuthCredential *credential =
[[FIRGameCenterAuthCredential alloc] initWithPlayerID:localPlayer.playerID
publicKeyURL:publicKeyURL
signature:signature
salt:salt
timestamp:timestamp
displayName:displayName];
#pragma clang diagnostic pop
completion(credential, nil);
}
}
}];
}