App ID & Game Center - I

本文介绍了如何在iOS应用中设置AppID以及如何通过iTunesConnect进行注册,并详细讲解了如何在Xcode中配置AppID,同时演示了启用GameCenter功能的方法。
部署运行你感兴趣的模型镜像

An App ID is the combination of a unique ten character string called the "Bundle Seed ID" and a traditional CF Bundle ID (or Bundle Identifier).


App ID 的意义在于区别iOS中两个不同的APP。

Bundle Seed ID 是一个由Apple生成的10位随机字符串。


Provisioning Portal - Add new App:

Bundle Seed ID(App ID Prefix): 选择已存在的Bundle Seed ID (应该只有一个的)

Bundle Identifier:       com.skingtree.testAPP2


Xcode:

Bundle Identifier: com.skingtree.testAPP2


于是这个开发中的App便有了自己的唯一ID,

下面到ITC中为这个APP ID注册


iTunesConnect

App Name: Space Viking

SKU: SPACEVIKING001

Bundle ID: 选择之前创建好的,com.skingtree.testAPP2  (其它不需要指明App ID的就是 wildcard ID)


接下来把必填的填上,随便附上iTunesArtwork图片

在你提交最后版本的binary前,也就是你的app真正release上架之前是可以修改的。


上面的设置为Game Center做好准备,下面来启用Game Center



Done!

这样就可以用leaderboard 和 achievement 的功能了。




您可能感兴趣的与本文相关的镜像

Stable-Diffusion-3.5

Stable-Diffusion-3.5

图片生成
Stable-Diffusion

Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

### Cocos Creator 中实现 iOS Game Center 功能集成 在 Cocos Creator 中实现 iOS Game Center 功能,需要结合原生插件开发和配置 iTunes Connect 来完成。以下是详细的实现方法: #### 1. 配置 iTunes Connect 在接入 Game Center 功能之前,必须先在 iTunes Connect 中完成相关设置: - 登录 [iTunes Connect](https://itunesconnect.apple.com),选择你的应用。 - 进入 **Features(功能)** 页面,启用 Game Center 功能[^2]。 - 创建排行榜或成就。例如,点击 **Leaderboards(排行榜)** 或 **Achievements(成就)**,然后按照提示完成创建过程[^2]。 #### 2. Xcode 配置 确保你的项目已正确配置以支持 Game Center-Xcode 的 **Capabilities** 标签下,启用 **Game Center** 功能。 - 确保项目的 Bundle Identifier 和 iTunes Connect 中的应用保持一致。 #### 3. 创建原生插件 Cocos Creator 不直接支持 Game Center 功能,因此需要通过原生插件来实现。以下是一个简单的实现步骤: ##### 3.1 创建 Objective-C 类 在 Xcode 中创建一个新的 Objective-C 文件,用于处理 Game Center 相关逻辑。例如,创建一个名为 `GameCenterManager` 的类。 ```objective-c #import <GameKit/GameKit.h> #import <Foundation/Foundation.h> @interface GameCenterManager : NSObject + (void)authenticateLocalPlayer; + (void)submitScore:(int64_t)score forCategory:(NSString *)category; + (void)showLeaderboard; @end @implementation GameCenterManager + (void)authenticateLocalPlayer { GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer]; localPlayer.authenticateHandler = ^(UIViewController * _Nullable viewController, NSError * _Nullable error) { if (viewController != nil) { // 如果需要用户登录,显示登录界面 [UIApplication.sharedApplication.keyWindow.rootViewController presentViewController:viewController animated:YES completion:nil]; } else if ([GKLocalPlayer localPlayer].isAuthenticated) { // 用户已成功授权 NSLog(@"Game Center: User authenticated successfully."); } else { // 授权失败 NSLog(@"Game Center: Authentication failed with error: %@", error.localizedDescription); } }; } + (void)submitScore:(int64_t)score forCategory:(NSString *)category { GKScore *gkScore = [[GKScore alloc] initWithLeaderboardIdentifier:category]; gkScore.value = score; [GKScore reportScores:@[gkScore] withCompletionHandler:^(NSError * _Nullable error) { if (error != nil) { NSLog(@"Error submitting score: %@", error.localizedDescription); } else { NSLog(@"Score submitted successfully."); } }]; } + (void)showLeaderboard { GKGameCenterViewController *gameCenterVC = [[GKGameCenterViewController alloc] init]; gameCenterVC.viewState = GKGameCenterViewControllerStateLeaderboards; gameCenterVC.gameCenterDelegate = self; [UIApplication.sharedApplication.keyWindow.rootViewController presentViewController:gameCenterVC animated:YES completion:nil]; } @end ``` ##### 3.2 将插件封装为 JavaScript 接口 在 Cocos Creator 中,可以通过 `jsb-reflection` 模块调用原生代码。首先,在 `native` 文件夹中添加上述 Objective-C 文件,并在 `cocos-project.json` 中声明插件路径。 接下来,编写 JavaScript 接口文件,例如 `GameCenter.js`: ```javascript cc.Class({ extends: cc.Component, properties: {}, authenticateLocalPlayer() { jsb.reflection.callStaticMethod("GameCenterManager", "authenticateLocalPlayer"); }, submitScore(score, category) { jsb.reflection.callStaticMethod("GameCenterManager", "submitScore:forCategory:", score, category); }, showLeaderboard() { jsb.reflection.callStaticMethod("GameCenterManager", "showLeaderboard"); } }); ``` #### 4. 调用 Game Center 功能 在游戏逻辑中调用封装好的 JavaScript 接口。例如: ```javascript const gameCenter = new cc.GameCenter(); // 授权本地玩家 gameCenter.authenticateLocalPlayer(); // 提交分数到排行榜 gameCenter.submitScore(1000, "com.example.leaderboard"); // 显示排行榜 gameCenter.showLeaderboard(); ``` #### 5. 测试与调试 - 确保设备已登录 Game Center 账户,并且测试设备的 Apple ID 已加入 TestFlight 测试计划。 - 在开发和调试阶段,可能需要多次清除应用数据并重新运行以刷新 Game Center 数据。 --- ### 注意事项 - 在发布应用之前,确保应用符合 App Store 审核指南的所有要求[^2]。 - 使用 Game Center 功能时,建议在用户明确同意的情况下提交数据,以提高用户体验。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值