:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/../../GodotApplePlugins/doc_classes/GKLocalPlayer.xml. .. _class_GKLocalPlayer: GKLocalPlayer ============= **Inherits:** :ref:`GKPlayer` **<** :ref:`RefCounted` **<** :ref:`Object` Represents the signed-in Game Center player and exposes local-only APIs. .. rst-class:: classref-introduction-group Description ----------- Use ``GKLocalPlayer`` to inspect authentication flags and to fetch the local player's friends as shown in the "Players" section of ``GameCenterGuide.md``. Every asynchronous call mirrors Apple's API and invokes your ``Callable`` with the requested data plus an optional error ``Variant``. Refer to Apple's documentation at `Apple's GKLocalPlayer reference `__ for platform-specific behavior. Sample from the guide that fetches the local player when your scene loads: .. tabs:: .. code-tab:: gdscript var game_center: GameCenterManager var local: GKLocalPlayer func _ready() -> void: game_center = GameCenterManager.new() local = game_center.local_player print("ONREADY: local, is auth: %s" % local.is_authenticated) print("ONREADY: local, player ID: %s" % local.game_player_id) Friends-related helpers mirror the snippets in the guide (assuming you stored the player reference in ``local``): .. tabs:: .. code-tab:: gdscript # Loads the local player's friends list if access is granted. local.load_friends(func(friends: Array[GKPlayer], error: Variant) -> void: if error: print(error) else: for friend in friends: print(friend.display_name) ) # Loads players the local user can challenge. local.load_challengeable_friends(func(friends: Array[GKPlayer], error: Variant) -> void: if error: print(error) else: for friend in friends: print(friend.display_name) ) # Loads the friends or recent players list. local.load_recent_friends(func(friends: Array[GKPlayer], error: Variant) -> void: if error: print(error) else: for friend in friends: print(friend.display_name) ) .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +-------------------------+------------------------------------------------------------------------------------------------------------------------+-----------+ | :ref:`bool` | :ref:`is_authenticated` | ``false`` | +-------------------------+------------------------------------------------------------------------------------------------------------------------+-----------+ | :ref:`bool` | :ref:`is_multiplayer_gaming_restricted` | ``true`` | +-------------------------+------------------------------------------------------------------------------------------------------------------------+-----------+ | :ref:`bool` | :ref:`is_personalized_communication_restricted` | ``true`` | +-------------------------+------------------------------------------------------------------------------------------------------------------------+-----------+ | :ref:`bool` | :ref:`is_underage` | ``false`` | +-------------------------+------------------------------------------------------------------------------------------------------------------------+-----------+ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`delete_saved_games`\ (\ named\: :ref:`String`, callback\: :ref:`Callable`\ ) | +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`fetch_items_for_identity_verification_signature`\ (\ callback\: :ref:`Callable`\ ) | +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`fetch_saved_games`\ (\ callback\: :ref:`Callable`\ ) | +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`load_challengeable_friends`\ (\ callback\: :ref:`Callable`\ ) | +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`load_friends`\ (\ callback\: :ref:`Callable`\ ) | +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`load_recent_friends`\ (\ callback\: :ref:`Callable`\ ) | +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`save_game_data`\ (\ data\: :ref:`PackedByteArray`, withName\: :ref:`String`, callback\: :ref:`Callable`\ ) | +--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_GKLocalPlayer_property_is_authenticated: .. rst-class:: classref-property :ref:`bool` **is_authenticated** = ``false`` :ref:`🔗` .. rst-class:: classref-property-setget - :ref:`bool` **get_is_authenticated**\ (\ ) Reflects ``GKLocalPlayer.local.isAuthenticated``. .. rst-class:: classref-item-separator ---- .. _class_GKLocalPlayer_property_is_multiplayer_gaming_restricted: .. rst-class:: classref-property :ref:`bool` **is_multiplayer_gaming_restricted** = ``true`` :ref:`🔗` .. rst-class:: classref-property-setget - :ref:`bool` **get_is_multiplayer_gaming_restricted**\ (\ ) True when multiplayer is disabled by parental controls. .. rst-class:: classref-item-separator ---- .. _class_GKLocalPlayer_property_is_personalized_communication_restricted: .. rst-class:: classref-property :ref:`bool` **is_personalized_communication_restricted** = ``true`` :ref:`🔗` .. rst-class:: classref-property-setget - :ref:`bool` **get_is_personalized_communication_restricted**\ (\ ) Indicates whether personalized communication is blocked for this account. .. rst-class:: classref-item-separator ---- .. _class_GKLocalPlayer_property_is_underage: .. rst-class:: classref-property :ref:`bool` **is_underage** = ``false`` :ref:`🔗` .. rst-class:: classref-property-setget - :ref:`bool` **get_is_underage**\ (\ ) Apple's ``isUnderage`` flag for COPPA-compliant flows. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_GKLocalPlayer_method_delete_saved_games: .. rst-class:: classref-method |void| **delete_saved_games**\ (\ named\: :ref:`String`, callback\: :ref:`Callable`\ ) :ref:`🔗` .. container:: contribute There is currently no description for this method. Please help us by `contributing one `__! .. rst-class:: classref-item-separator ---- .. _class_GKLocalPlayer_method_fetch_items_for_identity_verification_signature: .. rst-class:: classref-method |void| **fetch_items_for_identity_verification_signature**\ (\ callback\: :ref:`Callable`\ ) :ref:`🔗` Calls Apple's ``fetchItems`` helper for server-side authentication. The callback receives ``(Dictionary data, Variant error)``. The dictionary contains the ``url``, ``data``, ``salt``, and ``timestamp`` keys described in the inline Swift documentation, letting your backend verify the player's identity. .. rst-class:: classref-item-separator ---- .. _class_GKLocalPlayer_method_fetch_saved_games: .. rst-class:: classref-method |void| **fetch_saved_games**\ (\ callback\: :ref:`Callable`\ ) :ref:`🔗` Use this API to retrieve the list of saved games, upon completion, this method invokes the provided callback with both an array of GKSavedGame objects and a variant error, if not nil it contains a string describing the problem. .. rst-class:: classref-item-separator ---- .. _class_GKLocalPlayer_method_load_challengeable_friends: .. rst-class:: classref-method |void| **load_challengeable_friends**\ (\ callback\: :ref:`Callable`\ ) :ref:`🔗` Loads players whom the local user can challenge. The callback receives ``(Array[GKPlayer] friends, Variant error)`` where either argument can be ``null``. .. rst-class:: classref-item-separator ---- .. _class_GKLocalPlayer_method_load_friends: .. rst-class:: classref-method |void| **load_friends**\ (\ callback\: :ref:`Callable`\ ) :ref:`🔗` Fetches the friends list. The callback receives ``(Array[GKPlayer] friends, Variant error)``; a non-null error ``Variant`` holds the localized error string. .. rst-class:: classref-item-separator ---- .. _class_GKLocalPlayer_method_load_recent_friends: .. rst-class:: classref-method |void| **load_recent_friends**\ (\ callback\: :ref:`Callable`\ ) :ref:`🔗` Loads friends that recently played together with the local player. The callback signature matches :ref:`load_challengeable_friends()`. .. rst-class:: classref-item-separator ---- .. _class_GKLocalPlayer_method_save_game_data: .. rst-class:: classref-method |void| **save_game_data**\ (\ data\: :ref:`PackedByteArray`, withName\: :ref:`String`, callback\: :ref:`Callable`\ ) :ref:`🔗` Saves the packed byte array as the game data with the specified name, upon completion the callback is invoked with both a GKSavedObject parameter and a Variant parameter for the error. The GKSavedObject is not-nil on success, and on error, the second parameter is not-nil and contains the error message. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`