FitfunHead_C.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. //
  2. // FitfunHead_C.h
  3. // FitfunSDKDesign
  4. //
  5. // Created by 许晨琛 on 2018/3/24.
  6. // Copyright © 2018年 Fitfun. All rights reserved.
  7. // iOS与Unity交互的桥接类,unity部分采用C#方法,iOS部分采用C++和O-C混编,.m后缀改为.mm
  8. #import <Foundation/Foundation.h>
  9. #import <FitfunCore/FitfunCore.h>
  10. #import <FitfunSDK/FitfunSDK.h>
  11. #import <AdSupport/AdSupport.h>
  12. #ifdef DEBUG
  13. #define NSLog(FORMAT, ...) fprintf(stderr,"%s:%d\t%s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
  14. #else
  15. #define NSLog(FORMAT, ...) nil
  16. #endif
  17. #if defined(__cplusplus)
  18. extern "C"{
  19. #endif
  20. //C 拷贝
  21. char* FitfunMakeStringCopy ( const char* string )
  22. {
  23. if ( 0 == string )
  24. return 0;
  25. unsigned long nLengh = strlen(string);
  26. char* res = (char*)malloc( nLengh + 1);
  27. strcpy(res, string);
  28. res[nLengh] = '\0';
  29. return res;
  30. }
  31. //////////////////////////////////////////////////////////////
  32. #pragma mark - 获取设备当前任务占用内存
  33. double FitfunUsedMemory()
  34. {
  35. // NSLog(@"FitfunHead_C==FitfunUsedMemory==%f", [FitfunYDManager ff_usedMemory]);
  36. return [FitfunYDManager ff_usedMemory];
  37. }
  38. #pragma mark - Unity获取ServerKey ***
  39. /*
  40. key 如下:
  41. resServerIOS
  42. urlProxy
  43. webServerPost
  44. webServerGet
  45. webLoginBroadCast
  46. appVersionRequest
  47. webLoginBroadCastRealUrl
  48. appVersionUpdate
  49. serverListURL
  50. disEnableLoginManager
  51. logicServerDNS
  52. logicServerSDK
  53. GetQuestionSignsURL
  54. enableStartBroadcast
  55. enableShowGoogleIcon
  56. enableVoiceChatMsg
  57. enableRecharge
  58. resServerVersionCfg
  59. appVersionRequest
  60. enablePlatformManager
  61. enableChangeAccoutInGame
  62. enableShowPromotionIcon
  63. IsShowTrueNameRegisterBtn
  64. IsShowContact
  65. enableVoiceChatMsg
  66. */
  67. char* FitfunGetServerKey( char* key )
  68. {
  69. NSString *keyString = [NSString stringWithUTF8String:key];
  70. NSString *valueString = [FitfunYDManager ff_objectForKeywithCfgDictionary:keyString];
  71. if (![keyString isEqualToString:@"resServerIOS"]) {
  72. NSLog (@"FitfunHead_C==FitfunGetServerKey==key:%@, value:%@", keyString, valueString);
  73. }
  74. if (valueString.length != 0) {
  75. NSLog (@"FitfunHead_C==FitfunGetServerKey==key:%@, value:%s", keyString, FitfunMakeStringCopy([valueString UTF8String]));
  76. return FitfunMakeStringCopy([valueString UTF8String]);
  77. }
  78. else {
  79. const char* empty = "";
  80. NSLog (@"FitfunHead_C==FitfunGetServerKey==key:%@, value:%s", keyString, FitfunMakeStringCopy( empty ));
  81. return FitfunMakeStringCopy( empty );
  82. }
  83. }
  84. #pragma mark - 设置UserID
  85. void FitfunSetUserID( int64_t usrID )
  86. {
  87. /*
  88. 角色的role id,上传照片要用到
  89. */
  90. // NSLog(@"FitfunHead_C==FitfunSetUserID: %lld", usrID);
  91. [FitfunYDManager ff_sharedInstance].userID = usrID;
  92. }
  93. #pragma mark - 设置用户昵称
  94. void FitfunSetUserName( const char* userName )
  95. {
  96. NSLog(@"FitfunHead_C==FitfunSetUserName: %s", userName);
  97. [FitfunYDManager ff_sharedInstance].userName = [NSString stringWithUTF8String:userName];
  98. }
  99. #pragma mark - 获取App版本号
  100. char* FitfunGetVersionName()
  101. {
  102. // NSLog(@"FitfunHead_C==FitfunGetVersionName: %@", [FitfunYDManager ff_appVersion]);
  103. return FitfunMakeStringCopy([[FitfunYDManager ff_appVersion] UTF8String]);
  104. }
  105. #pragma mark - 获取设备识别码——IDFV
  106. char* FitfunGetDeviceID()
  107. {
  108. // NSLog(@"FitfunHead_C==FitfunGetDeviceID: %@", [FitfunYDManager ff_IDFV]);
  109. return FitfunMakeStringCopy([[FitfunYDManager ff_IDFV] UTF8String]);
  110. }
  111. #pragma mark - 获取设备识别码——IDFA
  112. char* FitfunGetMacAddress()
  113. {
  114. // NSString* adId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
  115. // return FitfunMakeStringCopy( [adId UTF8String] );
  116. return FitfunMakeStringCopy([[FitfunYDManager ff_IDFA] UTF8String]);
  117. }
  118. #pragma mark - 获取包名
  119. char* FitfunGetAppName()
  120. {
  121. return FitfunMakeStringCopy([[FitfunYDManager ff_appBundleID] UTF8String]);
  122. }
  123. #pragma mark - 获取操作系统版本号
  124. char* FitfunGetOSVersion()
  125. {
  126. return FitfunMakeStringCopy([[FitfunYDManager ff_systemVersion] UTF8String]);
  127. }
  128. #pragma mark - 获取手机型号
  129. char* FitfunGetPhoneModel()
  130. {
  131. return FitfunMakeStringCopy([[FitfunYDManager ff_devicemodel] UTF8String]);
  132. }
  133. #pragma mark - 获取渠道ID
  134. char* FitfunGetChannelID()
  135. {
  136. // NSLog(@"FitfunHead_C==FitfunGetChannelID:%@", [FitfunYDManager ff_sharedInstance].channelID);
  137. return FitfunMakeStringCopy( [[FitfunYDManager ff_sharedInstance].channelID UTF8String] );
  138. }
  139. #pragma mark - 获取AppKey
  140. char* FitfunGetAppKey()
  141. {
  142. // NSLog(@"FitfunHead_C==FitfunGetAppKey:%@", [FitfunYDManager ff_sharedInstance].appKey);
  143. return FitfunMakeStringCopy( [[FitfunYDManager ff_sharedInstance].appKey UTF8String] );
  144. }
  145. #pragma mark - 获取AppSecret
  146. char* FitfunGetSecret()
  147. {
  148. // NSLog(@"FitfunHead_C==FitfunGetSecret:%@", [FitfunYDManager ff_sharedInstance].appSecret);
  149. return FitfunMakeStringCopy( [[FitfunYDManager ff_sharedInstance].appSecret UTF8String] );
  150. }
  151. #pragma mark - 检查更新
  152. void FitfunCheckUpdate( const char* target, const char* msg )
  153. {
  154. NSString* targetStr = [[NSString alloc] initWithCString:target encoding:NSUTF8StringEncoding];
  155. NSString* msgStr = [[NSString alloc] initWithCString:msg encoding:NSUTF8StringEncoding];
  156. NSLog(@"FitfunHead_C==FitfunCheckUpdate:%@, %@", targetStr, msgStr);
  157. [FitfunYDManager ff_checkUpdateWithTarget:targetStr message:msgStr];
  158. }
  159. #pragma mark - 设置游戏区服ID
  160. void FitfunSetGameID( const char* val )
  161. {
  162. NSString* gameID = [NSString stringWithUTF8String:val];
  163. NSLog(@"FitfunHead_C==FitfunSetGameID:%@", gameID);
  164. [FitfunYDManager ff_sharedInstance].gameID = gameID;
  165. }
  166. #pragma mark - 定位
  167. #pragma mark 定位初始化
  168. void FitfunLocationInit()
  169. {
  170. NSLog(@"FitfunHead_C==FitfunLocationInit");
  171. [FitfunYDManager ff_initLocation];
  172. }
  173. #pragma mark 停止定位
  174. void FitfunLocationStop()
  175. {
  176. NSLog(@"FitfunHead_C==FitfunLocationStop");
  177. [FitfunYDManager ff_stopLocation];
  178. }
  179. #pragma mark 获取当前定位状态
  180. int FitfunLocationGetStatus()
  181. {
  182. //登录前调用太频繁。。。
  183. // NSLog(@"FitfunHead_C==FitfunLocationGetStatus: %d", [FitfunYDManager ff_locationStatus]);
  184. return [FitfunYDManager ff_locationStatus];
  185. }
  186. #pragma mark 纬度
  187. double FitfunLocationGetLatitude()
  188. {
  189. NSLog(@"FitfunHead_C==FitfunLocationGetLatitude: %f",[FitfunYDManager ff_latitude] );
  190. return [FitfunYDManager ff_latitude];
  191. }
  192. #pragma mark 经度
  193. double FitfunLocationGetLongitude()
  194. {
  195. NSLog(@"FitfunHead_C==FitfunLocationGetLongitude: %f",[FitfunYDManager ff_longitude]);
  196. return [FitfunYDManager ff_longitude];
  197. }
  198. #pragma mark - 视频处理
  199. void FitfunPlayMovie( const char* path, const char* type, const char* u3dPath )
  200. {
  201. NSString *pathStr = [NSString stringWithUTF8String:path];
  202. NSString *typeStr = [NSString stringWithUTF8String:type];
  203. NSString *u3dPathStr = [NSString stringWithUTF8String:u3dPath];
  204. //NSLog(@"FitfunHead_C==FitfunPlayMovie path: %@, type:%@, u3dPath:%@",pathStr, typeStr, u3dPathStr );
  205. [[FitfunYDManager ff_sharedInstance] ff_play:pathStr TypeName:typeStr u3dPath:u3dPathStr];
  206. }
  207. /// SnapShot Interface
  208. #pragma mark - 照片处理
  209. #pragma mark 调用相机
  210. void FitfunSnapShotCamera()
  211. {
  212. NSLog(@"FitfunHead_C==FitfunSnapShotCamera");
  213. [[FitfunYDManager ff_sharedInstance] ff_takePhotoFromCamera];
  214. }
  215. #pragma mark 调用相册
  216. void FitfunSnapShotLibrary()
  217. {
  218. NSLog(@"FitfunHead_C==FitfunSnapShotLibrary");
  219. [[FitfunYDManager ff_sharedInstance] ff_takePhotoFromLibrary];
  220. }
  221. #pragma mark 裁剪图片
  222. int FitfunClipShot( const char* path, float x, float y, float width, float height )
  223. {
  224. NSString *pathStr = [NSString stringWithUTF8String:path];
  225. NSLog(@"FitfunHead_C==FitfunClipShot:path:%@, x:%.f, y:%.f, width:%.f, height:%.f", pathStr, x, y, width, height);
  226. return [FitfunYDManager ff_clipPhotoFromPath:pathStr X:x Y:y Width:width Height:height];
  227. }
  228. #pragma mark 上传图片
  229. int FitfunPostImage( const char* path )
  230. {
  231. NSString *pathStr = [NSString stringWithUTF8String:path];
  232. NSLog(@"FitfunHead_C==FitfunPostImage path:%@", pathStr);
  233. return [FitfunYDManager ff_uploadPhotoToWebServerWithPath:pathStr];
  234. }
  235. #pragma mark - 云娃语音--->废弃
  236. /// YvIm Interface
  237. //isTest 1 测试环境 0 真机环境
  238. #pragma mark 云娃初始化
  239. void FitFuninitYvIm(const char* appid, const char* isTest)
  240. {
  241. // NSString *appidStr = [NSString stringWithUTF8String:appid];
  242. // NSString *isTestStr = [NSString stringWithUTF8String:isTest];
  243. NSLog(@"FitfunHead_C==FitFuninitYvIm appid:%@, isTest:%@", appidStr, isTestStr);
  244. [FitfunYDManager ff_initYvimSDK];
  245. }
  246. #pragma mark 云娃第三方登录
  247. void FitFunThirdLoginWithTT( const char* userid,const char* nickname)
  248. {
  249. NSString *userIDStr = [NSString stringWithUTF8String:userid];
  250. NSString *nickNameStr = [NSString stringWithUTF8String:nickname];
  251. NSLog(@"FitfunHead_C==FitFunThirdLoginWithTT userid:%@, nickname:%@", userIDStr, nickNameStr);
  252. NSString * tt = [NSString stringWithFormat:@"{\"uid\": \"%@\", \"nickname\": \"%@\"}",userIDStr,nickNameStr];
  253. [FitfunYDManager ff_thirdLoginWithTT:tt];
  254. }
  255. #pragma mark 云娃登录频道
  256. void FitFunLoginChannel( const char* wildCard, const char* channelId)
  257. {
  258. NSString *wildCardString = [[NSString alloc] initWithCString:wildCard encoding:NSUTF8StringEncoding];
  259. NSString *channelCardString = [[NSString alloc] initWithCString:channelId encoding:NSUTF8StringEncoding];
  260. NSLog(@"FitfunHead_C==FitFunLoginChannel wild:%@, channelID:%@", wildCardString, channelCardString);
  261. [FitfunYDManager ff_loginChannel:wildCardString channelId:channelCardString];
  262. }
  263. #pragma mark 云娃发送文字消息
  264. BOOL FitFunChannelTextMsg( const char* textMsg, const char* wildCard, const char* expand)
  265. {
  266. NSString *wildCardString = [[NSString alloc] initWithCString:wildCard encoding:NSUTF8StringEncoding];
  267. NSString *textMessage = [[NSString alloc] initWithCString:textMsg encoding:NSUTF8StringEncoding];
  268. NSString *expandString = [[NSString alloc] initWithCString:expand encoding:NSUTF8StringEncoding];
  269. NSLog(@"FitfunHead_C==FitFunChannelTextMsg textMsg:%@, wildCard:%@, expand:%@", textMessage, wildCardString, expandString);
  270. return [FitfunYDManager ff_channelTextMsg:textMessage wildCard:wildCardString expand:expandString];
  271. }
  272. #pragma mark 云娃开始录音
  273. void FitFunStartRecord(const char* strfilepath, const char* ext)
  274. {
  275. NSString *strFile = [[NSString alloc] initWithCString:strfilepath encoding:NSUTF8StringEncoding];
  276. NSString *extString = [[NSString alloc] initWithCString:ext encoding:NSUTF8StringEncoding];
  277. NSLog(@"FitfunHead_C==FitFunStartRecord strFile:%@, extString:%@", strFile, extString);
  278. [FitfunYDManager ff_startRecord:strFile ext:extString];
  279. }
  280. #pragma mark 云娃停止录音
  281. void FitFunStopRecord()
  282. {
  283. NSLog(@"FitfunHead_C==FitFunStopRecord");
  284. [FitfunYDManager ff_stopRecord];
  285. }
  286. #pragma mark 播放音频
  287. void FitFunPlayAudioWithUrl(const char* strUrl, const char* ext)
  288. {
  289. ext = ""; //不加这句,iOS 11 播放音频会闪退
  290. NSString *strUrlString = [[NSString alloc] initWithCString:strUrl encoding:NSUTF8StringEncoding];
  291. NSString *extString = [[NSString alloc] initWithCString:ext encoding:NSUTF8StringEncoding];
  292. NSLog(@"FitfunHead_C==FitFunPlayAudioWithUrl strUrl:%@, ext:%@", strUrlString, extString);
  293. [FitfunYDManager ff_playAudioWithUrl:strUrlString filepath:nil ext:extString];
  294. }
  295. #pragma mark 停止播放音频
  296. void FitFunStopPlayAudio()
  297. {
  298. // NSLog(@"FitfunHead_C==FitFunStopPlayAudio");
  299. [FitfunYDManager ff_stopPlayAudio];
  300. }
  301. #pragma mark 上传音频
  302. void FitFunUploadFileReq(const char* filename, const char* fileId)
  303. {
  304. NSString *fileNameString = [[NSString alloc] initWithCString:filename encoding:NSUTF8StringEncoding];
  305. NSString *fileIdString = [[NSString alloc] initWithCString:fileId encoding:NSUTF8StringEncoding];
  306. NSLog(@"FitfunHead_C==FitFunUploadFileReq fileNameString:%@, fileIdString:%@", fileNameString, fileIdString);
  307. if ( NSNotFound == [fileNameString rangeOfString:@"/"].location )
  308. {
  309. fileNameString = [NSString stringWithFormat:@"%@/%@", [FitfunYDManager ff_cachePath], fileNameString];
  310. }
  311. [FitfunYDManager ff_uploadFileReq:fileNameString fileId:fileIdString];
  312. }
  313. #pragma mark 音频下载
  314. void FitFunDownloadFileReq(const char* url, const char* filename, const char* fileId)
  315. {
  316. NSString *urlString = [[NSString alloc] initWithCString:url encoding:NSUTF8StringEncoding];
  317. NSString *fileNameString = [[NSString alloc] initWithCString:filename encoding:NSUTF8StringEncoding];
  318. NSString *fileIdSting = [[NSString alloc] initWithCString:fileId encoding:NSUTF8StringEncoding];
  319. NSLog(@"FitfunHead_C==FitFunDownloadFileReq urlString:%@, fileNameString:%@, fileIdString:%@", urlString,fileNameString, fileIdSting);
  320. [FitfunYDManager ff_downloadFileReq:urlString filename:fileNameString fileId:fileIdSting];
  321. }
  322. #pragma mark - 同步POST请求
  323. const char* FitfunPostData(const char* webUrl,const char* m_Params)
  324. {
  325. NSString *webUrlString = [[NSString alloc] initWithCString:webUrl encoding:NSUTF8StringEncoding];
  326. NSString *m_ParamsString = [[NSString alloc] initWithCString:m_Params encoding:NSUTF8StringEncoding];
  327. NSLog(@"FitfunHead_C==FitfunPostData webUrlString:%@, m_ParamsString:%@", webUrlString, m_ParamsString);
  328. return FitfunMakeStringCopy([[FitfunYDManager PostToWeb:webUrlString params:m_ParamsString] UTF8String]);
  329. }
  330. #pragma mark - 文件下载
  331. //断点续传
  332. #pragma mark 断点下载
  333. void FitfunBreakPtDownload( const char* url,const char * filePath ){
  334. NSString *urlString = [[NSString alloc] initWithCString:url encoding:NSUTF8StringEncoding];
  335. NSString *filePathString = [[NSString alloc] initWithCString:filePath encoding:NSUTF8StringEncoding];
  336. NSDate* dat = [NSDate dateWithTimeIntervalSinceNow:0];
  337. NSTimeInterval a=[dat timeIntervalSince1970] * 1000;
  338. NSString*timeString = [NSString stringWithFormat:@"%0.f", a];//转为字符型
  339. NSString *dataUrlstring = urlString;
  340. if ([urlString containsString:@"?t="] == NO) {
  341. dataUrlstring = [NSString stringWithFormat:@"%@?t=%@",urlString,timeString];;
  342. }
  343. NSLog(@"FitfunHead_C==FitfunBreakPtDownload urlString:%@, filePathString:%@", dataUrlstring, filePathString);
  344. [FitfunYDManager ff_startBreakDownloadWithURLStr:dataUrlstring savePath:filePathString];
  345. }
  346. #pragma mark 文件下载是否成功
  347. int FitfunBreakPtIsSuccess() {
  348. return [FitfunYDManager ff_breakDownloadIsSuccess];
  349. }
  350. #pragma mark 获取文件下载进度
  351. int FitfunBreakPtGetProgress() {
  352. return [FitfunYDManager ff_breakDownloadProgress];
  353. }
  354. #pragma mark 文件总字节数
  355. int FitfunBreakPtGetTotalBytes() {
  356. NSLog(@"FitfunHead_C==FitfunBreakPtGetTotalBytes: %d", [FitfunYDManager ff_breakDownloadTotalBytes]);
  357. return [FitfunYDManager ff_breakDownloadTotalBytes];
  358. }
  359. #pragma mark 立即获取文件大小 字节
  360. long FitfunGetRemoteFileBytes( const char* url) {
  361. NSString *urlStr = [[NSString alloc] initWithCString:url encoding:NSUTF8StringEncoding];
  362. long dataLength = [FitfunYDManager URLHEAD:urlStr];
  363. NSLog(@"FitfunHead_C==FitfunGetRemoteFileBytes ==url:%@, 文件大小:%zd字节==", urlStr, dataLength);
  364. return dataLength;
  365. }
  366. #pragma mark - 网络连接
  367. #pragma mark 建立连接
  368. void FitfunNetLink( const char* value, int port )
  369. {
  370. NSString *hostName = [[NSString alloc] initWithCString:value encoding:NSUTF8StringEncoding];
  371. // NSLog(@"FitfunHead_C==FitfunNetLink:hostName:%@, port:%d", hostName, port);
  372. [FitfunYDManager ff_connectServer:hostName port:port];
  373. }
  374. #pragma mark 向服务器发消息
  375. void FitfunNetSend( const char* value )
  376. {
  377. NSString *message = [[NSString alloc] initWithCString:value encoding:NSUTF8StringEncoding];
  378. // NSLog(@"FitfunHead_C==FitfunNetSend: message:%@", message);
  379. [FitfunYDManager ff_sendSeverMessage:message];
  380. }
  381. #pragma mark 关闭网络连接
  382. void FitfunNetClose()
  383. {
  384. [FitfunYDManager ff_closeSocket];
  385. }
  386. #pragma mark - 打开网页
  387. void FitFunOpenWebUrl(const char* webUrl)
  388. {
  389. NSString *webUrlString = [[NSString alloc] initWithCString:webUrl encoding:NSUTF8StringEncoding];
  390. NSLog(@"FitfunHead_C==FitFunOpenWebUrl webUrlString:%@", webUrlString);
  391. [[FitfunYDManager ff_sharedInstance] ff_openWebWithURL:webUrlString];
  392. }
  393. #pragma mark - 登录 *****************接渠道需要变更接入SDK*****************************************
  394. #pragma mark -
  395. void FitfunLogin( char* key )
  396. {
  397. NSString *keyStr = [NSString stringWithUTF8String:key];
  398. NSLog(@"FitfunHead_C==FitfunLogin: key:%@", keyStr);
  399. [[FitfunSDKManager ff_sharedInstance] ff_showLoginViewIsAutoLogin:YES currentController:[FitfunYDManager ff_sharedInstance].rootViewController];
  400. }
  401. #pragma mark 切换账号/退出 *****************接渠道需要变更接入SDK************************************
  402. void FitfunSwitchAccount( char* value )
  403. {
  404. NSLog(@"FitfunHead_C==FitfunSwitchAccount");
  405. [[FitfunSDKManager ff_sharedInstance] ff_switchAccount];
  406. /*
  407. 如果渠道没有切换账号/退出功能,就直接调用下面的方法
  408. //向u3d发送消息,注销登录
  409. [FitfunYDManager ff_sendMessageToU3DWithTarget:@"ledouApi" message:@"OnLogoutGame" param:@""];
  410. */
  411. }
  412. #pragma mark - 支付 *****************接渠道需要变更接入SDK********************************************
  413. #pragma mark -
  414. void FitfunPay( char* c_amount, char* c_productID, char* c_extraInfo, char* c_desc )
  415. {
  416. NSString *strAmount = [[NSString alloc] initWithCString:c_amount encoding:NSUTF8StringEncoding];
  417. NSString *strProductID = [[NSString alloc] initWithCString:c_productID encoding:NSUTF8StringEncoding];
  418. NSString *strExtraInfo = [[NSString alloc] initWithCString:c_extraInfo encoding:NSUTF8StringEncoding];
  419. NSString *descStr = [NSString stringWithUTF8String:c_desc];
  420. /*strExtraInfo:productId=10002&userId=85291267&environment=QA*/
  421. NSLog(@"FitfunHead_C==FitfunPay strAmount:%@, strProductID:%@, strExtraInfo:%@, descStr:%@", strAmount, strProductID, strExtraInfo, descStr);
  422. [[FitfunSDKManager ff_sharedInstance] ff_payWithProductID:strProductID amount:strAmount];
  423. }
  424. #pragma mark - 个人中心
  425. void FitFunShowSDKSetting()
  426. {
  427. NSLog(@"FitfunHead_C==FitFunShowSDKSetting");
  428. [[FitfunSDKManager ff_sharedInstance] ff_showMeCenter];
  429. }
  430. #pragma mark - 分享
  431. void FitFunShareWithImageAndText(const char* imagePath, const char* text)
  432. {
  433. NSString *imagePathString = [[NSString alloc] initWithCString:imagePath encoding:NSUTF8StringEncoding];
  434. NSString *textString = [[NSString alloc] initWithCString:text encoding:NSUTF8StringEncoding];
  435. NSLog(@"FitfunHead_C==FitFunShareWithImageAndText imagePathString:%@, textString:%@", imagePathString, textString);
  436. [[FitfunSDKManager ff_sharedInstance] ff_shareWithImage:imagePathString text:textString];
  437. }
  438. #pragma mark - 通用接口函数 Set
  439. /*
  440. 函数名 参数 对照表
  441. funcName:OnGameInit params:
  442. funcName:FitFunUpdateUserInfo params:{"USER_INFO_ID":"ODUyOTEyNjc=","USER_INFO_NAME":"6Z2e5Yeh55qE5ZyfMDE=","USER_INFO_LEVEL":"Mw==","USER_INFO_VIP_LEVEL":"MA==","USER_INFO_BALANCE":"MA==","USER_INFO_GUILD_NAME":"MA==","USER_INFO_SERVER_ID":"Mg==","USER_INFO_SERVER_NAME":"5YWo5rCR5LmQ6Iie6YCB5a6h5pyN","USER_INFO_LEVEL_CHANGE_TIME_CHUO_AND_LEVEL":""}
  443. funcName:role_login params:
  444. funcName:role_level_change params:
  445. funcName: params:
  446. funcName: params:
  447. funcName: params:
  448. */
  449. void FitFunSetFuncAny(const char* funcName, const char* params )
  450. {
  451. NSString *funcNameStr = [[NSString alloc] initWithCString:funcName encoding:NSUTF8StringEncoding];
  452. NSString *paramsStr = [[NSString alloc] initWithCString:params encoding:NSUTF8StringEncoding];
  453. NSLog(@"FitfunHead_C==FitFunSetFuncAny funcNameStr:%@, paramsStr:%@", funcNameStr, paramsStr);
  454. [[FitfunSDKManager ff_sharedInstance] ff_setFuncAnyWithFuncName:funcNameStr params:paramsStr];
  455. }
  456. #pragma mark - 通用接口函数 Get
  457. const char* FitFunGetFuncAny( const char* funcName, const char* params)
  458. {
  459. NSString *funcNameStr = [[NSString alloc] initWithCString:funcName encoding:NSUTF8StringEncoding];
  460. NSString *paramsStr = [[NSString alloc] initWithCString:params encoding:NSUTF8StringEncoding];
  461. //NSLog(@"FitfunHead_C==FitFunGetFuncAny funcNameStr:%@, paramsStr:%@", funcNameStr, paramsStr);
  462. if ( [funcNameStr isEqualToString:@"GetProviderName"] )
  463. {
  464. NSString* providerValue = @"";
  465. return FitfunMakeStringCopy([providerValue UTF8String]);
  466. }
  467. NSString *returnValue = [[FitfunSDKManager ff_sharedInstance] ff_getFuncAnyWithFuncName:funcNameStr params:paramsStr];
  468. if (returnValue == nil || returnValue.length == 0) {
  469. NSLog(@"FitfunHead_C==FitFunGetFuncAny funcNameStr:%@, paramsStr:%@", funcNameStr, paramsStr);
  470. }
  471. return FitfunMakeStringCopy([returnValue UTF8String]);
  472. }
  473. void FitFunExitGame(){
  474. UIWindow *window = [UIApplication sharedApplication].keyWindow;
  475. // 动画 1
  476. [UIView animateWithDuration:0.6f animations:^{
  477. window.alpha = 0;
  478. window.frame = CGRectMake(0, window.bounds.size.width, 0, 0);
  479. } completion:^(BOOL finished) {
  480. exit(0);
  481. }];
  482. }
  483. #pragma mark -
  484. #pragma mark - 已废弃函数
  485. void FitfunSetRoleName( const char* rolename ){
  486. NSLog(@"FitfunHead_C==FitfunSetRoleName");
  487. }
  488. //游戏中心
  489. void FitFunReportScoreAndScoreInt(const char* scoreId,const char *scoreInt)
  490. {
  491. NSLog(@"FitfunHead_C==FitFunReportScoreAndScoreInt");
  492. }
  493. void FitFunAchievementsWithId (const char *achievementsId)
  494. {
  495. NSLog(@"FitfunHead_C==FitFunAchievementsWithId");
  496. }
  497. void FitFunShowGameCentre ()
  498. {
  499. NSLog(@"FitfunHead_C==FitFunShowGameCentre");
  500. }
  501. //设置服务器host === 存在延迟,不合理 (程序一启动就应该调用此方法的,初始化需要用到根地址)
  502. void FitfunSetSDKUrl( const char* val )
  503. {
  504. // NSString* SDKURL = [NSString stringWithUTF8String:val];
  505. // NSLog(@"FitfunHead_C==FitfunSetSDKUrl:%@", SDKURL);
  506. }
  507. // 云娃登出频道
  508. void FitFunLogoutChannel()
  509. {
  510. // NSLog(@"FitfunHead_C==FitFunLogoutChannel");
  511. }
  512. //设置照片上传地址 -- 正式环境下没用
  513. void FitfunSetPhotoPostUrl( const char* val )
  514. {
  515. //只有QA环境下才会执行这个方法
  516. NSString *photoPostURL = [NSString stringWithUTF8String:val];
  517. NSLog(@"FitfunHead_C==FitfunSetPhotoPostUrl:%@", photoPostURL);
  518. [FitfunYDManager ff_sharedInstance].photoPostKURL = photoPostURL;
  519. }
  520. #if defined(__cplusplus)
  521. }
  522. #endif