# 6.社交能力

## 6.1 登录

### Android

```java
SocialNative.login(int type,final SocialCallBack callback)；
```

示例：

```java
SocialNative.login(SocialDef.TYPE_WX,new SocialNative.SocialCallBack(){
                    @Override
                    public void onResult(HashMap<String, String> map) {

                        if(map != null && map.get("retCode") !=null && map.get("retCode").equals("1"))
                        {
                            System.out.println("登录成功 可以更新用户信息");
                        }else
                        {
                            System.out.println("登录失败");
                        }
                    }
                });
```

### iOS

```objectivec
 [IOSLoader thirdLoginWithType:type callBack:^(KTMLoginState code, NSString *returnMsg) {

        }];
```

### Unity

```csharp
Wb.SocialManager.Instance.Login(int type, Action<bool> callFun)
```

示例：

```csharp
Wb.SocialManager.Instance.Login(type, (result) =>
            {
                if (result)
                {
                    string outStr1;
                    if (LanguageManagers.Instance.languageDic.TryGetValue("登录成功", out outStr1))
                    {
                        ShowToast(outStr1, false);
                    }
                }
                else
                {
                    string outStr1;
                    if (LanguageManagers.Instance.languageDic.TryGetValue("登录失败", out outStr1))
                    {
                        ShowToast(outStr1, true);
                    }
                }

            });
```

* 参数：

  type：登录类型 1:微信登录，3:FB登录

  callback：回调

## 6.2 获取用户信息

### Android

```java
SocialNative.updateUserInfo(int type,final SocialCallBack callback);
```

示例：

```java
 SocialNative.updateUserInfo(SocialDef.TYPE_WX, new SocialNative.SocialCallBack() {
                    @Override
                    public void onResult(HashMap<String, String> map) {
                        if (map !=null &&  map.get("openid") != null && ((String)map.get("openid")).length() > 0) {
                            System.out.println("获取用户信息成功");
                        } else {
                            System.out.println("获取用户信息失败");
                        }
                    }
                });
```

### iOS

```objectivec
  [IOSLoader getUserInfoWithType:type callBack:^(NSDictionary *userinfo) {
   }];
```

### Unity

```csharp
Wb.SocialManager.Instance.GetUserInfo(int type, Action<bool,string> callFun)
```

示例：

```csharp
 Wb.SocialManager.Instance.GetUserInfo(type, (result,info) =>
            {
                if (result)
                {
                    string outStr1;
                    if (LanguageManagers.Instance.languageDic.TryGetValue("获取用户信息成功", out outStr1))
                    {
                        ShowToast(outStr1, false);
                    }

                    userInfoTxt.GetComponent<Text>().text = info;
                }
                else
                {
                    string outStr1;
                    if (LanguageManagers.Instance.languageDic.TryGetValue("获取用户信息失败", out outStr1))
                    {
                        ShowToast(outStr1, true);
                    }

                    userInfoTxt.GetComponent<Text>().text = info;
                }

            });
```

参数：

type：登录类型 1:微信登录，3:FB登录

callback：回调

## 6.3 分享

### Android

```java
SocialNative.share(HashMap<String, String> param);
```

参数：

param：分享参数

### iOS

```objectivec
 [IOSLoader shareWithTitle:title imageUrl:imageurl url:url completeHandler:^(BOOL succed, NSString *reason) {

 }];
```

参数：

title：分享标题

imageurl：分享图片地址

url：分享链接

callback：回调

### Unity

```csharp
Wb.SocialManager.Instance.Share(Dictionary<string, string> attributes)
```

示例：

```csharp
 Wb.SocialManager.Instance.GetUserInfo(type, (result,info) =>
            {
                if (result)
                {
                    string outStr1;
                    if (LanguageManagers.Instance.languageDic.TryGetValue("获取用户信息成功", out outStr1))
                    {
                        ShowToast(outStr1, false);
                    }

                    userInfoTxt.GetComponent<Text>().text = info;
                }
                else
                {
                    string outStr1;
                    if (LanguageManagers.Instance.languageDic.TryGetValue("获取用户信息失败", out outStr1))
                    {
                        ShowToast(outStr1, true);
                    }

                    userInfoTxt.GetComponent<Text>().text = info;
                }

            });
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tyson.gitbook.io/vigamedoc/cn/ke-hu-duan-jie-ru/ye-wu-jie-kou/6.-she-jiao-neng-li.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
