IOSClient.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // <copyright file="IOSClient.cs" company="Google Inc.">
  2. // Copyright (C) 2015 Google Inc.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. // </copyright>
  16. #if (UNITY_IPHONE && !NO_GPGS)
  17. namespace GooglePlayGames.IOS
  18. {
  19. using System;
  20. using GooglePlayGames.BasicApi;
  21. using GooglePlayGames.Native.PInvoke;
  22. using UnityEngine;
  23. internal class IOSClient : IClientImpl
  24. {
  25. [System.Runtime.InteropServices.DllImport("__Internal")]
  26. static extern void _GooglePlayEnableProfileScope();
  27. public PlatformConfiguration CreatePlatformConfiguration()
  28. {
  29. if (!GameInfo.IosClientIdInitialized())
  30. {
  31. throw new InvalidOperationException("Could not locate the OAuth Client ID, " +
  32. "provide this by navigating to Google Play Games > iOS Setup");
  33. }
  34. if (GameInfo.WebClientIdInitialized())
  35. {
  36. _GooglePlayEnableProfileScope();
  37. }
  38. var config = IosPlatformConfiguration.Create();
  39. config.SetClientId(GameInfo.IosClientId);
  40. return config;
  41. }
  42. public PlatformConfiguration CreatePlatformConfiguration(PlayGamesClientConfiguration clientConfig)
  43. {
  44. return CreatePlatformConfiguration();
  45. }
  46. public TokenClient CreateTokenClient(bool reset)
  47. {
  48. return new IOSTokenClient();
  49. }
  50. /// <summary>
  51. /// Creates the token client.
  52. /// </summary>
  53. /// <returns>The token client.</returns>
  54. /// <param name="playerId">not used for iOS</param>
  55. /// <param name="reset">not used for iOS</param>
  56. public TokenClient CreateTokenClient(string playerId, bool reset)
  57. {
  58. return new IOSTokenClient();
  59. }
  60. public void GetPlayerStats(IntPtr apiClientPtr,
  61. Action<CommonStatusCodes, PlayerStats> callback) {
  62. throw new InvalidOperationException(
  63. "The native API should be called for iOS");
  64. }
  65. public void SetGravityForPopups(IntPtr apiClient, Gravity gravity) {
  66. throw new NotImplementedException();
  67. }
  68. }
  69. }
  70. #endif