1、闲聊sdk接入说明 1闲聊SDK接入以下是游戏需求(Ctrl点击进入超链接):需求补充:游戏头像以及昵称按照最先点击登录的类型处理,即先点击哪种登录方式,就以该种登录方式显示。以下是闲聊给出的文档:以下是闲聊给出的demo(在开发过程中闲聊有更换sdk,所以他们的demo仅做参考):以下是河南麻将项目接入文档(并未完全按照闲聊所给文档接入):一、安卓篇1.在Eclipse内导入。2.在android项目内添加(位置为:henmjandroidsrccomhappyplayhnmjsgapi)3.在android项目内添加、三个文件(位置为:henmjandroidsrcorgcocos2dxj
2、avascript)4.在android项目内修改1).添加以下内容. .2).在onCreate函数内添加 public void onCreate(Bundle savedInstanceState) . xianLiaoInit(); etExtras(); if(bundle != null) String msg =(XL_InviteGameInfo); xlInviteGameInfo = msg; (getIntent,getIntent_XL_InviteGameInfo:+msg); .try . (, has xianliao); catch (IOException e
3、) .3).添加函数RunJS_objetjs(name, param);5).添加函数xianLiaoInitpublic void xianLiaoInit() 6) 改微信登录函数wxLogin7)把 req = new (); 改为 req = new 添加函数xianLiaoLogin public void xianLiaoLogin() if(isXLInstall() req = new = none; (req); 8).添加函数isXLInstall9) 加函数doWithoutXLApp10) 加函数xlShareText public void xlShareText(
4、String text) if(isXLInstall()11) 加函数xlShareInviteGame public void xlShareInviteGame(String roomId, String roomToken,String title, String description) if(isXLInstall() Bitmap bitmap = (getResources(),12) 加函数xlShareTexture public void xlShareTexture(String path) if(isXLInstall() Bitmap bitmap = (path)
5、;13) 加函数GetXLInviteGameInfo public void GetXLInviteGameInfo() String rtn_msg = xlInviteGameInfo; if(rtn_msg != ) RunJS_obj(XL_InviteGameInfo,rtn_msg); xlInviteGameInfo = ; 14).添加函数StartXianLiaoLogin public static void StartXianLiaoLogin() if (ccActivity != null) (); 15).添加函数StartShareTextToXL public
6、 static void StartShareTextToXL(String path) if (ccActivity != null) (path); 16).添加函数StartShareInviteGameToXL public static void StartShareInviteGameToXL(String roomId, String roomToken, String title, String description) if (ccActivity != null) (roomId, roomToken, title, description); 17).添加函数StartS
7、hareTextureToXL public static void StartShareTextureToXL(String path) if (ccActivity != null) (path); 18).添加函数xlGetInviteGameInfo public static void xlGetInviteGameInfo() if (ccActivity != null) (); 19).在中添加二、JS篇1.在中修改函数,在函数中添加以下内容 = function () if WX_USER_LOGIN); XL_USER_LOGIN); LoginType); loginDa
8、ta); sendEvent(logout); else (); , , function () WX_USER_LOGIN); XL_USER_LOGIN); LoginType); loginData); sendEvent(logout); (); ); ;2.在中添加函数getWXunionid = function () var unionid = ; var WX_USER_LOGIN = WX_USER_LOGIN); if(WX_USER_LOGIN) WX_USER_LOGIN = (WX_USER_LOGIN); unionid = ; return unionid;3.在
9、中添加函数operateFirstLoginType = function (type) if(!type) var loginType = LoginType); if(loginType) return loginType; else if(type) LoginType, type); return type; else return null; ;4.在中添加函数doInviteGameInfo = function (para) if(!para) return; . if 0) . else . ,6.在中的JSScene的jsBind中添加XL_InviteGameInfo消息
10、XL_InviteGameInfo: function (para) (para); ,7.在中的中添加xlLogin函数 xlLogin: function () try if = , StartXianLiaoLogin, ()V); else if = AppController, sendXLRequest); catch (e) xianLiaoLogin throw: + (e); ,8.在中的中添加xlInviteGame函数 xlInviteGame:function (roomId,roomToken,title,description) try if = , StartSh
11、areInviteGameToXL, (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V, roomId, roomToken, title, description ); else if = AppController, xlShareInvite:AndID:AndTitle:AndText:, roomToken, roomId, title, description ); catch (e) XLInviteGame throw: + (e); ,9.在中的中添加xlShareImage
12、函数 xlShareImage:function () try var writePath = var textrueName = ; if = , StartShareTextureToXL, (Ljava/lang/String;)V, writePath + textrueName ); else if = var writePath = var textrueName = ; AppController, xlShareImage:, writePath + textrueName ); catch (e) XLShareImage throw: + (e); ,10.在中的中添加xl
13、ShareText函数 xlShareText:function (text) try if = , StartShareTextToXL, (Ljava/lang/String;)V, text ); else if = AppController, xlShareText:AndText:, 【四方河南麻将】, text ); catch (e) xlShareText throw: + (e); ,11.在中的中添加xlGetInviteGameInfo函数 xlGetInviteGameInfo:function () . try if = , xlGetInviteGameInfo,
14、 ()V); else if = AppController, xlGetInviteGameInfo); catch (e) xlGetInviteGameInfo throw: + (e); ,12.在中添加变量xlLoginPara = ;13.在中的f_login函数中添加: if = ; = ; = ; = ; 14.在中修改函数autoLogin = function () (); var type = (); var beginLogin = false; mylog(判断是否可以进行闲聊或者微信的自动登录 type: + type); if (type = wx) mylog(
15、开始进行微信自动登录.); var WX_USER_LOGIN = WX_USER_LOGIN); if (WX_USER_LOGIN) mylog(微信自动登录.); WX_USER_LOGIN = (WX_USER_LOGIN); LoginAsWeChat(WX_USER_LOGIN); beginLogin = true; else if (type = xl) mylog(开始进行闲聊自动登录.); var XL_USER_LOGIN = XL_USER_LOGIN); if (XL_USER_LOGIN) mylog(闲聊自动登录.); XL_USER_LOGIN = (XL_US
16、ER_LOGIN); .); loginData = loginData); if (loginData) mylog(loginData自动登录.); loginData = (loginData); f_login, ; beginLogin = true; .); + , function (er, txt) if (txt) .); f_login(xlLoginPara); ); ,15.在中_event内添加XL_LOGIN_MSG的事件响应 XL_LOGIN_MSG:function (para) if switch case ERR_SUCCESS: . . else if =
17、 . ,16.在中的邀请按钮的点击事件中添加:wxinvite: . _click: function () . . ,17.在中添加:var XianLiaoType = text:1, . , _click: function () (); 18.在的ShareWXLayer中的_event添加XL_USER_LOGIN XL_USER_LOGIN:function (para) (); if(para) .); ;1.在中handleOpenURL函数中修改- (BOOL)application:(UIApplication *)application handleOpenURL:(NS
18、URL *)url .); std:string result_c_str= ; if (callBackType = SugramLoginSuccessType) result_c_str = errMsg:ERR_SUCCESS; else if (callBackType = SugramLoginCancelType) result_c_str = errMsg:ERR_CANCEL; else if(callBackType = SugramLoginErrorType) result_c_str = errMsg:ERR_FAIL; else if(callBackType =
19、SugramLoginUnkonwType) result_c_str = errMsg:ERR_UNKNOW; dispatch_async(dispatch_get_main_queue(), std:string event = XL_LOGIN_MSG; std:string funName = ; std:string rStr = funName + ( + event + , + result_c_str + ); NSString *printStr = NSString stringWithCString:() encoding:NSString defaultCString
20、Encoding; NSLog(printStr:%,printStr); ScriptingCore:getInstance()-evalString(); ); NSLog(闲聊登录结果结束.);2.在中添加函数xlErrorAfterGetCode+(void)xlErrorAfterGetCode NSLog(闲聊在获取code之后的其他操作失败.); std:string result_c_str = errMsg:ERR_AFTERGETCODE; dispatch_async(dispatch_get_main_queue(), std:string event = XL_LOG
21、IN_MSG; std:string funName = ; std:string rStr = funName + ( + event + , + result_c_str + ); NSString *printStr = NSString stringWithCString:() encoding:NSString defaultCStringEncoding; NSLog(printStr:%,printStr); ScriptingCore:getInstance()-evalString(); );3.在中添加函数xlShareMSG+(void)xlShareMSG:(Sugra
22、mShareCallBackType)callBackType NSLog(闲聊分享结果.); std:string result_c_str= ; if (callBackType = SugramShareSuccesslType) result_c_str = errMsg:ERR_SUCCESS; else if(callBackType = SugramShareCancelType) result_c_str = errMsg:ERR_CANCEL; else if(callBackType = SugramShareErrorType) result_c_str = errMsg
23、:ERR_FAIL; else if(callBackType = SugramShareUnkonwType) result_c_str = errMsg:ERR_UNKNOW; dispatch_async(dispatch_get_main_queue(), std:string event = XL_SHARE_MSG; std:string funName = ; std:string rStr = funName + ( + event + , + result_c_str + ); NSString *printStr = NSString stringWithCString:(
24、) encoding:NSString defaultCStringEncoding; NSLog(printStr:%,printStr); ScriptingCore:getInstance()-evalString(); ); NSLog(闲聊分享结果结束.);4.在中添加函数xlGetInviteGameInfo+(void)xlGetInviteGameInfo NSLog(查询闲聊查询游戏邀请信息.); NSString *inviateMsgStr1 = NSString stringWithCString:() encoding:NSString defaultCStringEncoding; NSLog(inviateMsgStr:% len=%lu,inviateMsgStr1,(); if() 0) dispatch_async(dispatch_get
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1