6.社交能力

6.1 登录

Android

SocialNative.login(int type,final SocialCallBack callback);

示例:

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

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

        }];

Unity

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

示例:

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

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

示例:

 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

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

Unity

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

示例:

 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

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

参数:

param:分享参数

iOS

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

 }];

参数:

title:分享标题

imageurl:分享图片地址

url:分享链接

callback:回调

Unity

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

示例:

 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;
                }

            });

最后更新于