PottingMobileServicesAndroid.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using PottingMobileSDK.MiniJSON;
  4. using UnityEngine;
  5. public class PottingMobileServicesAndroid : PottingMobileServicesBase
  6. {
  7. private static readonly AndroidJavaClass PluginClass = new AndroidJavaClass("com.youloft.api.ApiManager");
  8. static PottingMobileServicesAndroid()
  9. {
  10. InitManager();
  11. }
  12. /**
  13. * 渠道下单接口,根据不同渠道需要的数据不同
  14. * 返回的数据结构不同,前端需要根据情况解析
  15. *
  16. * @param channel 渠道
  17. * @param goodsid 商品ID
  18. */
  19. public static void _channelPayOrder(int channel, string goodsid)
  20. {
  21. PluginClass.CallStatic(
  22. "channelPayOrder", channel, goodsid);
  23. }
  24. /**
  25. * 获取当前游戏,渠道的最新版本
  26. * 返回结果无加密
  27. *
  28. * @param channel 渠道
  29. */
  30. public static void _channelPayGetAppVersion(int channel)
  31. {
  32. PluginClass.CallStatic(
  33. "channelPayGetAppVersion", channel + "");
  34. }
  35. /**
  36. * 获取服务器配置
  37. * appver:如果不需要根据版本判断可以串0
  38. * lastver:每次全新获取传0
  39. * 返回结果加密
  40. * @param appVer
  41. * @param lastVer
  42. */
  43. public static void _configSync(string appVer, int lastVer)
  44. {
  45. PluginClass.CallStatic(
  46. "configSync", appVer, lastVer);
  47. }
  48. /**
  49. * 兑换码兑换接口
  50. *
  51. * @param redeemcode 兑换码
  52. */
  53. public static void _dedeemConsume(string redeemcode)
  54. {
  55. PluginClass.CallStatic(
  56. "dedeemConsume", redeemcode,null);
  57. }
  58. /**
  59. * 登录接口
  60. *
  61. * @param id 设备ID 或者第三方登录平台的ID
  62. * @param type 登录类型
  63. * @param name 用户昵称
  64. * @param icon 用户头像链接
  65. */
  66. public static void _userLogin(string id, int type, string name, string icon)
  67. {
  68. PluginClass.CallStatic(
  69. "userLogin", id, type, name, icon);
  70. }
  71. /**
  72. * 获取(提交)存档到服务器
  73. * 1.每次启动游戏优先获取存档
  74. * 2.当有需要更新的存档时提交服务器
  75. * 提交存档时服务器会默认覆盖以前的存档不会做其他判断
  76. * 请求需要签名,返回数据有加密
  77. *
  78. * @param archive
  79. * @param archiveVersion
  80. */
  81. public static void _userSync(string archive, int archiveVersion)
  82. {
  83. PluginClass.CallStatic(
  84. "userSync", archive, archiveVersion);
  85. }
  86. /**
  87. * 心跳检测,判断当前客户端登陆是否有效
  88. * 请求需要签名,返回数据无加密
  89. */
  90. public static void _userHeartbeat()
  91. {
  92. PluginClass.CallStatic(
  93. "userHeartbeat");
  94. }
  95. /**
  96. * 恢复购买,查看已完成的所有订单,以及消耗状态
  97. * 请求需要签名,返回结果有加密
  98. */
  99. public static void _userResumepurchase()
  100. {
  101. PluginClass.CallStatic(
  102. "userResumepurchase");
  103. }
  104. /**
  105. * 订单消耗
  106. * 请求需要签名,返回结果有加密
  107. *
  108. * @param goodsid 商品ID
  109. * @param orderId 订单ID
  110. */
  111. public static void _userConsume(string goodsid, string orderId)
  112. {
  113. PluginClass.CallStatic(
  114. "userConsume", goodsid, orderId);
  115. }
  116. /**
  117. * 查询单个订单的状态
  118. * 用来处理非消耗性商品,判断订单是否支付完成
  119. * 返回结果有加密
  120. *
  121. * @param goodsid 商品ID
  122. * @param orderId 订单ID
  123. */
  124. public static void _userQueryOrder(string goodsid, string orderId)
  125. {
  126. PluginClass.CallStatic(
  127. "userQueryOrder", goodsid, orderId);
  128. }
  129. /**
  130. * 提交用户分数
  131. * 返回用户排行榜信息,返回结果无加密
  132. *
  133. * @param score 名次
  134. * @param info 排名信息
  135. * @param rankingid 排名ID
  136. */
  137. public static void _userUploadScore(int score, string info, string rankingid)
  138. {
  139. PluginClass.CallStatic(
  140. "userUploadScore", score, info, rankingid);
  141. }
  142. /**
  143. * 获取用户自己的排名
  144. *
  145. * @param rankingid 排行榜ID
  146. */
  147. public static void _userGetUserRank(string rankingid)
  148. {
  149. PluginClass.CallStatic(
  150. "userGetUserRank", rankingid);
  151. }
  152. public static void _getActivitiesWithChannel(string channel, string language)
  153. {
  154. PluginClass.CallStatic(
  155. "getActivitiesWithChannel", channel, language);
  156. }
  157. /// <summary>
  158. /// 获取公告
  159. /// </summary>
  160. /// <param name="channel"></param>
  161. /// <param name="version"></param>
  162. /// <param name="language"></param>
  163. public static void _getGameAnoncementsWithChannel(string channel, string version, string language)
  164. {
  165. PluginClass.CallStatic(
  166. "gameAnoncementsWithChannel", channel, version, language);
  167. }
  168. /// <summary>
  169. /// 根据渠道兑换码兑换接口
  170. /// </summary>
  171. /// <param name="redeemCode"></param>
  172. /// <param name="channel"></param>
  173. public static void _redeemConsume(string redeemCode, string channel)
  174. {
  175. PluginClass.CallStatic(
  176. "redeemConsume", redeemCode, channel);
  177. }
  178. /// <summary>
  179. /// 根据渠道兑换码兑换接口,需要用户登录
  180. /// </summary>
  181. /// <param name="redeemCode"></param>
  182. /// <param name="channel"></param>
  183. /// <param name="clientId"></param>
  184. public static void _redeemUserConsume(string redeemCode, string channel, string clientId)
  185. {
  186. PluginClass.CallStatic("redeemUserConsume", redeemCode, channel, clientId);
  187. }
  188. /// <summary>
  189. /// 提交反馈接口
  190. /// </summary>
  191. /// <param name="msg">反馈信息</param>
  192. /// <param name="connect">联系方式</param>
  193. /// <param name="docInfo">存档</param>
  194. public static void _FeedBackSubmit(string msg, string connect, string docInfo)
  195. {
  196. PluginClass.CallStatic(
  197. "feedbackSubmit",
  198. msg, connect, docInfo
  199. );
  200. }
  201. public static void _PayValidate(string payToken, string gporderId, string sku, string price, int skuType,
  202. string actId)
  203. {
  204. PluginClass.CallStatic(
  205. "googleValidate",
  206. payToken, gporderId, sku, price, skuType, actId
  207. );
  208. }
  209. public static void _GameInfoUpload(Dictionary<string, string> lable)
  210. {
  211. var jsonString = Json.Serialize(lable);
  212. PluginClass.CallStatic(
  213. "gameInfoUpload", jsonString);
  214. }
  215. public static void _Serverinfo()
  216. {
  217. PluginClass.CallStatic(
  218. "Serverinfo");
  219. }
  220. }