闲聊sdk接入说明 1.docx

上传人:b****6 文档编号:6974401 上传时间:2023-01-13 格式:DOCX 页数:17 大小:18.50KB
下载 相关 举报
闲聊sdk接入说明 1.docx_第1页
第1页 / 共17页
闲聊sdk接入说明 1.docx_第2页
第2页 / 共17页
闲聊sdk接入说明 1.docx_第3页
第3页 / 共17页
闲聊sdk接入说明 1.docx_第4页
第4页 / 共17页
闲聊sdk接入说明 1.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

闲聊sdk接入说明 1.docx

《闲聊sdk接入说明 1.docx》由会员分享,可在线阅读,更多相关《闲聊sdk接入说明 1.docx(17页珍藏版)》请在冰豆网上搜索。

闲聊sdk接入说明 1.docx

闲聊sdk接入说明1

闲聊SDK接入

以下是游戏需求(Ctrl点击进入超链接):

需求补充:

游戏头像以及昵称按照最先点击登录的类型处理,即先点击哪种登录方式,就以该种登录方式显示。

以下是闲聊给出的文档:

以下是闲聊给出的demo(在开发过程中闲聊有更换sdk,所以他们的demo仅做参考):

以下是河南麻将项目接入文档(并未完全按照闲聊所给文档接入):

一、安卓篇

1.在Eclipse内导入。

2.在android项目内添加(位置为:

henmj\android\src\com\happyplay\hnmj\sgapi)

3.在android项目内添加、、三个文件(位置为:

henmj\android\src\org\cocos2dx\javascript)

4.在android项目内修改

1).添加以下内容

....

....

}

2).在onCreate函数内添加

publicvoidonCreate(BundlesavedInstanceState){

......

xianLiaoInit();

etExtras();

if(bundle!

=null){

Stringmsg=("XL_InviteGameInfo");

xlInviteGameInfo=msg;

("getIntent","getIntent_XL_InviteGameInfo:

"+msg);

}

......

try{

......

("","hasxianliao");

}catch(IOExceptione){

......

}

......

}

3).添加函数RunJS_obj

etjs(name,param));

}

5)..添加函数xianLiaoInit

publicvoidxianLiaoInit(){

6)改微信登录函数wxLogin

7)把req=new();改为req=new添加函数xianLiaoLogin

publicvoidxianLiaoLogin(){

if(isXLInstall()){

req=new="none";

(req);

}

}

8).添加函数isXLInstall

9)加函数doWithoutXLApp

10)加函数xlShareText

publicvoidxlShareText(Stringtext){

if(isXLInstall()){

11)加函数xlShareInviteGame

publicvoidxlShareInviteGame(StringroomId,StringroomToken,Stringtitle,Stringdescription){

if(isXLInstall()){

Bitmapbitmap=(getResources(),

12)加函数xlShareTexture

publicvoidxlShareTexture(Stringpath){

if(isXLInstall()){

Bitmapbitmap=(path);

13)加函数GetXLInviteGameInfo

publicvoidGetXLInviteGameInfo(){

Stringrtn_msg=xlInviteGameInfo;

if(rtn_msg!

=""){

RunJS_obj("XL_InviteGameInfo",rtn_msg);

}

xlInviteGameInfo="";

}

14).添加函数StartXianLiaoLogin

publicstaticvoidStartXianLiaoLogin(){

if(ccActivity!

=null){

();

}

}

15).添加函数StartShareTextToXL

publicstaticvoidStartShareTextToXL(Stringpath){

if(ccActivity!

=null){

(path);

}

}

16).添加函数StartShareInviteGameToXL

publicstaticvoidStartShareInviteGameToXL(StringroomId,

StringroomToken,Stringtitle,Stringdescription){

if(ccActivity!

=null){

(roomId,roomToken,title,description);

}

}

17).添加函数StartShareTextureToXL

publicstaticvoidStartShareTextureToXL(Stringpath){

if(ccActivity!

=null){

(path);

}

}

18).添加函数xlGetInviteGameInfo

publicstaticvoidxlGetInviteGameInfo(){

if(ccActivity!

=null){

();

}

}

19).在中添加

--xianliao-->

name=""

android:

screenOrientation="sensorLandscape"

android:

configChanges="orientation"

android:

theme="@android:

style/">

