如何解决不推荐使用Firebase和Xcode12 API,请使用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);
}
}
}];
}
解决方法
这对我有用:)
[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并使用类似代码的项目中。由于swift 5.3刚刚发布,因此还需要一些时间来更新API。如果您的项目按预期运行,请不要担心警告,因为您的代码仍会编译并有望运行。您可以在https://firebase.google.com/support/release-notes/ios处检查API的更新,更新后在终端中运行“ pod update”(就像安装它们时一样),它将解决此问题。这是在更新swift时发生的问题。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。