authenticateGameCenter method

  1. @override
Future<Session> authenticateGameCenter({
  1. required String playerId,
  2. required String bundleId,
  3. required int timestampSeconds,
  4. required String salt,
  5. required String signature,
  6. required String publicKeyUrl,
  7. bool create = true,
  8. String? username,
  9. Map<String, String>? vars,
})
override

Implementation

@override
Future<model.Session> authenticateGameCenter({
  required String playerId,
  required String bundleId,
  required int timestampSeconds,
  required String salt,
  required String signature,
  required String publicKeyUrl,
  bool create = true,
  String? username,
  Map<String, String>? vars,
}) async {
  final res = await _api.nakamaAuthenticateGameCenter(
    body: ApiAccountGameCenter(
      playerId: playerId,
      bundleId: bundleId,
      timestampSeconds: timestampSeconds.toString(),
      salt: salt,
      signature: signature,
      publicKeyUrl: publicKeyUrl,
      vars: vars,
    ),
    create: create,
    username: username,
  );

  if (res.body == null) {
    throw Exception('Authentication failed.');
  }

  final data = res.body!;

  return model.Session(
    created: data.created ?? false,
    token: data.token!,
    refreshToken: data.refreshToken,
  );
}