0

I'm try to use Firebase with Xcode 12, but I'm facing this warning after install and run the project.

'generateIdentityVerificationSignatureWithCompletionHandler:' is deprecated: first deprecated in iOS 13.5 - API deprecated. Use fetchItemsForIdentityVerificationSignature: and the teamPlayerID value to verify a user identity.

any idea how I can fix this issue?

warning

here the code:


+ (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);
      }
    }
  }];
}

Damiano Miazzi
  • 1,514
  • 1
  • 16
  • 38

2 Answers2

1

This did it for me :)

[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);
      }
    }
  }];
}
David
  • 333
  • 1
  • 2
  • 14
  • Curious how you're getting Firebase to work with no `App Delegate`. – David Sep 19 '20 at 07:05
  • 2
    Nevermind. Good ol' Paul. https://www.hackingwithswift.com/quick-start/swiftui/how-to-add-an-appdelegate-to-a-swiftui-app – David Sep 19 '20 at 07:10
0

I am currently also in the middle of a project that uses firebase and use similar code. Since swift 5.3 just released it will take sometime for the API's to be update as well. If your project runs as expected don't worry about a warning since your code will still compile and hopefully run. You can check for updates to the API here https://firebase.google.com/support/release-notes/ios, and once its updated run "pod update" in the terminal(just like when you installed them) and it will resolve the issue. This is an issue that happened when swift is updated.

Lucas Dahl
  • 722
  • 1
  • 5
  • 20