JsbSystem.ts 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. import { DataEventId } from "../../game/data/GameData";
  2. /**
  3. * Jsb管理类(与安卓Java类或者IOS交互)
  4. * @description
  5. * @author 冯聪
  6. */
  7. export default class JsbSystem {
  8. /**代码桥在AS中的路径 */
  9. private static _JSB_ANDROID_PATH: string = "org/cocos2dx/javascript/thirdSdk/ThirdSdkMgr";
  10. /**代码桥在IOS中的路径 */
  11. private static _JSB_IOS_PATH: string = "ThirdSdkMgr";
  12. /**代码桥在AS中的路径 */
  13. private static _JSB_ANDROID_PATH_JSDK: string = "org/cocos2dx/javascript/thirdSdk/ysdk/YSDKMgr";
  14. /**
  15. * 是否文件存在
  16. * @param filePath 文件路径
  17. * @returns 是否文件存在 boolean
  18. */
  19. public static isFileExist(fileName: string): boolean {
  20. if (cc.sys.os == cc.sys.OS_WINDOWS) {
  21. return true;
  22. }
  23. let filePath = this.getWritablePath() + fileName + ".apk";
  24. return jsb.fileUtils.isFileExist(filePath);
  25. }
  26. /**
  27. * 获取写入的路径
  28. * @description
  29. * @returns path 写入路径(string)
  30. */
  31. public static getWritablePath(): string {
  32. return jsb.fileUtils.getWritablePath();
  33. }
  34. /**
  35. * 调用项目工程静态方法
  36. * @description 调用Android与IOS对应的静态方法
  37. * @param path 调用路径:"org/cocos2dx/javascript/AppActivity":java中的包名(.换成/)+class文件名,就当是路径好了
  38. * @param methodName 调用的方法名:必须public static
  39. * @param methodSignature 方法签名:“(Ljava/lang/String;)Ljava/lang/String;”:()内的是调用的java方法的参数类型,()外面的是返回值类
  40. * @param parameters 参数:是java方法需要传入的参数(可以多个,与methodSignature中()内的数量和类型一一对应)
  41. */
  42. public static callStaticMethod(path: string, methodName: string, methodSignature: string, ...parameters: any): any {
  43. let value = jsb.reflection.callStaticMethod(path, methodName, methodSignature, ...parameters);
  44. return value;
  45. }
  46. /**
  47. * Java调用返回测试
  48. * @description 自定义功能 JavaToCocos
  49. */
  50. public static backTest() {
  51. }
  52. /**
  53. * 更新设备信息
  54. * @description 自定义功能 JavaToCocos
  55. * @param info info(Java返回)
  56. */
  57. public static updateDeviceInfo(info) {
  58. mk.console.log("===[JsbSystem] updateDeviceInfo", info)
  59. if (cc.sys.os == cc.sys.OS_ANDROID) {
  60. gData.appData.updateDeviceInfo(info);
  61. }
  62. else if (cc.sys.os == cc.sys.OS_IOS) {
  63. }
  64. }
  65. /** 获取手机授权 */
  66. public static checkPermission() {
  67. if (cc.sys.os == cc.sys.OS_ANDROID) {
  68. this.callStaticMethod(this._JSB_ANDROID_PATH, "checkPermission", "()V");
  69. }
  70. else if (cc.sys.os == cc.sys.OS_IOS) {
  71. jsb.reflection.callStaticMethod("GameConfig", "checkPermission:", "");
  72. }
  73. }
  74. /**
  75. * 获取设备信息
  76. * @description 自定义功能 CocosToJava
  77. */
  78. public static getDeviceInfo() {
  79. let deviceInfo = "";
  80. if (cc.sys.os == cc.sys.OS_ANDROID) {
  81. deviceInfo = this.callStaticMethod(this._JSB_ANDROID_PATH, "getDeviceInfo", "()Ljava/lang/String;");
  82. console.log("===[JsbSystem] getDeviceInfo ", deviceInfo);
  83. gData.appData.updateDeviceInfo(deviceInfo);
  84. }
  85. else if (cc.sys.os == cc.sys.OS_IOS) {
  86. this.callStaticMethod(this._JSB_IOS_PATH, "getDeviceInfo", "");
  87. }
  88. else {
  89. gData.appData.getDeviceInfoCompelete = true;
  90. }
  91. }
  92. /**
  93. * 获取包名
  94. * @description 自定义功能 CocosToJava
  95. * @returns packName 包名
  96. */
  97. public static getPackageName() {
  98. let packName = '';
  99. if (cc.sys.os == cc.sys.OS_ANDROID) {
  100. packName = this.callStaticMethod(this._JSB_ANDROID_PATH, "getPackageName", "()Ljava/lang/String;");
  101. }
  102. else if (cc.sys.os == cc.sys.OS_IOS) {
  103. packName = this.callStaticMethod("CsjAdReward", "getPackageName", "");
  104. }
  105. return packName;
  106. }
  107. /**
  108. * 获取appid 和 配置version
  109. * @description 自定义功能 CocosToJava
  110. * @returns appid
  111. */
  112. public static getWxAppId() {
  113. let unicodeStr = "";
  114. if (cc.sys.os == cc.sys.OS_ANDROID) {
  115. unicodeStr = this.callStaticMethod(this._JSB_ANDROID_PATH, "getWxAppId", "()Ljava/lang/String;");
  116. }
  117. else if (cc.sys.os == cc.sys.OS_IOS) {
  118. unicodeStr = this.callStaticMethod("CsjAdReward", "getWxAppId", "",);
  119. }
  120. let unicodeArr = unicodeStr.split(';');
  121. if (unicodeArr) {
  122. gData.appData.appId = unicodeArr[0];
  123. gData.appData.version = unicodeArr[1];
  124. }
  125. if (CC_DEBUG) {
  126. gData.appData.appId = "wx6438b2697e818b24";
  127. gData.appData.version = "5.1.1";
  128. }
  129. // console.log('gData.appData ', unicodeStr)
  130. // console.log('gData.appData.appId ', gData.appData.appId)
  131. // console.log('gData.appData.version ', gData.appData.version)
  132. }
  133. /**
  134. * 获取广告渠道和相关id
  135. * @description 自定义功能 CocosToJava
  136. * @returns str
  137. */
  138. public static getAdvertisingChannel(): string {
  139. let str = "";
  140. if (cc.sys.os == cc.sys.OS_ANDROID) {
  141. str = this.callStaticMethod(this._JSB_ANDROID_PATH, "getAdvertisingChannel", "()Ljava/lang/String;");
  142. }
  143. else if (cc.sys.os == cc.sys.OS_IOS) {
  144. str = this.callStaticMethod("CsjAdReward", "AdvertisingChannel", "");
  145. }
  146. let arr = str.split(',')
  147. gData.warnTipData.AdIDArr = arr.slice(3);
  148. return str;
  149. }
  150. /** 显示开屏 */
  151. static showSplash() {
  152. // mk.data.sendDataEvent('slashAd', '开屏')
  153. if (cc.sys.os == cc.sys.OS_ANDROID) {
  154. this.callStaticMethod(this._JSB_ANDROID_PATH, "showSplash", "()V");
  155. }
  156. else if (cc.sys.os == cc.sys.OS_IOS) {
  157. jsb.reflection.callStaticMethod("GameConfig", "showSplash:", "");
  158. }
  159. }
  160. /**
  161. * 复制到剪切板
  162. * @description Andorid功能 CocosToJava
  163. * @param str 剪切板字符串内容
  164. */
  165. public static setClipboard(str: string) {
  166. if (cc.sys.os == cc.sys.OS_ANDROID) {
  167. this.callStaticMethod(this._JSB_ANDROID_PATH, "setClipboard", "(Ljava/lang/String;)V", str);
  168. }
  169. else if (cc.sys.os == cc.sys.OS_IOS) {
  170. }
  171. else if (cc.sys.isBrowser) {
  172. var input = str;
  173. const el: any = document.createElement('textarea');
  174. el.value = input;
  175. el.setAttribute('readonly', '');
  176. el.style.contain = 'strict';
  177. el.style.position = 'absolute';
  178. el.style.left = '-9999px';
  179. el.style.fontSize = '12pt';
  180. const selection = getSelection();
  181. var originalRange: any = false;
  182. if (selection.rangeCount > 0) {
  183. originalRange = selection.getRangeAt(0);
  184. }
  185. document.body.appendChild(el);
  186. el.select();
  187. el.selectionStart = 0;
  188. el.selectionEnd = input.length;
  189. var success = false;
  190. try {
  191. success = document.execCommand('copy');
  192. } catch (err) { }
  193. document.body.removeChild(el);
  194. if (originalRange) {
  195. selection.removeAllRanges();
  196. selection.addRange(originalRange);
  197. }
  198. return success;
  199. }
  200. }
  201. /**
  202. * 请求用户授权
  203. * @description Andorid功能 CocosToJava
  204. */
  205. public static requestPermission() {
  206. if (cc.sys.os == cc.sys.OS_ANDROID) {
  207. this.callStaticMethod(this._JSB_ANDROID_PATH, "requestPermission", "()V");
  208. }
  209. else if (cc.sys.os == cc.sys.OS_IOS) {
  210. this.callStaticMethod("AppController", "requestPermission", "");
  211. }
  212. }
  213. /**
  214. * 获取安卓的版本号
  215. * @description Andorid功能 CocosToJava
  216. */
  217. public static getAppVersion() {
  218. if (cc.sys.os == cc.sys.OS_ANDROID) {
  219. this.callStaticMethod(this._JSB_ANDROID_PATH, "getAppVersion", "()V");
  220. }
  221. else if (cc.sys.os == cc.sys.OS_IOS) {
  222. this.callStaticMethod("AppController", "getAppVersion", "");
  223. }
  224. }
  225. /**
  226. * 设置安卓得版本号
  227. * @description Andorid功能 JavaToCocos
  228. * @param appVersion app版本号
  229. */
  230. public static setAppVersion(appVersion: string) {
  231. if (cc.sys.os == cc.sys.OS_ANDROID) {
  232. // GameConst.appVersion = appVersion;
  233. }
  234. else if (cc.sys.os == cc.sys.OS_IOS) {
  235. }
  236. }
  237. /**
  238. * 安装apk
  239. * @description Andorid功能 CocosToJava
  240. * @param apkName apkName
  241. */
  242. public static installApk(apkName: string) {
  243. let fullPath = this.getWritablePath() + apkName + ".apk";
  244. if (cc.sys.os == cc.sys.OS_ANDROID) {
  245. this.callStaticMethod(this._JSB_ANDROID_PATH, "installApk", "(Ljava/lang/String;)V", fullPath);
  246. }
  247. else if (cc.sys.os == cc.sys.OS_IOS) {
  248. this.callStaticMethod("GameConfig", "installApk:", "");
  249. }
  250. }
  251. /**
  252. * 是否可以启动游戏
  253. * @param packageName 包名
  254. * @param start 如存在是否启动
  255. * @returns ifCan
  256. */
  257. public static ifCanStartGame(packageName: string, start: boolean): boolean {
  258. let isCan = false;
  259. if (cc.sys.os == cc.sys.OS_ANDROID) {
  260. isCan = this.callStaticMethod(this._JSB_ANDROID_PATH, "isStartGame", "(Ljava/lang/String;Z)Z", packageName, start);
  261. return isCan;
  262. }
  263. else if (cc.sys.os == cc.sys.OS_IOS) {
  264. isCan = this.callStaticMethod("GameConfig", "installApk:", "");
  265. }
  266. return isCan;
  267. }
  268. /**
  269. * 数数事件注册
  270. * @description 数数SDK功能
  271. * @returns
  272. */
  273. static setTAEventRegister() {
  274. if (cc.sys.os == cc.sys.OS_ANDROID) {
  275. this.callStaticMethod(this._JSB_ANDROID_PATH, "setTAEventRegister", "()V");
  276. }
  277. else if (cc.sys.os == cc.sys.OS_IOS) {
  278. }
  279. }
  280. /**
  281. * 发送自定义事件 自定义功能 CocosToJava
  282. * @description 发送统计事件
  283. * @param key 事件的key值
  284. * @param value 事件的value值
  285. */
  286. public static sendEvent(key: string, value: string) {
  287. if (cc.sys.os == cc.sys.OS_ANDROID) {
  288. this.callStaticMethod(this._JSB_ANDROID_PATH, "sendEvent", "(Ljava/lang/String;Ljava/lang/String;)V", key, value);
  289. }
  290. else if (cc.sys.os == cc.sys.OS_IOS) {
  291. }
  292. }
  293. /**
  294. * 发送自定义事件 自定义功能 CocosToJava
  295. * @description 发送统计事件
  296. * @param key 事件的key值
  297. * @param value 事件的value值
  298. */
  299. public static sendEventValue(key: string, value: string, value1: number) {
  300. if (cc.sys.os == cc.sys.OS_ANDROID) {
  301. this.callStaticMethod(this._JSB_ANDROID_PATH, "sendEventValue", "(Ljava/lang/String;Ljava/lang/String;F)V", key, value, value1);
  302. }
  303. else if (cc.sys.os == cc.sys.OS_IOS) {
  304. }
  305. }
  306. /**
  307. * 设置人物属性
  308. * @param type 0 set 1 add
  309. * @param property 属性名
  310. * @param value 数值
  311. */
  312. public static setTAEventUser(type: number, property: string, value: number) {
  313. if (cc.sys.os == cc.sys.OS_ANDROID) {
  314. this.callStaticMethod(this._JSB_ANDROID_PATH, "setTAEventUser", "(ILjava/lang/String;F)V", type, property, value);
  315. }
  316. else if (cc.sys.os == cc.sys.OS_IOS) {
  317. }
  318. }
  319. /**
  320. * 设置人物属性
  321. * @param type 0 set 1 add
  322. * @param property 属性名
  323. * @param value 数值
  324. */
  325. public static setTAEventUserStr(type: number, property: string, value: string) {
  326. if (cc.sys.os == cc.sys.OS_ANDROID) {
  327. this.callStaticMethod(this._JSB_ANDROID_PATH, "setTAEventUserStr", "(ILjava/lang/String;Ljava/lang/String;)V", type, property, value);
  328. }
  329. else if (cc.sys.os == cc.sys.OS_IOS) {
  330. }
  331. }
  332. /** 设置人物uin到数数
  333. * id uin
  334. */
  335. public static setTAUserID(id: string) {
  336. if (cc.sys.os == cc.sys.OS_ANDROID) {
  337. this.callStaticMethod(this._JSB_ANDROID_PATH, "setTAUserID", "(Ljava/lang/String;)V", id);
  338. }
  339. else if (cc.sys.os == cc.sys.OS_IOS) {
  340. }
  341. }
  342. /**
  343. * 微信授权
  344. * @description 微信SDK功能 CocosToJava
  345. */
  346. public static WxAuth() {
  347. if (cc.sys.os == cc.sys.OS_ANDROID) {
  348. this.callStaticMethod(this._JSB_ANDROID_PATH, "WxAuth", "()V");
  349. }
  350. else if (cc.sys.os == cc.sys.OS_IOS) {
  351. this.callStaticMethod("AppController", "WxAuth", "");
  352. }
  353. }
  354. /**
  355. * 获取授权code
  356. * @description 微信SDK功能 JavaToCocos
  357. * @param code 微信code(Java返回)
  358. */
  359. public static onGetWxAccessCode(code) {
  360. // 暂时注释,需要网络通信
  361. gData.wechatData.code = code;
  362. console.log("=== gData.wechatData.code", gData.wechatData.code);
  363. gData.loginData.wxLogin();
  364. }
  365. public static WXLaunchMiniProgram(ghId, path) {
  366. if (cc.sys.os == cc.sys.OS_ANDROID) {
  367. this.callStaticMethod(this._JSB_ANDROID_PATH, "WXLaunchMiniProgram", "(Ljava/lang/String;Ljava/lang/String;)V", ghId, path);
  368. }
  369. else if (cc.sys.os == cc.sys.OS_IOS) {
  370. this.callStaticMethod("AppController", "WXLaunchMiniProgram", "");
  371. }
  372. }
  373. /**
  374. * 微信打开小游戏
  375. * @description 微信SDK功能 CocosToJava
  376. */
  377. public static OpenMiniGame() {
  378. if (cc.sys.os == cc.sys.OS_ANDROID) {
  379. this.callStaticMethod(this._JSB_ANDROID_PATH, "OpenMiniGame", "()V");
  380. }
  381. else if (cc.sys.os == cc.sys.OS_IOS) {
  382. this.callStaticMethod("AppController", "WxAuth", "");
  383. }
  384. }
  385. /**
  386. * 分享成微信小游戏
  387. * @description 微信SDK功能 CocosToJava
  388. */
  389. public static ShareToMiniGame() {
  390. if (cc.sys.os == cc.sys.OS_ANDROID) {
  391. this.callStaticMethod(this._JSB_ANDROID_PATH, "ShareToMiniGame", "()V");
  392. }
  393. else if (cc.sys.os == cc.sys.OS_IOS) {
  394. this.callStaticMethod("AppController", "WxAuth", "");
  395. }
  396. }
  397. /**
  398. * 分享图片
  399. * @description 微信SDK功能 CocosToJava
  400. */
  401. public static sharePic() {
  402. if (cc.sys.platform == cc.sys.WECHAT_GAME) {
  403. return
  404. }
  405. if (cc.sys.os == cc.sys.OS_ANDROID) {
  406. jsb.reflection.callStaticMethod(this._JSB_ANDROID_PATH, "sharePic", "()V");
  407. }
  408. else if (cc.sys.os == cc.sys.OS_IOS) {
  409. jsb.reflection.callStaticMethod("GameConfig", "sharePic:", "");
  410. }
  411. }
  412. /** 打开微信 */
  413. public static openWx() {
  414. if (cc.sys.os == cc.sys.OS_ANDROID) {
  415. this.callStaticMethod(this._JSB_ANDROID_PATH, "openWx", "()V");
  416. }
  417. else if (cc.sys.os == cc.sys.OS_IOS) {
  418. this.callStaticMethod("AppController", "openWx", "");
  419. }
  420. }
  421. /** 下载文件
  422. * @param url 下载地址
  423. * @param fileName 存储文件名称
  424. * @param successCb 成功回调
  425. * @param failCb 失败回调
  426. * @param progressCb 下载进度回调
  427. */
  428. public static downFile2Local(url, fileName, successCb, failCb, progressCb): any {
  429. var fullPath = jsb.fileUtils.getWritablePath() + fileName
  430. if (jsb) {
  431. var downloader = new jsb.Downloader();
  432. downloader.setOnFileTaskSuccess(function () {
  433. console.log("DownLoadM setOnFileTaskSuccess", "")
  434. if (successCb) {
  435. console.log("DownLoadM result... ", jsb.fileUtils.isFileExist(fullPath))
  436. console.log("DownLoadM setOnFileTaskSuccess fullPath...", fullPath)
  437. successCb(fullPath);
  438. }
  439. });
  440. downloader.setOnTaskError(function (task: any, errorCode: number, errorCodeInternal: number, errorStr: string) {
  441. console.log("DownLoadM setOnTaskError", errorCode + " ; " + errorCodeInternal + " ; " + errorStr)
  442. if (failCb) {
  443. failCb(fullPath);
  444. }
  445. });
  446. downloader.setOnTaskProgress(function (task: any, bytesReceived: number, totalBytesReceived: number, totalBytesExpected: number) {
  447. console.log("DownLoadM", bytesReceived + " ; " + totalBytesReceived + " ; " + totalBytesExpected)
  448. if (progressCb) {
  449. progressCb(bytesReceived, totalBytesReceived, totalBytesExpected)
  450. }
  451. });
  452. downloader.createDownloadFileTask(url, fullPath);//创建下载任务
  453. return downloader
  454. }
  455. }
  456. private static singleClick = true;
  457. /** 上传开屏广告星云埋点 */
  458. public static updateSplashAdLog(info) {
  459. let arr = info.split('#')
  460. // console.log('updateSplashAdLog placementId ', arr[0])
  461. // console.log('updateSplashAdLog callbackInfo ', arr[1])
  462. let type = 6;
  463. if (arr[2]) {
  464. type = parseInt(arr[2]);
  465. }
  466. let data = JSON.parse(arr[1])
  467. gData.adData.updateADLog(type, arr[0], data);
  468. if (type == 6) {
  469. let times = mk.storage.getStorage('ad_openEcpm');
  470. if (!times) {
  471. times = 1;
  472. }
  473. else {
  474. times++;
  475. }
  476. mk.storage.setStorage('ad_openEcpm', times);
  477. if (times <= 300) {
  478. if (times <= 50) {
  479. mk.data.sendDataEventValue(DataEventId.ad_openEcpm, `ad_video_ecpm${times}`, data.adsource_price);
  480. }
  481. else if (times % 10 == 0) {
  482. mk.data.sendDataEventValue(DataEventId.ad_openEcpm, `ad_video_ecpm${times}`, data.adsource_price);
  483. }
  484. }
  485. }
  486. else if (type == 54) {
  487. mk.data.sendDataEvent(DataEventId.ad_click, '开屏点击');
  488. if (this.singleClick) {
  489. this.singleClick = false;
  490. gData.adData.updateADLog(74, arr[0], data);
  491. }
  492. }
  493. }
  494. /** 获取阿里风控设备token */
  495. public static getAliRiskDeviceToken() {
  496. let token = '';
  497. if (cc.sys.os == cc.sys.OS_ANDROID) {
  498. token = this.callStaticMethod(this._JSB_ANDROID_PATH, "getAliDeviceToken", "()Ljava/lang/String;");
  499. }
  500. else if (cc.sys.os == cc.sys.OS_IOS) {
  501. token = this.callStaticMethod("AppController", "openWx", "");
  502. }
  503. return token;
  504. }
  505. /** 初始化ysdk */
  506. public static ysdkInit() {
  507. if (cc.sys.os == cc.sys.OS_ANDROID) {
  508. this.callStaticMethod(this._JSB_ANDROID_PATH_JSDK, "init", "()V");
  509. }
  510. else if (cc.sys.os == cc.sys.OS_IOS) {
  511. this.callStaticMethod("AppController", "init", "");
  512. }
  513. }
  514. /** ysdk登录 */
  515. public static autologin() {
  516. if (cc.sys.os == cc.sys.OS_ANDROID) {
  517. this.callStaticMethod(this._JSB_ANDROID_PATH_JSDK, "autologin", "()V");
  518. }
  519. else if (cc.sys.os == cc.sys.OS_IOS) {
  520. this.callStaticMethod("AppController", "autologin", "");
  521. }
  522. }
  523. public static ysdkAuthSuccess() {
  524. gData.loginData.passAnti = true;
  525. }
  526. /** 统计时长 */
  527. public static updateActivateLog(sessionDuration) {
  528. console.log('test>>> updateActivateLog ', sessionDuration)
  529. let data = {
  530. 'appId': gData.appData.appId,
  531. 'uin': gData.loginData.uin,
  532. 'sessionDuration': sessionDuration
  533. }
  534. mk.http.sendData('activateLog', data);
  535. }
  536. /** 屏蔽对应广告位的广告源 */
  537. public static setFilterAdSourceIdList(adID: string, adSourceStr: string) {
  538. if (cc.sys.os == cc.sys.OS_ANDROID) {
  539. jsb.reflection.callStaticMethod(this._JSB_ANDROID_PATH, "setFilterAdSourceIdList", "(Ljava/lang/String;Ljava/lang/String;)V", adID, adSourceStr);
  540. }
  541. else if (cc.sys.os == cc.sys.OS_IOS) {
  542. jsb.reflection.callStaticMethod("GameConfig", "setFilterAdSourceIdList:", "");
  543. }
  544. }
  545. /** 数盟获取设备id */
  546. public static getQueryID() {
  547. if (cc.sys.os == cc.sys.OS_ANDROID) {
  548. jsb.reflection.callStaticMethod(this._JSB_ANDROID_PATH, "getQueryID", "()V");
  549. }
  550. else if (cc.sys.os == cc.sys.OS_IOS) {
  551. jsb.reflection.callStaticMethod("GameConfig", "getQueryID:", "");
  552. }
  553. }
  554. /** 设置数盟设备id */
  555. public static setShuzilmEquipID(szlm_did: string) {
  556. mk.shuzilmM.setShuzilmEquipID(szlm_did);
  557. }
  558. /** 设置同盾设备id */
  559. public static setTDEquipID(equipID) {
  560. mk.tongdunM.setTDEquipID(equipID);
  561. }
  562. /** 同盾初始化 */
  563. public static tongdunInit() {
  564. if (cc.sys.os == cc.sys.OS_ANDROID) {
  565. jsb.reflection.callStaticMethod(this._JSB_ANDROID_PATH, "tongdunInit", "()V");
  566. }
  567. else if (cc.sys.os == cc.sys.OS_IOS) {
  568. jsb.reflection.callStaticMethod("GameConfig", "tongdunInit:", "");
  569. }
  570. }
  571. }
  572. window['JsbMgr'] = JsbSystem