name=""/>

name=""/>

name=""/>

scheme="paraches"

android:

host="xianliao*******闲聊审核获得的APPID*****"/>

android:

name=""

android:

exported="true">

二、JS篇

1.在中修改函数,在函数中添加以下内容

=function(){

if{

"WX_USER_LOGIN");

"XL_USER_LOGIN");

"LoginType");

"loginData");

sendEvent("logout");

}

else{

();

"",{},

function(){

"WX_USER_LOGIN");

"XL_USER_LOGIN");

"LoginType");

"loginData");

sendEvent("logout");

();

});

}

};

2.在中添加函数getWXunionid

=function(){

varunionid="";

varWX_USER_LOGIN="WX_USER_LOGIN");

if(WX_USER_LOGIN){

WX_USER_LOGIN=(WX_USER_LOGIN);

unionid=;

}

returnunionid;

};

3.在中添加函数operateFirstLoginType

=function(type){

if(!

type){

varloginType="LoginType");

if(loginType){

returnloginType;

}

}

else{

if(type){

"LoginType",type);

returntype;

}

else

returnnull;

}

};

4.在中添加函数doInviteGameInfo

=function(para){

if(!

para){

return;

}

....

if<=-2){

......

}

else{

......

}

}],

5.在中的JSScene的jsBind中的loginOK消息中添加xlGetInviteGameInfo的函数调用

loginOK:

function(rtn){

......

if>0){

......

}

else{

......

}

},

6.在中的JSScene的jsBind中添加XL_InviteGameInfo消息

XL_InviteGameInfo:

function(para){

(para);

},

7.在中的中添加xlLogin函数

xlLogin:

function(){

try{

if=={

"","StartXianLiaoLogin","()V");

}

elseif=={

"AppController","sendXLRequest");

}

}catch(e){

"xianLiaoLoginthrow:

"+(e));

}

},

8.在中的中添加xlInviteGame函数

xlInviteGame:

function(roomId,roomToken,title,description){

try{

if=={

"",

"StartShareInviteGameToXL",

"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",

roomId,roomToken,title,description

);

}

elseif=={

"AppController",

"xlShareInvite:

AndID:

AndTitle:

AndText:

",

roomToken,

roomId,

title,

description

);

}

}catch(e){

"XLInviteGamethrow:

"+(e));

}

},

9.在中的中添加xlShareImage函数

xlShareImage:

function(){

try{

varwritePath=vartextrueName="";

if=={

"",

"StartShareTextureToXL",

"(Ljava/lang/String;)V",

writePath+textrueName

);

}

elseif=={

varwritePath=vartextrueName="";

"AppController",

"xlShareImage:

",

writePath+textrueName

);

}

}catch(e){

"XLShareImagethrow:

"+(e));

}

},

10.在中的中添加xlShareText函数

xlShareText:

function(text){

try{

if=={

"",

"StartShareTextToXL",

"(Ljava/lang/String;)V",

text

);

}

elseif=={

"AppController",

"xlShareText:

AndText:

",

"【四方河南麻将】",

text

);

}

}catch(e){

"xlShareTextthrow:

"+(e));

}

},

11.在中的中添加xlGetInviteGameInfo函数

xlGetInviteGameInfo:

function(){

......

try{

if=={

"","xlGetInviteGameInfo","()V");

}

elseif=={

"AppController","xlGetInviteGameInfo");

}

}catch(e){

"xlGetInviteGameInfothrow:

"+(e));

}

},

12.在中添加变量xlLoginPara={};

13.在中的f_login函数中添加:

if{

=;

=;

=;

=;

}

14.在中修改函数autoLogin

=function(){

();

vartype=();

varbeginLogin=false;

mylog("判断是否可以进行闲聊或者微信的自动登录type:

"+type);

if(type=="wx"){

mylog("开始进行微信自动登录...");

varWX_USER_LOGIN="WX_USER_LOGIN");

if(WX_USER_LOGIN){

mylog("微信自动登录...");

WX_USER_LOGIN=(WX_USER_LOGIN);

LoginAsWeChat(WX_USER_LOGIN);

beginLogin=true;

}

}

elseif(type=="xl"){

mylog("开始进行闲聊自动登录...");

varXL_USER_LOGIN="XL_USER_LOGIN");

if(XL_USER_LOGIN){

mylog("闲聊自动登录...");

XL_USER_LOGIN=(XL_USER_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":

.

}

}

......

elseif=={

....

....

}

},

