PottingMobileServicesiOS.cs 7.7 KB

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