如何登陆game center无反应r

海岛奇兵如何绑定game center账号?保存游戏进度教程
发表时间:&&出处:本站整理 &&责任编辑:笑堂&&标签:
海岛奇兵游戏官方最近在游戏里发了一则公告,提醒大家保存游戏进度,由于很多玩家不知道如何将游戏与Game center绑定以此保存游戏进度,小编特地在此奉上教程,供新手玩家参考。
过程非常简单:
1、打开设置,找到Game Center,登陆你的苹果账号,也就是Apple ID(没有的话直接注册一个就行了)
2、登录后,退出设置,打开并运行海岛奇兵游戏。这时Game Center会自动绑定你的游戏进度,从此再也不怕弄丢游戏进度了!
微信扫一扫,免费秒领礼包
点击查询最新礼包,限量礼包免费领取、独家礼包、福利好礼,轻松获得。
公众号查询:zhangyouwang289 (扫我)
责编:笑堂289掌游网在手 ,礼包资讯应有尽有。
近期热门游戏
关注最强手游神器
[ 尽享独家礼包 ]Unity iOS Game Center帐号验证(包括python后端) - 简书
Unity iOS Game Center帐号验证(包括python后端)
为了少走弯路,参考了:
先写个Tips:
1. 这个例子没有检查Game Center用户切换的情况
2. 为了尽量突出验证的过程,汇报显示排行榜等接口也没有列出
3. 如果出现“无法完成所请求的操作,因为 Game Center 未识别此应用程序。”,
a. 请先检查BundleId是否一致
b. 再检查看itunesconnect里是不是没有添加过排行榜或者成就设置,必须要至少添加一条
c. Game Center需要登录你设置ITunesconnect设置过的测试帐号(不用有些资料说的必需新建帐号)
GameCenterUserVerify.h
#import &Foundation/Foundation.h&
#import &GameKit/GameKit.h&;
@interface GameCenterUserVerify : NSObject
@interface GameCenterUserManager : NSObject
GameCenterUserVerify.m
#import "GameCenterUserVerify.h"
@implementation GameCenterUserVerify
+ (void)Verify
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
if (localPlayer.authenticated)
__weak GKLocalPlayer *useLocalPlayer = localP
[useLocalPlayer generateIdentityVerificationSignatureWithCompletionHandler: ^(NSURL * _Nullable publicKeyUrl,
NSData * _Nullable signature,
NSData * _Nullable salt,
uint64_t timestamp,
NSError * _Nullable error) {
if (error == nil)
[self verifyPlayer: useLocalPlayer.playerID // our verify routine: below
publicKeyUrl: publicKeyUrl
signature: signature
salt: salt
timestamp: timestamp];
// GameCent deal with it here.
UnitySendMessage("_GameCenterManager_","IOSGameGameCenterVerifyFail",[[error localizedDescription] UTF8String]);
it makes no sense to try to verify them.
UnitySendMessage("_GameCenterManager_","IOSGameGameCenterVerifyFail","Game center not logined.");
+(void)verifyPlayer: (NSString*) playerID
publicKeyUrl: (NSURL*) publicKeyUrl
signature: (NSData*) signature
salt: (NSData*) salt
timestamp: (uint64_t) timestamp
NSDictionary *paramsDict = @{ @"publicKeyUrl": [publicKeyUrl absoluteString],
@"timestamp"
: [NSString stringWithFormat: @"%llu", timestamp],
@"signature"
: [signature base64EncodedStringWithOptions: 0],
: [salt base64EncodedStringWithOptions: 0],
@"playerID"
: playerID,
@"bundleID"
: [[NSBundle mainBundle] bundleIdentifier]
// NOTE: A lot of the code below was cribbed from another SO answer for which I have lost the URL.
// FIXME: &When found, insert other-SO-answer URL here&
// build payload
NSMutableData *payload = [NSMutableData new];
[payload appendData: [playerID dataUsingEncoding: NSASCIIStringEncoding]];
[payload appendData: [[[NSBundle mainBundle] bundleIdentifier] dataUsingEncoding: NSASCIIStringEncoding]];
uint64_t timestampBE = CFSwapInt64HostToBig(timestamp);
[payload appendBytes: &timestampBE length: sizeof(timestampBE)];
[payload appendData: salt];
// Verify with server
[self verifyPlayerOnServer: payload withSignature: signature publicKeyURL: publicKeyUrl];
+ (void) verifyPlayerOnServer: (NSData*) payload withSignature: signature publicKeyURL: (NSURL*) publicKeyUrl
// hint courtesy of: /questions//how-to-authenticate-the-gklocalplayer-on-my-third-party-server-using-php
NSDictionary *jsonDict = @{ @"data" : [payload base64EncodedStringWithOptions: 0],@"puk":[publicKeyUrl absoluteString],
@"sig":[signature base64EncodedStringWithOptions: 0]};
//NSLog(@"%s [DEBUG] jsonDict: %@", __PRETTY_FUNCTION__, jsonDict);
NSError *error =
NSData *bodyData = [NSJSONSerialization dataWithJSONObject: jsonDict options: 0 error: &error];
if (error != nil)
NSLog(@"%s ***** dataWithJson error: %@", __PRETTY_FUNCTION__, error);
UnitySendMessage("_GameCenterManager_","IOSGameGameCenterVerifyFail",[[error localizedDescription] UTF8String]);
NSString *jsonStr = [[NSString alloc] initWithData:bodyData encoding:NSUTF8StringEncoding];
// NSLog(@"json data:%s",[jsonStr UTF8String]);
UnitySendMessage("_GameCenterManager_","IOSGameGameCenterVerifySuccess",[jsonStr UTF8String]);
@implementation GameCenterUserManager
extern "C"
void CallFromUnity_GameCenterUserVerify()
NSLog(@"CallFromUnity_GameCenterUserVerify.");
[GameCenterUserVerify Verify];
using UnityE
using UnityEngine.SocialP
using UnityEngine.SocialPlatforms.GameC
using CodeStage.AntiCheat.ObscuredT
using System.Runtime.InteropS
using MiniJSON;
using System.Collections.G
public class GameCenterManager : MonoBehaviour
#if UNITY_IOS
[DllImport ("__Internal")]
private static extern void CallFromUnity_GameCenterUserVerify();
private static GameCenterM
private static object _lock=new object();
private GameCenterManager(){}
public static GameCenterManager GetInstance()
if(instance==null)
lock(_lock)
if(instance==null)
var obj = new GameObject("_GameCenterManager_");
instance = obj.AddComponent&GameCenterManager&();
private JDKUserModel userM
private System.Action&bool& loginCallBack=
public void Start()
Social.localUser.Authenticate(HandleAuthenticated);
public JDKUserModel GetUserModel(){
return userM
public void Authenticate(System.Action&bool& callback){
// if(Social.localUser.authenticated){
callback(true);
loginCallBack =
private void HandleAuthenticated(bool success)
Debug.Log("*** HandleAuthenticated: success = " + success);
if(success)
string userInfo = "UserName:" + Social.localUser.userName +"\nUser ID:"+
Social.localUser.id + " \nIsUnderage: "+ Social.localUser.
JDKLog.Log(userInfo);
#if UNITY_IOS && !UNITY_EDITOR
CallFromUnity_GameCenterUserVerify();
if(loginCallBack!=null){
loginCallBack(false);
loginCallBack=
if(loginCallBack!=null){
loginCallBack(false);
loginCallBack=
public void IOSGameGameCenterVerifyFail(string errorMsg){
JDKLog.LogError(errorMsg);
if(loginCallBack!=null){
loginCallBack(false);
loginCallBack=
public void IOSGameGameCenterVerifySuccess(string result){
JDKLog.Log(result);
var dict = (IDictionary&string,object&)Json.Deserialize(result);
var data = (string)dict["data"];
var puk = (string)dict["puk"];
var sig = (string)dict["sig"];
//现在可以发送 data/puk/sig 给服务器验证
//我们是先存到一个用户模型,稍候(点击登录按钮后)再发送给服务器端验证
//userModel = new JDKUserModel(Social.localUser.id,Social.localUser.userName,UserChannel.iOSGameCenter,null);
//userModel.SetiOSGameCenterVerifyData(puk, sig, data);
//if(loginCallBack!=null){
loginCallBack(true);
loginCallBack=
服务器端我就把关键的验证方法贴出来吧:
from OpenSSL.crypto import verify
from OpenSSL.crypto import load_certificate
from OpenSSL.crypto import FILETYPE_ASN1
import base64
#cert_der对应客户端的puk指向的文件原文,注意客户端给的puk只是url,这里的cert_der需要传入这个url文件的内容,需要自己通过http获取url的文件
#signatureBase64 对应客户端给的sig原文
#dataBase64 对应客户端给的data原文
#user_id 是指客户端的Social.localUser.id,用在这里校验苹果这次签名的是不是这个用户id
def ios_gamecenter_user_verify(cert_der, signatureBase64, dataBase64,user_id):
signature = base64.b64decode(signatureBase64)
data = base64.b64decode(dataBase64)
good_cert = load_certificate(FILETYPE_ASN1, cert_der)
verify(good_cert, signature, data, 'sha256')
user_id=':%sc'%(user_id)
return user_id in data
return False
return True

我要回帖

更多关于 game center被别人登陆 的文章

 

随机推荐