# 1.1账号部分

## 1.1.1 游客登录 <a href="#id-1-1-1-guestlogin" id="id-1-1-1-guestlogin"></a>

**说明**

* 登陆方式选择界面，点击GameStart按钮调用此API

**接口**

```
-(void) guestLogin:(SDKResponseBlock) sdkResponse;
```

**参数说明**

* 无参数

**示例**

```objectivec
[mCydoniaSDK guestLogin:^(NSDictionary *resultDictionary) {
        //通过key获取对应的value
        NSNumber* statusNumber = [resultDictionary objectForKey:@"status"];
        int status = [statusNumber intValue];
        if ( status==200 ) {
            NSDictionary* dataDic = [resultDictionary objectForKey: @"data"];
            //userId
            NSString* userId = [dataDic objectForKey: @"userId"];
            NSString *msg = [resultDictionary objectForKey:@"msg"];
            NSLog(@"Demo guestLogin Callback:status is:%d, userId is %@,msg is %@.",status,userId,msg);
        }else{
            NSString *msg = [resultDictionary objectForKey:@"msg"];
            NSLog(@"Demo %d----------%@",status,msg);
        }
    }];
```

## 1.1.2 获取SDK玩家ID <a href="#id-1-1-2-getplayerid" id="id-1-1-2-getplayerid"></a>

**说明**

* 获取SDK发行的userID，每个玩家的userID是唯一的
* 此userID在其他登陆方式的返回中也会返回

**接口**

```
-(NSString*) getUserId;
```

**参数说明**

* 无参数

**示例**

```
NSString* userId = [mCydoniaSDK getUserId];
```

## 1.1.3 获取继承ID <a href="#id-1-1-3-getmigrateid" id="id-1-1-3-getmigrateid"></a>

**说明**

* 获取继承ID，显示在继承密码设定界面

**接口**

```
-(void) getMigrateId:(SDKResponseBlock) sdkResponse;
```

**参数说明**

* 无参数

**示例**

```objectivec
[mCydoniaSDK getMigrateId :^(NSDictionary *resultDictionary) {
        NSNumber* statusNumber = [resultDictionary objectForKey:@"status"];
        int status = [statusNumber intValue];
        if ( status==200 ) {
            NSDictionary* dataDic = [resultDictionary objectForKey: @"data"];
            NSString *migrateId= [dataDic objectForKey:@"migrateId"];
            NSString *msg = [resultDictionary objectForKey:@"msg"];
            NSLog(@"Demo getMigrateId Callback:status is:%d, migrateId is %@,msg is %@.",status,migrateId,msg);
        }else{
            NSString *msg = [resultDictionary objectForKey:@"msg"];
            NSLog(@"Demo %d----------%@",status,msg);
        }  
    }];
```

## 1.1.4 玩家登出 <a href="#id-1-1-4-logout" id="id-1-1-4-logout"></a>

**说明**

* 如果有玩家登出按钮需调用此API

**接口**

```
-(void) userLogout;
```

**参数说明**

* 无参数

**示例**

```
[mCydoniaSDK userLogout];
```

## 1.1.5 是否设定过继承密码 <a href="#id-1-1-5-issetpass" id="id-1-1-5-issetpass"></a>

**说明**

* 检测该账号是否设定过继承密码

**接口**

```
-(Boolean) isPasswordSet;
```

**参数说明**

* 无参数

**示例**

```
 Boolean isSetResult = [mCydoniaSDK isPasswordSet];
```

## 1.1.6 设定继承密码 <a href="#id-1-1-6-setpass" id="id-1-1-6-setpass"></a>

**说明**

* 给账号设定继承密码

**接口**

```
-(void) setMigratePass:(NSString*)pass1 :(NSString*)pass2 :(SDKResponseBlock) sdkResponse;
```

**参数说明**

* pass1: 玩家第一次输入的密码
* pass2: 玩家第二次输入的密码

**示例**

```objectivec
    NSString* pass1 = self.pass1Text.text;
    NSString* pass2 = self.pass2Text.text;
    [mCydoniaSDK setMigratePass:pass1 :pass2 :^(NSDictionary *resultDictionary) {
        [self describeDictionarya:resultDictionary];
        NSNumber* statusNumber = [resultDictionary objectForKey:@"status"];
        int status = [statusNumber intValue];
        NSString *msg = [resultDictionary objectForKey:@"msg"];
        NSLog(@"setMigratePassword Callback:%d----------%@",status,msg);
    }];
```

