hnmj

11


IOS调用

<p>调用OC函数,类似调用web接口 将json参数反序列化成字符串传递 在OC层会解析成json处理</p> <p>wechatAuthCallBack</p> <h3>初始化微信</h3> <pre><code> let params = { "appid":"wx16a94ff2df5e4954",//固定参数 appid "appName": "海南麻将" } let paramsStr = JSON.stringify(params) let ret = jsb.reflection.callStaticMethod("iOSBridge","initWeChat:",paramsStr);</code></pre> <h3>微信登录</h3> <pre><code> if (cc.sys.isNative&amp;&amp;cc.sys.os==cc.sys.OS_IOS) { let params1 = { authScope : "snsapi_userinfo", //固定参数 authOpenID : "",//固定参数 authState : "",//固定参数 } let paramsStr1 = JSON.stringify(params1) let ret1 = jsb.reflection.callStaticMethod("iOSBridge","startWeChatAuth:",paramsStr1); } 需定义全局函数接收返回值然后调用web接口callback std::string jsCallStr = cocos2d::StringUtils::format("wechatAuthCallBack(\"%s\", \"%s\");", strRet1.c_str(), strRet.c_str()); wechatAuthCallBack(string, string) 返回数据 { code : 微信串,用于发给服务端在调用 errorcode: 错误码,为0成功,为-1 失败 }</code></pre> <h3>发送微信消息</h3> <h2>图片</h2> <p>sendImageToWeChat 参数{ inScene: // 0 聊天 1 朋友圈 bigWidth:需要转换到的图width(oc层做缩放) bigHeight:图height tagName:微信需要参数 description:描述 imagePath:图片路径 } 定义全局回调供OC 调用 SendMessageWechatCallBack(ret:string):int<br /> ret-1 失败0成功</p>

页面列表

ITEM_HTML