{"id":29194629,"url":"https://github.com/rouic/expo-game-center","last_synced_at":"2025-10-07T06:37:26.731Z","repository":{"id":299654314,"uuid":"1003734909","full_name":"Rouic/expo-game-center","owner":"Rouic","description":"A custom Expo module for integrating Game Center","archived":false,"fork":false,"pushed_at":"2025-06-18T09:18:44.000Z","size":404,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-04T22:08:30.811Z","etag":null,"topics":["expo","gamecenter","ios","react-native"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/expo-game-center","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rouic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-17T15:29:59.000Z","updated_at":"2025-06-18T09:22:02.000Z","dependencies_parsed_at":"2025-06-17T16:55:13.893Z","dependency_job_id":null,"html_url":"https://github.com/Rouic/expo-game-center","commit_stats":null,"previous_names":["rouic/expo-game-center"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Rouic/expo-game-center","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rouic%2Fexpo-game-center","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rouic%2Fexpo-game-center/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rouic%2Fexpo-game-center/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rouic%2Fexpo-game-center/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rouic","download_url":"https://codeload.github.com/Rouic/expo-game-center/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rouic%2Fexpo-game-center/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278734381,"owners_count":26036402,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["expo","gamecenter","ios","react-native"],"created_at":"2025-07-02T04:05:57.039Z","updated_at":"2025-10-07T06:37:26.692Z","avatar_url":"https://github.com/Rouic.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# expo-game-center\n\nA comprehensive Expo module for iOS Game Center integration, providing authentication, leaderboards, achievements, and native UI presentation.\n\n## Features\n\n- 🎮 **Game Center Authentication** - Seamlessly authenticate players with Game Center\n- 👤 **Player Information** - Retrieve authenticated player details and profile images  \n- 🏆 **Leaderboards** - Submit scores and present leaderboard interfaces\n- 🎯 **Achievements** - Report achievement progress with native completion banners\n- 📱 **Native UI** - Present Game Center's native user interfaces\n- 🔧 **Development Support** - Mock implementations for Expo Go and simulators\n- 📦 **TypeScript Support** - Full TypeScript definitions included\n- ⚡ **Auto Configuration** - Automatic Game Center entitlements via Expo config plugin\n\n## Installation\n\n```bash\nnpm install expo-game-center\n```\n\nor \n\n```bash\nyarn add expo-game-center\n```\n\n## Configuration\n\n### Automatic Configuration (Recommended)\n\nThe module includes an Expo config plugin that automatically configures Game Center entitlements for you.\n\nAdd the plugin to your `app.json` or `app.config.js`:\n\n```json\n{\n  \"expo\": {\n    \"plugins\": [\n      \"expo-game-center\"\n    ]\n  }\n}\n```\n\n### Manual Configuration\n\nIf you prefer manual configuration or need custom settings, add the Game Center entitlement to your `app.json`:\n\n```json\n{\n  \"expo\": {\n    \"ios\": {\n      \"entitlements\": {\n        \"com.apple.developer.game-center\": true\n      }\n    }\n  }\n}\n```\n\n## Usage\n\n### Quick Start with React Hook (Recommended)\n\n```typescript\nimport React from 'react';\nimport { View, Text, Button } from 'react-native';\nimport { useGameCenter } from 'expo-game-center';\n\nexport function GameScreen() {\n  const {\n    isReady,\n    isLoading,\n    player,\n    authenticate,\n    submitScore,\n    showLeaderboard,\n  } = useGameCenter({\n    leaderboards: {\n      'high_scores': 'your_leaderboard_id',\n    },\n    achievements: {\n      'first_win': 'your_achievement_id',\n    },\n    autoInitialize: true,\n  });\n\n  if (isLoading) {\n    return \u003cText\u003eLoading GameCenter...\u003c/Text\u003e;\n  }\n\n  return (\n    \u003cView\u003e\n      {isReady ? (\n        \u003cView\u003e\n          \u003cText\u003eWelcome, {player?.displayName}!\u003c/Text\u003e\n          \u003cButton \n            title=\"Submit Score\" \n            onPress={() =\u003e submitScore(1000, 'high_scores')} \n          /\u003e\n          \u003cButton \n            title=\"Show Leaderboard\" \n            onPress={() =\u003e showLeaderboard('high_scores')} \n          /\u003e\n        \u003c/View\u003e\n      ) : (\n        \u003cButton title=\"Sign in to GameCenter\" onPress={authenticate} /\u003e\n      )}\n    \u003c/View\u003e\n  );\n}\n```\n\n### Service Layer Approach\n\n```typescript\nimport { GameCenterService } from 'expo-game-center';\n\nconst gameCenterService = new GameCenterService({\n  leaderboards: {\n    'high_scores': 'your_leaderboard_id',\n    'weekly_scores': 'your_weekly_leaderboard_id',\n  },\n  achievements: {\n    'first_win': 'your_first_win_achievement_id',\n    'high_scorer': 'your_high_scorer_achievement_id',\n  },\n  enableLogging: true,\n});\n\n// Initialize and authenticate\nawait gameCenterService.initialize();\nconst authenticated = await gameCenterService.authenticate();\n\n// Submit score and report achievement\nawait gameCenterService.submitScore(9999, 'high_scores');\nawait gameCenterService.reportAchievement('first_win', 100);\n```\n\n### Basic Native Module Usage\n\n```typescript\nimport ExpoGameCenter from 'expo-game-center';\n\n// Check if Game Center is available\nconst isAvailable = await ExpoGameCenter.isGameCenterAvailable();\n\nif (isAvailable) {\n  // Authenticate the player\n  const authenticated = await ExpoGameCenter.authenticateLocalPlayer();\n  \n  if (authenticated) {\n    console.log('Player authenticated successfully!');\n  }\n}\n```\n\n### Player Authentication\n\n```typescript\nimport ExpoGameCenter from 'expo-game-center';\n\nasync function authenticatePlayer() {\n  try {\n    const authenticated = await ExpoGameCenter.authenticateLocalPlayer();\n    \n    if (authenticated) {\n      // Get player information\n      const player = await ExpoGameCenter.getLocalPlayer();\n      console.log('Player:', player);\n      \n      // Get player's profile image\n      const playerImage = await ExpoGameCenter.getPlayerImage();\n      if (playerImage) {\n        // playerImage is a base64-encoded data URI\n        console.log('Player image:', playerImage);\n      }\n    }\n  } catch (error) {\n    console.error('Authentication failed:', error);\n  }\n}\n```\n\n### Leaderboards\n\n```typescript\n// Submit a score\nasync function submitScore(score: number) {\n  try {\n    const success = await ExpoGameCenter.submitScore(score, 'your_leaderboard_id');\n    if (success) {\n      console.log('Score submitted successfully!');\n    }\n  } catch (error) {\n    console.error('Failed to submit score:', error);\n  }\n}\n\n// Present leaderboard UI\nasync function showLeaderboard() {\n  try {\n    await ExpoGameCenter.presentLeaderboard('your_leaderboard_id');\n  } catch (error) {\n    console.error('Failed to show leaderboard:', error);\n  }\n}\n```\n\n### Achievements\n\n```typescript\n// Report achievement progress\nasync function reportAchievement(achievementId: string, progress: number) {\n  try {\n    const success = await ExpoGameCenter.reportAchievement(achievementId, progress);\n    if (success) {\n      console.log('Achievement progress reported!');\n    }\n  } catch (error) {\n    console.error('Failed to report achievement:', error);\n  }\n}\n\n// Show achievements UI\nasync function showAchievements() {\n  try {\n    await ExpoGameCenter.presentAchievements();\n  } catch (error) {\n    console.error('Failed to show achievements:', error);\n  }\n}\n```\n\n### Game Center Dashboard\n\n```typescript\n// Present the main Game Center interface\nasync function showGameCenter() {\n  try {\n    await ExpoGameCenter.presentGameCenterViewController();\n  } catch (error) {\n    console.error('Failed to show Game Center:', error);\n  }\n}\n```\n\n## API Reference\n\n### Types\n\n```typescript\ninterface GameCenterPlayer {\n  playerID: string;     // Unique Game Center player ID\n  displayName: string;  // Player's display name\n  alias: string;        // Player's alias/gamertag\n}\n```\n\n### Methods\n\n#### `isGameCenterAvailable(): Promise\u003cboolean\u003e`\n\nChecks if Game Center is available on the current device.\n\n**Returns:** Promise that resolves to `true` if Game Center is available, `false` otherwise.\n\n#### `authenticateLocalPlayer(): Promise\u003cboolean\u003e`\n\nAuthenticates the local player with Game Center. If the player is not signed in, presents the authentication UI.\n\n**Returns:** Promise that resolves to `true` if authentication was successful, `false` otherwise.\n\n#### `getLocalPlayer(): Promise\u003cGameCenterPlayer | null\u003e`\n\nRetrieves information about the authenticated local player.\n\n**Returns:** Promise that resolves to a `GameCenterPlayer` object or `null` if no player is authenticated.\n\n#### `getPlayerImage(): Promise\u003cstring | null\u003e`\n\nRetrieves the authenticated player's profile image.\n\n**Returns:** Promise that resolves to a base64-encoded data URI string or `null` if no image is available.\n\n#### `submitScore(score: number, leaderboardID: string): Promise\u003cboolean\u003e`\n\nSubmits a score to a specified leaderboard.\n\n**Parameters:**\n- `score`: The score value to submit\n- `leaderboardID`: The identifier of the target leaderboard\n\n**Returns:** Promise that resolves to `true` if the score was submitted successfully, `false` otherwise.\n\n#### `reportAchievement(achievementID: string, percentComplete: number): Promise\u003cboolean\u003e`\n\nReports progress on an achievement.\n\n**Parameters:**\n- `achievementID`: The identifier of the achievement\n- `percentComplete`: Progress percentage (0-100)\n\n**Returns:** Promise that resolves to `true` if the achievement was reported successfully, `false` otherwise.\n\n#### `presentLeaderboard(leaderboardID: string): Promise\u003cvoid\u003e`\n\nPresents the native leaderboard interface for a specific leaderboard.\n\n**Parameters:**\n- `leaderboardID`: The identifier of the leaderboard to display\n\n#### `presentAchievements(): Promise\u003cvoid\u003e`\n\nPresents the native achievements interface.\n\n#### `presentGameCenterViewController(): Promise\u003cvoid\u003e`\n\nPresents the main Game Center interface.\n\n## Platform Support\n\n- ✅ **iOS**: Full native support (iOS 13.0+)\n- ❌ **Android**: Not supported (Game Center is iOS-only)\n- 🔧 **Development**: Mock implementation available for testing\n\n## Development Mode\n\nWhen running in Expo Go or on simulators, the module provides mock implementations that return placeholder data. This allows you to develop and test your Game Center integration without requiring a physical device or Game Center authentication.\n\n## Troubleshooting\n\n### Common Issues\n\n**Game Center not available**\n- Ensure you're testing on a physical iOS device (not simulator)\n- Verify Game Center is enabled in device Settings\n- Check that your app has Game Center entitlements configured\n\n**Authentication fails**\n- Make sure the player is signed into Game Center in Settings\n- Verify your app's bundle identifier matches your Game Center configuration\n- Ensure Game Center is enabled for your app in App Store Connect\n\n**Leaderboards/Achievements not working**\n- Verify leaderboard/achievement IDs match those configured in App Store Connect\n- Ensure your app has been approved for Game Center (for production apps)\n- Check that you're using the correct sandbox/production environment\n\n### Debug Mode\n\nEnable debug logging by setting the `EXPO_GAME_CENTER_DEBUG` environment variable:\n\n```bash\nEXPO_GAME_CENTER_DEBUG=true expo start\n```\n\n## Requirements\n\n- Expo SDK 49.0.0 or higher\n- iOS 13.0 or higher\n- Xcode 12.0 or higher (for building)\n- Game Center configuration in App Store Connect\n\n## Contributing\n\nContributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n- Built with [Expo Modules](https://docs.expo.dev/modules/overview/)\n- Inspired by the iOS Game Center framework\n- Thanks to the Expo community for feedback and contributions","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frouic%2Fexpo-game-center","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frouic%2Fexpo-game-center","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frouic%2Fexpo-game-center/lists"}