## apple_game_center

Integration with the https://developer.apple.com/game-center/[Apple Game Center].

To use this, you will need to configure your application integration with _Game Center_ on the Apple websites:

* Login to https://developer.apple.com/ and create your App ID (if not created already) using the `qualified_name` like `io.castleengine.castlespine`.
* Add _Game Center_ feature to your App ID (see the screenshot below):
+
image::https://castle-engine.io/images/thumb_size/app_id_gamekit.png[Add GameKit to App Id,link=https://castle-engine.io/images/original_size/app_id_gamekit.png]

* Login to https://itunesconnect.apple.com/ and configure the achievements, leaderboars in the _Game Center_ section of _iTunes Connect_. https://developer.apple.com/library/content/documentation/LanguagesUtilities/Conceptual/iTunesConnectGameCenter_Guide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40013726[See the Apple documentation for the details].

Then from your Pascal code, you can use `TGameService` class from the `CastleGameService` unit to send achievements and more using the _Apple Game Center_. See the https://github.com/castle-engine/castle-engine/tree/master/examples/mobile/game_services[examples/mobile/game_services] example, in particular the code inside https://github.com/castle-engine/castle-engine/blob/master/examples/mobile/game_services/code/gameids.pas[code/gameids.pas] and https://github.com/castle-engine/castle-engine/blob/master/examples/mobile/game_services/code/gameviewplay.pas[code/gameviewplay.pas].

*Savegames in the cloud* work too. Use simple methods `TGameService.SaveGameSave`, `TGameService.SaveGameLoad` from Pascal code. Notes:

* User must be logged into the iCloud, and have _iCloud Drive_ enabled, https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/GameKit_Guide/SavedGames/SavedGames.html[see Apple documentation].
* You must enable iCloud for your App ID in your https://developer.apple.com/ account.
* You need to use an additional service `icloud_for_save_games`. In effect, in the application settings in Xcode, you should see that the _iCloud_ is active, with _iCloud Documents_ selected. Like on the screenshot below. (_You should not need to adjust them, the generated Xcode project should be already correct. The screenshot is only to allow you to make sure._)
+
image::https://castle-engine.io/images/thumb_size/xcode_icloud_settings.png[Xcode iCloud Settings for Apple Game Center with savegames,link=https://castle-engine.io/images/original_size/xcode_icloud_settings.png]