## 1.1.7 玩家继承 <a href="#id-1-1-7-integration" id="id-1-1-7-integration"></a>

**说明**

玩家在另一台设备通过继承ID和继承密码来继承登录游戏的时候调用此API

**接口**

```
-(void) migratedevice:(NSString*)migrateId :(NSString*)password :(SDKResponseBlock) sdkResponse;
```

**参数说明**

* migrateId: 玩家输入的继承ID
* password: 玩家输入的继承密码

**示例**

```objectivec
[mCydoniaSDK migratedevice:migrateId :migratePass :^(NSDictionary *resultDictionary) {
        describeDictionary(resultDictionary);
        
        NSNumber* statusNumber = [resultDictionary objectForKey:@"status"];
        int status = [statusNumber intValue];
        if ( status==200 ) {
            NSDictionary* dataDic = [resultDictionary objectForKey: @"data"];
            NSString *userId= [dataDic objectForKey:@"userId"];
            NSString *migrateId= [dataDic objectForKey:@"migrateId"];
            NSString *msg = [resultDictionary objectForKey:@"msg"];
            NSLog(@"Demo migrateDevice Callback:status is:%d,userId is %@, migrateId is %@,msg is %@.",status,userId,migrateId,msg);
        }else{
            NSString *msg = [resultDictionary objectForKey:@"msg"];
            NSLog(@"Demo migrateDevice Callback:%d----------%@",status,msg);
        }
        
    }];
```

## 1.1.8 SNS账号部分 <a href="#id-1-1-8-sns" id="id-1-1-8-sns"></a>

几种SNS登录方式类同，仅拿一种进行说明。

SNS分享只有Twitter和Facebook两种SNS有。

### Twitter部分 <a href="#twitter" id="twitter"></a>

#### 1.1.8.1 Twitter账号是否绑定

**说明**

判断Twitter账号是够绑定

**接口**

```
-(Boolean) isTwitterBind;
```

**参数说明**

无

**示例**

```
Boolean isBindResult = [mCydoniaSDK isTwitterBind];
```

#### **1.1.8.2 绑定Twitter账号**

**说明**

对于还没有绑定Twitter账号的玩家，可以通过此API实现绑定

**接口**

```
-(void) bindTwitter:(SDKResponseBlock) sdkResponse;
```

**参数说明**

无

**示例**

```objectivec
[mCydoniaSDK bindTwitter:^(NSDictionary *resultDictionary) {
        [self describeDictionarya:resultDictionary];
        NSNumber* statusNumber = [resultDictionary objectForKey:@"status"];
        int status = [statusNumber intValue];
        if ( status==200 ) {
            NSLog(@"Demo Twitter绑定成功.");
        }else{
            NSString *msg = [resultDictionary objectForKey:@"msg"];
            NSLog(@"Demo Twitter绑定失败%d----------%@",status,msg);
        }
    }];
```

#### **1.1.8.3 Twitter账号解绑**

**说明**

对于已经绑定过Twitter账号的玩家，可以通过此API实现解绑

**接口**

```
-(void) unbindTwitter:(SDKResponseBlock) sdkResponse;
```

**参数说明**

无

**示例**

```objectivec
[mCydoniaSDK unbindTwitter:^(NSDictionary *resultDictionary) {
        [self describeDictionarya:resultDictionary];
        NSNumber* statusNumber = [resultDictionary objectForKey:@"status"];
        int status = [statusNumber intValue];
        if ( status==200 ) {
            NSLog(@"Twitter解绑成功.");
        }else{
            NSString *msg = [resultDictionary objectForKey:@"msg"];
            NSLog(@"Twitter解绑失败%d----------%@",status,msg);
        }
    }];
```

#### **1.1.8.4 Twitter账号登录**

**说明**

使用Twitter账号登录游戏，返回数据的数据结构与游客登录方式

**接口**

```
-(void) twitterMigrate:(SDKResponseBlock) sdkResponse;
```

**参数说明**

无

**示例**

