Crasheye.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. /**
  2. * Unity Plugins Version 2.2.10
  3. *
  4. * android version 2.2.9
  5. * iOS version 2.7.3
  6. * window version 1.0.0
  7. */
  8. using System.Text;
  9. using UnityEngine;
  10. using System.Collections;
  11. using System.Collections.Generic;
  12. using System;
  13. using System.IO;
  14. using System.Runtime.InteropServices;
  15. using System.Security.Cryptography;
  16. using System.Text.RegularExpressions;
  17. #if UNITY_ANDROID || UNITY_IPHONE || UNITY_IOS
  18. using com.xsj.Crasheye.U3D;
  19. #endif
  20. #if UNITY_ANDROID
  21. using com.xsj.Crasheye.U3D.Android;
  22. #endif
  23. #if UNITY_IPHONE || UNITY_IOS
  24. using com.xsj.Crasheye.U3D.IOS;
  25. #endif
  26. public class Crasheye : MonoBehaviour
  27. {
  28. public delegate void FnOnCrashCallback(bool bCaptureSucceed, string cpszCrashReportFile);
  29. public string YourAppKeyForAndroid = "YourAppKeyForAndroid";
  30. public string YourChannelIdForAndroid = "YourChannelIdForAndroid";
  31. public string YourAppKeyForIOS = "YourAppKeyForIOS";
  32. public string YourChannelIdForIOS = "YourChannelIdForIOS";
  33. public string YourAppKeyForPC = "YourAppKeyForPC";
  34. public string YourChannelIdForPC = "YourChannelIdForPC";
  35. #if UNITY_ANDROID || UNITY_IPHONE || UNITY_IOS
  36. public static CrasheyeLib crasheyeLib = null;
  37. #endif
  38. #if UNITY_ANDROID || UNITY_IPHONE || UNITY_IOS || UNITY_STANDALONE_WIN
  39. private static string YourChannelId = "NA";
  40. #endif
  41. public static void AddCustomLog(string collectFile)
  42. {
  43. #if UNITY_STANDALONE_WIN && !UNITY_EDITOR
  44. DumpForPC.AddCustomLog(collectFile);
  45. #endif
  46. }
  47. public static void AddCustomLogDirectory(string CollectLogDirectory)
  48. {
  49. #if UNITY_STANDALONE_WIN && !UNITY_EDITOR
  50. DumpForPC.AddCustomLogDirectory(CollectLogDirectory);
  51. #endif
  52. }
  53. void Start()
  54. {
  55. DontDestroyOnLoad(gameObject);
  56. if (Application.platform == RuntimePlatform.Android)
  57. {
  58. #if UNITY_ANDROID
  59. SetChannelID(YourChannelIdForAndroid);
  60. StartInitCrasheye(YourAppKeyForAndroid);
  61. #endif
  62. }
  63. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  64. {
  65. #if UNITY_IPHONE || UNITY_IOS
  66. SetChannelID(YourChannelIdForIOS);
  67. StartInitCrasheye(YourAppKeyForIOS);
  68. #endif
  69. }
  70. else if (Application.platform == RuntimePlatform.WindowsPlayer)
  71. {
  72. #if UNITY_STANDALONE_WIN
  73. SetChannelID(YourAppKeyForPC);
  74. StartInitCrasheye(YourAppKeyForPC);
  75. #endif
  76. }
  77. }
  78. /// <summary>
  79. /// SetURL
  80. /// </summary>
  81. /// <param name="SetUrl"></param>
  82. public static void SetURL(string url)
  83. {
  84. if (Application.platform == RuntimePlatform.Android)
  85. {
  86. #if UNITY_ANDROID
  87. CrasheyeForAndroid.SetURL(url);
  88. #endif
  89. }
  90. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  91. {
  92. #if UNITY_IPHONE || UNITY_IOS
  93. CrasheyeForIOS.SetURL(url);
  94. #endif
  95. }
  96. else if (Application.platform == RuntimePlatform.WindowsPlayer)
  97. {
  98. #if UNITY_STANDALONE_WIN
  99. DumpForPC.SetURL(url);
  100. #endif
  101. }
  102. }
  103. /// <summary>
  104. /// 设置Dump是否强制上报(忽略玩家在DumpReport界面上的选择)
  105. ///
  106. /// </summary>
  107. /// <param name="isForceUpload"> isForceUpload 是否设置Dump强制上报 </param>
  108. public static void SetForceUpload(bool isForceUpload)
  109. {
  110. Debug.Log("SetForceUpload");
  111. #if UNITY_STANDALONE_WIN
  112. DumpForPC.SetForceUpload(isForceUpload);
  113. #endif
  114. }
  115. /// <summary>
  116. /// 启动Crasheye
  117. /// </summary>
  118. /// <param name="Your_AppKey"></param>
  119. public static void StartInitCrasheye(string Your_AppKey)
  120. {
  121. RegisterLogCallback();
  122. if (Application.platform == RuntimePlatform.Android)
  123. {
  124. #if UNITY_ANDROID
  125. CrasheyeForAndroid.Init(Your_AppKey, YourChannelId);
  126. #endif
  127. }
  128. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  129. {
  130. #if UNITY_IPHONE || UNITY_IOS
  131. CrasheyeForIOS.Init(Your_AppKey, YourChannelId);
  132. #endif
  133. }
  134. else if (Application.platform == RuntimePlatform.WindowsPlayer)
  135. {
  136. #if UNITY_STANDALONE_WIN
  137. DumpForPC.Init(Your_AppKey, YourChannelId);
  138. #endif
  139. }
  140. //bool result = Crasheye.PushLogTrace("Crasheye Demo Push Log");
  141. //Debug.Log("PushLogTrace:" + result);
  142. }
  143. /// <summary>
  144. /// 注册脚本捕获
  145. /// </summary>
  146. public static void RegisterLogCallback()
  147. {
  148. if (Application.platform == RuntimePlatform.Android)
  149. {
  150. #if UNITY_ANDROID
  151. crasheyeLib = new LibForAndroid();
  152. CrasheyeForAndroid.setInternalExtraData();
  153. #endif
  154. }
  155. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  156. {
  157. #if UNITY_IPHONE || UNITY_IOS
  158. crasheyeLib = new LibForiOS();
  159. #endif
  160. }
  161. else if (Application.platform == RuntimePlatform.WindowsPlayer)
  162. {
  163. #if UNITY_STANDALONE_WIN
  164. Debug.Log("RegisterLogCallback");
  165. AppDomain.CurrentDomain.UnhandledException += DumpForPC.OnHandleUnresolvedException;
  166. SetRegisterLogFunction(DumpForPC.OnHandleLogCallback);
  167. Application.logMessageReceived += RegisterLogFunction;
  168. #endif
  169. }
  170. #if UNITY_ANDROID || UNITY_IPHONE || UNITY_IOS
  171. if (crasheyeLib == null)
  172. {
  173. return;
  174. }
  175. System.AppDomain.CurrentDomain.UnhandledException += new System.UnhandledExceptionEventHandler(crasheyeLib.OnHandleUnresolvedException);
  176. SetRegisterLogFunction(crasheyeLib.OnHandleLogCallback);
  177. #if UNITY_5
  178. Application.logMessageReceived += RegisterLogFunction;
  179. #else
  180. Application.RegisterLogCallback(RegisterLogFunction);
  181. #endif
  182. #endif
  183. }
  184. private static void RegisterLogFunction(string logString, string stackTrace, LogType type)
  185. {
  186. #if (UNITY_IPHONE || UNITY_IOS) && !UNITY_EDITOR
  187. if (Application.platform == RuntimePlatform.IPhonePlayer)
  188. {
  189. CrasheyeForIOS.SaveLogger(logString);
  190. }
  191. if (CrasheyeForIOS.GetLoggingLines() > 0 &&
  192. Application.platform == RuntimePlatform.IPhonePlayer &&
  193. (type == LogType.Assert || type == LogType.Exception)
  194. )
  195. {
  196. CrasheyeForIOS.addLog(CrasheyeForIOS.GetLogger());
  197. }
  198. #endif
  199. if (m_RegisterLog != null)
  200. {
  201. m_RegisterLog(logString, stackTrace, type);
  202. }
  203. #if (UNITY_IPHONE || UNITY_IOS) && !UNITY_EDITOR
  204. if (CrasheyeForIOS.GetLoggingLines() > 0 &&
  205. Application.platform == RuntimePlatform.IPhonePlayer &&
  206. (type == LogType.Assert || type == LogType.Exception)
  207. )
  208. {
  209. CrasheyeForIOS.removeLog();
  210. }
  211. #endif
  212. }
  213. public delegate void RegisterLog(string logString, string stackTrace, LogType type);
  214. private static RegisterLog m_RegisterLog = null;
  215. /// <summary>
  216. /// 设置用户的脚本回调的函数
  217. /// </summary>
  218. /// <param name="registerLogCBFun"></param>
  219. public static void SetRegisterLogFunction(RegisterLog registerLogCBFun)
  220. {
  221. Debug.Log("SetRegisterLogFunction");
  222. m_RegisterLog += registerLogCBFun;
  223. }
  224. /// <summary>
  225. /// 发送脚本异常
  226. /// </summary>
  227. /// <param name="ex">Excepiton Info</param>
  228. public static void SendScriptException(Exception ex)
  229. {
  230. if (Application.platform == RuntimePlatform.Android)
  231. {
  232. #if UNITY_ANDROID
  233. crasheyeLib.LibSendScriptException(ex.Message, ex.StackTrace);
  234. #endif
  235. }
  236. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  237. {
  238. #if UNITY_IPHONE || UNITY_IOS
  239. crasheyeLib.LibSendScriptException(ex.Message, ex.StackTrace);
  240. #endif
  241. }
  242. }
  243. /// <summary>
  244. /// 上报脚本异常
  245. /// </summary>
  246. /// <param name="errorTitle">错误的标题</param>
  247. /// <param name="stacktrace">错误堆栈信息</param>
  248. /// <param name="language">语言</param>
  249. public static void SendScriptException(string errorTitle, string stacktrace, string language)
  250. {
  251. if (Application.platform == RuntimePlatform.Android)
  252. {
  253. #if UNITY_ANDROID
  254. crasheyeLib.LibSendScriptException(errorTitle, stacktrace, language);
  255. #endif
  256. }
  257. else if(Application.platform == RuntimePlatform.IPhonePlayer)
  258. {
  259. #if UNITY_IPHONE || UNITY_IOS
  260. crasheyeLib.LibSendScriptException(errorTitle, stacktrace);
  261. #endif
  262. } else if (Application.platform == RuntimePlatform.WindowsPlayer)
  263. {
  264. #if UNITY_STANDALONE_WIN
  265. DumpForPC.SendScriptException(errorTitle, stacktrace, language);
  266. #endif
  267. }
  268. }
  269. /// <summary>
  270. /// 设置渠道号
  271. /// </summary>
  272. /// <param name="yourChannelID"></param>
  273. public static void SetChannelID(string yourChannelID)
  274. {
  275. if (String.IsNullOrEmpty(yourChannelID))
  276. {
  277. Debug.LogError("set channel id value is null or empty!");
  278. return;
  279. }
  280. if (yourChannelID.Equals("YourChannelIdForAndroid") || yourChannelID.Equals("YourChannelIdForIOS"))
  281. {
  282. return;
  283. }
  284. #if UNITY_ANDROID || UNITY_IPHONE || UNITY_IOS || UNITY_STANDALONE_WIN
  285. YourChannelId = yourChannelID;
  286. #endif
  287. }
  288. /// <summary>
  289. /// 设置是否只在wifi下上报报告文件
  290. /// </summary>
  291. /// <param name="enabled"></param>
  292. public static void SetFlushOnlyOverWiFi(bool enabled)
  293. {
  294. if (Application.platform == RuntimePlatform.Android)
  295. {
  296. #if UNITY_ANDROID
  297. CrasheyeForAndroid.SetFlushOnlyOverWiFi(enabled);
  298. #endif
  299. }
  300. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  301. {
  302. #if UNITY_IPHONE || UNITY_IOS
  303. CrasheyeForIOS.SetFlushOnlyOverWiFi(enabled);
  304. #endif
  305. }
  306. }
  307. /// <summary>
  308. /// 设置该版本是否为测试版本
  309. /// </summary>
  310. /// <param name="isBeta">是否为测试版本</param>
  311. public static void SetIsBetaVersion(bool isBeta)
  312. {
  313. if (Application.platform == RuntimePlatform.Android)
  314. {
  315. #if UNITY_ANDROID
  316. CrasheyeForAndroid.SetIsBetaVersion(isBeta);
  317. #endif
  318. }
  319. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  320. {
  321. #if UNITY_IPHONE || UNITY_IOS
  322. CrasheyeForIOS.SetBeta(isBeta);
  323. #endif
  324. }
  325. else if (Application.platform == RuntimePlatform.WindowsPlayer)
  326. {
  327. #if UNITY_STANDALONE_WIN && !UNITY_EDITOR
  328. DumpForPC.SetBeta();
  329. #endif
  330. }
  331. }
  332. /// <summary>
  333. /// 设置版本号信息
  334. /// </summary>
  335. /// <param name="yourAppVersion">App版本号</param>
  336. public static void SetAppVersion(string yourAppVersion)
  337. {
  338. if (Application.platform == RuntimePlatform.Android)
  339. {
  340. #if UNITY_ANDROID
  341. CrasheyeForAndroid.SetAppVersion(yourAppVersion);
  342. #endif
  343. }
  344. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  345. {
  346. #if UNITY_IPHONE || UNITY_IOS
  347. CrasheyeForIOS.SetAppVersion(yourAppVersion);
  348. #endif
  349. }
  350. else if (Application.platform == RuntimePlatform.WindowsPlayer)
  351. {
  352. #if UNITY_STANDALONE_WIN
  353. DumpForPC.SetAppVersion(yourAppVersion);
  354. #endif
  355. }
  356. }
  357. /// <summary>
  358. /// 设置用户信息
  359. /// </summary>
  360. /// <param name="setUserIdentifier">用户标识</param>
  361. public static void SetUserIdentifier(string userIdentifier)
  362. {
  363. if(string.IsNullOrEmpty(userIdentifier))
  364. {
  365. return;
  366. }
  367. if (Application.platform == RuntimePlatform.Android)
  368. {
  369. #if UNITY_ANDROID
  370. CrasheyeForAndroid.SetUserIdentifier(userIdentifier);
  371. #endif
  372. }
  373. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  374. {
  375. #if UNITY_IPHONE || UNITY_IOS
  376. CrasheyeForIOS.SetUserIdentifier(userIdentifier);
  377. #endif
  378. }
  379. else if (Application.platform == RuntimePlatform.WindowsPlayer)
  380. {
  381. #if UNITY_STANDALONE_WIN
  382. DumpForPC.SetUserIdentifier_UTF8(userIdentifier);
  383. #endif
  384. }
  385. }
  386. /// <summary>
  387. /// 如果启动了C#堆栈回溯可能会导致某些机型出现宕机
  388. /// </summary>
  389. public static void EnableCSharpStackTrace()
  390. {
  391. #if UNITY_ANDROID
  392. CrasheyeForAndroid.EnableCSharpStackTrace();
  393. #endif
  394. }
  395. /// <summary>
  396. /// 添加自定义数据
  397. /// </summary>
  398. /// <param name="key">Key.</param>
  399. /// <param name="value">Value.</param>
  400. public static void AddExtraData(string key, string value)
  401. {
  402. if (Application.platform == RuntimePlatform.Android)
  403. {
  404. #if UNITY_ANDROID
  405. CrasheyeForAndroid.AddExtraData(key, value);
  406. #endif
  407. }
  408. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  409. {
  410. #if UNITY_IPHONE || UNITY_IOS
  411. CrasheyeForIOS.AddExtraData(key, value);
  412. #endif
  413. }
  414. else if (Application.platform == RuntimePlatform.WindowsPlayer)
  415. {
  416. #if UNITY_STANDALONE_WIN
  417. DumpForPC.AddExtraData(key,value);
  418. #endif
  419. }
  420. }
  421. public static void AddExtraDataUTF8(string key, string value)
  422. {
  423. if (Application.platform == RuntimePlatform.Android)
  424. {
  425. #if UNITY_ANDROID
  426. CrasheyeForAndroid.AddExtraData(key, value);
  427. #endif
  428. }
  429. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  430. {
  431. #if UNITY_IPHONE || UNITY_IOS
  432. CrasheyeForIOS.AddExtraData(key, value);
  433. #endif
  434. }
  435. else if (Application.platform == RuntimePlatform.WindowsPlayer)
  436. {
  437. #if UNITY_STANDALONE_WIN
  438. DumpForPC.AddExtraDataUTF8(key, value);
  439. #endif
  440. }
  441. }
  442. /// <summary>
  443. /// 获取自定义数据
  444. /// </summary>
  445. /// <param name="key">Key</param>
  446. /// <returns></returns>
  447. public static string GetExtraData(string key)
  448. {
  449. string extraData = "";
  450. if (string.IsNullOrEmpty(key))
  451. {
  452. return extraData;
  453. }
  454. if (Application.platform == RuntimePlatform.Android)
  455. {
  456. #if UNITY_ANDROID
  457. extraData = CrasheyeForAndroid.GetExtraData(key);
  458. #endif
  459. }
  460. else
  461. {
  462. #if UNITY_IPHONE || UNITY_IOS
  463. extraData = CrasheyeForIOS.GetExtraData(key);
  464. #endif
  465. }
  466. return extraData;
  467. }
  468. /// <summary>
  469. /// 移除自定义值
  470. /// </summary>
  471. /// <param name="key">Key</param>
  472. public static void RemoveExtraData(string key)
  473. {
  474. if (string.IsNullOrEmpty(key))
  475. {
  476. return;
  477. }
  478. if (Application.platform == RuntimePlatform.Android)
  479. {
  480. #if UNITY_ANDROID
  481. CrasheyeForAndroid.RemoveExtraData(key);
  482. #endif
  483. }
  484. else if(Application.platform == RuntimePlatform.IPhonePlayer)
  485. {
  486. #if UNITY_IPHONE || UNITY_IOS
  487. CrasheyeForIOS.RemoveExtraData(key);
  488. #endif
  489. }
  490. }
  491. /// <summary>
  492. /// 清除自定义数据
  493. /// </summary>
  494. public static void CleanExtraData()
  495. {
  496. if (Application.platform == RuntimePlatform.Android)
  497. {
  498. #if UNITY_ANDROID
  499. CrasheyeForAndroid.CleanExtraData();
  500. #endif
  501. }
  502. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  503. {
  504. #if UNITY_IPHONE || UNITY_IOS
  505. CrasheyeForIOS.ClearExtraData();
  506. #endif
  507. }
  508. }
  509. /// <summary>
  510. /// 设置打点数据接口
  511. /// </summary>
  512. /// <param name="breadcrumb">Breadcrumb.</param>
  513. public static void SetBreadCrumbType(Int32 type)
  514. {
  515. if (Application.platform == RuntimePlatform.Android)
  516. {
  517. #if UNITY_ANDROID
  518. // TODO
  519. #endif
  520. }
  521. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  522. {
  523. #if UNITY_IPHONE || UNITY_IOS
  524. // TODO
  525. #endif
  526. }
  527. else if (Application.platform == RuntimePlatform.WindowsPlayer)
  528. {
  529. #if UNITY_STANDALONE_WIN
  530. DumpForPC.SetBreadCrumbType(type);
  531. #endif
  532. }
  533. }
  534. /// <summary>
  535. /// 打点数据
  536. /// </summary>
  537. /// <param name="breadcrumb">Breadcrumb.</param>
  538. public static void LeaveBreadcrumb(string breadcrumb)
  539. {
  540. if (string.IsNullOrEmpty(breadcrumb))
  541. {
  542. return;
  543. }
  544. if (Application.platform == RuntimePlatform.Android)
  545. {
  546. #if UNITY_ANDROID
  547. CrasheyeForAndroid.LeaveBreadcrumb(breadcrumb);
  548. #endif
  549. }
  550. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  551. {
  552. #if UNITY_IPHONE || UNITY_IOS
  553. CrasheyeForIOS.LeaveBreadcrumb(breadcrumb);
  554. #endif
  555. } else if (Application.platform == RuntimePlatform.WindowsPlayer)
  556. {
  557. #if UNITY_STANDALONE_WIN
  558. DumpForPC.leaveBreadcrumb(breadcrumb);
  559. #endif
  560. }
  561. }
  562. /// <summary>
  563. /// 指定获取应用程序log日志的行数
  564. /// </summary>
  565. /// <param name="lines">需要获取log行数</param>
  566. public static void SetLogging(int lines)
  567. {
  568. if (Application.platform == RuntimePlatform.Android)
  569. {
  570. #if UNITY_ANDROID
  571. CrasheyeForAndroid.SetLogging(lines);
  572. #endif
  573. }
  574. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  575. {
  576. #if UNITY_IPHONE || UNITY_IOS
  577. CrasheyeForIOS.SetLogging(lines);
  578. #endif
  579. }
  580. }
  581. /// <summary>
  582. /// 获取应用程序log日志关键字过滤
  583. /// </summary>
  584. /// <param name="filter">需要过滤关键字</param>
  585. public static void SetLogging(string filter)
  586. {
  587. if (string.IsNullOrEmpty(filter))
  588. {
  589. return;
  590. }
  591. if (Application.platform == RuntimePlatform.Android)
  592. {
  593. #if UNITY_ANDROID
  594. CrasheyeForAndroid.SetLogging(filter);
  595. #endif
  596. }
  597. }
  598. /// <summary>
  599. /// 获取应用程序log日志(过滤条件:关键字过滤+行数)
  600. /// </summary>
  601. /// <param name="lines">需要获取的行数</param>
  602. /// <param name="filter">需要过滤的关键字</param>
  603. public static void SetLogging(int lines, string filter)
  604. {
  605. if (string.IsNullOrEmpty(filter))
  606. {
  607. return;
  608. }
  609. if (Application.platform == RuntimePlatform.Android)
  610. {
  611. #if UNITY_ANDROID
  612. CrasheyeForAndroid.SetLogging(lines, filter);
  613. #endif
  614. }
  615. else if(Application.platform == RuntimePlatform.IPhonePlayer)
  616. {
  617. #if UNITY_IPHONE || UNITY_IOS
  618. CrasheyeForIOS.SetLogging(lines, filter);
  619. #endif
  620. }
  621. }
  622. /// <summary>
  623. /// 获取sdk版本号
  624. /// </summary>
  625. /// <returns></returns>
  626. public static string GetAppVersion()
  627. {
  628. if (Application.platform == RuntimePlatform.Android)
  629. {
  630. #if UNITY_ANDROID
  631. return CrasheyeForAndroid.GetAppVersion();
  632. #endif
  633. }
  634. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  635. {
  636. #if UNITY_IPHONE || UNITY_IOS
  637. return CrasheyeForIOS.GetAppVersion();
  638. #endif
  639. }
  640. return "NA";
  641. }
  642. public static bool SetBackgroundUpload(bool isBackgroundUpload)
  643. {
  644. #if UNITY_STANDALONE_WIN
  645. return DumpForPC.SetBackgroundUpload(isBackgroundUpload);
  646. #endif
  647. return false;
  648. }
  649. public static bool SetCrashCallback(FnOnCrashCallback pCallback)
  650. {
  651. #if UNITY_STANDALONE_WIN
  652. return DumpForPC.SetOnMiniDumpCreateCallBack((bCaptureSucceed, cpszCrashReportFile)=>{
  653. string szCrashReportFile = Marshal.PtrToStringUni(cpszCrashReportFile);
  654. pCallback?.Invoke(bCaptureSucceed, szCrashReportFile);
  655. });
  656. #endif
  657. return false;
  658. }
  659. public static bool PushLogTrace(string cpszMessage)
  660. {
  661. #if UNITY_STANDALONE_WIN
  662. return DumpForPC.PushLogTrace(cpszMessage);
  663. #endif
  664. return false;
  665. }
  666. }