16.在中的邀请按钮的点击事件中添加:

wxinvite:

{

......

_click:

function(){

......

....

}

},

17.在中添加:

varXianLiaoType={

text:

1,....

},

_click:

function(){

();

}

}

18.在的ShareWXLayer中的_event添加XL_USER_LOGIN

XL_USER_LOGIN:

function(para){

();

if(para){

.");

}

}];

1.在中handleOpenURL函数中修改

-(BOOL)application:

(UIApplication*)applicationhandleOpenURL:

(NSURL*)url

{

.");

std:

:

stringresult_c_str="";

if(callBackType==SugramLoginSuccessType){

result_c_str="{\"errMsg\":

\"ERR_SUCCESS\"}";

}

elseif(callBackType==SugramLoginCancelType){

result_c_str="{\"errMsg\":

\"ERR_CANCEL\"}";

}

elseif(callBackType==SugramLoginErrorType){

result_c_str="{\"errMsg\":

\"ERR_FAIL\"}";

}

elseif(callBackType==SugramLoginUnkonwType){

result_c_str="{\"errMsg\":

\"ERR_UNKNOW\"}";

}

dispatch_async(dispatch_get_main_queue(),^{

std:

:

stringevent="XL_LOGIN_MSG";

std:

:

stringfunName="";

std:

:

stringrStr=funName+"(\""+event+"\","+result_c_str+");";

NSString*printStr=[NSStringstringWithCString:

()encoding:

[NSStringdefaultCStringEncoding]];

NSLog(@"printStr:

%@",printStr);

ScriptingCore:

:

getInstance()->evalString());

});

NSLog(@"闲聊登录结果结束...");

}

2.在中添加函数xlErrorAfterGetCode

+(void)xlErrorAfterGetCode{

NSLog(@"闲聊在获取code之后的其他操作失败...");

std:

:

stringresult_c_str="{\"errMsg\":

\"ERR_AFTERGETCODE\"}";

dispatch_async(dispatch_get_main_queue(),^{

std:

:

stringevent="XL_LOGIN_MSG";

std:

:

stringfunName="";

std:

:

stringrStr=funName+"(\""+event+"\","+result_c_str+");";

NSString*printStr=[NSStringstringWithCString:

()encoding:

[NSStringdefaultCStringEncoding]];

NSLog(@"printStr:

%@",printStr);

ScriptingCore:

:

getInstance()->evalString());

});

}

3.在中添加函数xlShareMSG

+(void)xlShareMSG:

(SugramShareCallBackType)callBackType{

NSLog(@"闲聊分享结果...");

std:

:

stringresult_c_str="";

if(callBackType==SugramShareSuccesslType){

result_c_str="{\"errMsg\":

\"ERR_SUCCESS\"}";

}

elseif(callBackType==SugramShareCancelType){

result_c_str="{\"errMsg\":

\"ERR_CANCEL\"}";

}

elseif(callBackType==SugramShareErrorType){

result_c_str="{\"errMsg\":

\"ERR_FAIL\"}";

}

elseif(callBackType==SugramShareUnkonwType){

result_c_str="{\"errMsg\":

\"ERR_UNKNOW\"}";

}

dispatch_async(dispatch_get_main_queue(),^{

std:

:

stringevent="XL_SHARE_MSG";

std:

:

stringfunName="";

std:

:

stringrStr=funName+"(\""+event+"\","+result_c_str+");";

NSString*printStr=[NSStringstringWithCString:

()encoding:

[NSStringdefaultCStringEncoding]];

NSLog(@"printStr:

%@",printStr);

ScriptingCore:

:

getInstance()->evalString());

});

NSLog(@"闲聊分享结果结束...");

}

4.在中添加函数xlGetInviteGameInfo

+(void)xlGetInviteGameInfo

{

NSLog(@"查询闲聊查询游戏邀请信息...");

NSString*inviateMsgStr1=[NSStringstringWithCString:

()encoding:

[NSStringdefaultCStringEncoding]];

NSLog(@"inviateMsgStr:

%@len=%lu",inviateMsgStr1,());

if()>0){

dispatch_async(dispatch_get

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1