```objectivec
[mCydoniaSDK twitterMigrate:^(NSDictionary *resultDictionary) {
        //可以在resultDictionary通过key获取对应的value
        describeDictionary(resultDictionary);
        NSNumber* statusNumber = [resultDictionary objectForKey:@"status"];
        int status = [statusNumber intValue];
        if ( status==200 ) {
            NSDictionary* dataDic = [resultDictionary objectForKey: @"data"];
            NSString *userId= [dataDic objectForKey:@"userId"];
            NSLog(@"Twitter登录成功 Callback:status is:%d, userId is %@.",status,userId);
        }else{
            NSString *msg = [resultDictionary objectForKey:@"msg"];
            NSLog(@"%d----------%@",status,msg);
        }
    }];
```

#### 1.1.8.5 Twitter账号分享

**说明**

Twitter和Facebook提供了分享功能

**接口**

```
-(void) twitterShareMsgTagsAndImage:(NSString*)msg :(NSString*)imgPath :(SDKResponseBlock) sdkResponse;
```

**参数说明**

* msg：Twitter需要分享的文本和Tags, Tags需要使用"#"
* imgPath：图片文件的路径

**示例**

```objectivec
[mCydoniaSDK twitterShareMsgTagsAndImage:@"私たちKitああアアtest发信息 #sdkdevelop" :@"icon.jpg" :^(NSDictionary *resultDictionary) {
        [self describeDictionarya:resultDictionary];
        
        NSNumber* statusNumber = [resultDictionary objectForKey:@"status"];
        int status = [statusNumber intValue];//200:ok 301:failed
        if ( status==200 ) {
            NSLog(@"share successfully");
        }else{
            NSString *msg = [resultDictionary objectForKey:@"msg"];
            NSLog(@"twitter share Callback:%d----------%@",status,msg);
        }
        
    }];
```

### ~~Facebook部分~~ <a href="#facebook" id="facebook"></a>

```
-(Boolean) isFacebookBind;
-(void) bindFacebook:(SDKResponseBlock) sdkResponse;
-(void) unbindFacebook:(SDKResponseBlock) sdkResponse;
-(void) facebookMigrate:(SDKResponseBlock) sdkResponse;
-(void)facebookShareTagsAndImage:(NSString *)imgPath andHashTag:(NSString*) hashTag :(SDKResponseBlock) sdkResponse;
```

~~\*Facebook分享不允许给默认信息~~

### ~~Google部分~~ <a href="#google" id="google"></a>

```
-(Boolean) isGoogleBind;
-(void) bindGoogle:(SDKResponseBlock) sdkResponse;
-(void) unbindGoogle:(SDKResponseBlock) sdkResponse;
-(void) googleMigrate:(SDKResponseBlock) sdkResponse;
```

## 1.2 Sign in with Apple(iOS13.0+)

**说明**

使用Sign in with Apple登录游戏，参考[URL](https://developer.apple.com/design/human-interface-guidelines/sign-in-with-apple/overview/).

登录按钮尺寸需求：

| Minimum width                | Minimum height            | Minimum margin              |
| ---------------------------- | ------------------------- | --------------------------- |
| 140pt (140px @1x, 280px @2x) | 30pt (30px @1x, 60px @2x) | 1/10 of the button's height |

其次要求白底黑字在深色背景,或白底黑字黑边框在浅色背景,或黑底白字在浅色背景。圆角的半径可以修改.

**接口**

```
-(void) appleMigrate:(SDKResponseBlock) sdkResponse;
```

**参数说明**

无

示例Demo

```
[mCydoniaSDK appleMigrate:^(NSDictionary *resultDictionary) {
        //可以在resultDictionary通过key获取对应的value
        describeDictionary(resultDictionary);
        NSNumber* statusNumber = [resultDictionary objectForKey:@"status"];
        int status = [statusNumber intValue];
        if ( status==200 ) {
            NSDictionary* dataDic = [resultDictionary objectForKey: @"data"];
            NSString *userId= [dataDic objectForKey:@"userId"];
            NSLog(@"apple登录成功 Callback:status is:%d, userId is %@.",status,userId);
        }else{
            NSString *msg = [resultDictionary objectForKey:@"msg"];
            NSLog(@"%d----------%@",status,msg);
        }
    }];
    
```
